diff --git a/crates/rooch-integration-test-runner/tests/cases/private_generics_direct_call.exp b/crates/rooch-integration-test-runner/tests/cases/private_generics_direct_call.exp new file mode 100644 index 000000000..21c886b32 --- /dev/null +++ b/crates/rooch-integration-test-runner/tests/cases/private_generics_direct_call.exp @@ -0,0 +1,12 @@ +processed 4 tasks + +task 1 'publish'. lines 3-35: +status EXECUTED + +task 2 'run'. lines 37-45: +status EXECUTED + +task 3 'view'. lines 47-49: +store key 0x42::test::Foo { + x: 500 +} diff --git a/crates/rooch-integration-test-runner/tests/cases/private_generics_direct_call.move b/crates/rooch-integration-test-runner/tests/cases/private_generics_direct_call.move new file mode 100644 index 000000000..e242acb27 --- /dev/null +++ b/crates/rooch-integration-test-runner/tests/cases/private_generics_direct_call.move @@ -0,0 +1,49 @@ +//# init --addresses creator=0x42 + +//# publish +module creator::test { + use std::string; + use moveos_std::account_storage; + use moveos_std::storage_context::{Self, StorageContext}; + use moveos_std::object; + use moveos_std::object_id::ObjectID; + use moveos_std::object_storage; + use std::debug; + + struct Foo has key, store { + x: u64, + } + + #[private_generics(T1)] + fun publish_foo(ctx: &mut StorageContext, s: &signer) { + account_storage::global_move_to(ctx, s, Foo { x: 500 }) + } + + public fun run(ctx: &mut StorageContext, s: &signer) { + let _ = string::utf8(b"account_storage"); + publish_foo(ctx, s) + } + + public fun call_moveos_std(ctx: &mut StorageContext, sender: &signer, object_id: ObjectID) { + let object_storage = storage_context::object_storage_mut(ctx); + debug::print(&object_id); + let obj = object_storage::remove(object_storage, object_id); + debug::print(&obj); + let (_id,_owner,value) = object::unpack(obj); + account_storage::global_move_to(ctx, sender, value); + } +} + +//# run --signers creator +script { + use creator::test; + use moveos_std::storage_context::StorageContext; + + fun main(ctx: &mut StorageContext, s: &signer) { + test::run(ctx, s); + } +} + +//# view +//# --address 0x42 +//# --resource 0x42::test::Foo diff --git a/crates/rooch-integration-test-runner/tests/cases/private_generics_indirect_call.exp b/crates/rooch-integration-test-runner/tests/cases/private_generics_indirect_call.exp index 2b0ab1c6f..0fcdf5631 100644 --- a/crates/rooch-integration-test-runner/tests/cases/private_generics_indirect_call.exp +++ b/crates/rooch-integration-test-runner/tests/cases/private_generics_indirect_call.exp @@ -3,23 +3,29 @@ processed 3 tasks task 1 'publish'. lines 3-8: status EXECUTED -task 2 'publish'. lines 10-48: +task 2 'publish'. lines 10-43: Error: error: resource type "KeyStruct" in function "0x2::object_storage::remove" not defined in current module or not allowed - ┌─ /tmp/tempfile:37:19 + ┌─ /tmp/tempfile:34:19 │ -37 │ let obj = object_storage::remove(object_storage, object_id); +34 │ let obj = object_storage::remove(object_storage, object_id); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: resource type "KeyStruct" in function "0x2::object::unpack" not defined in current module or not allowed - ┌─ /tmp/tempfile:39:34 + ┌─ /tmp/tempfile:36:34 │ -39 │ let (_id,_owner,value) = object::unpack(obj); +36 │ let (_id,_owner,value) = object::unpack(obj); │ ^^^^^^^^^^^^^^^^^^^ error: resource type "KeyStruct" in function "0x2::account_storage::global_move_to" not defined in current module or not allowed - ┌─ /tmp/tempfile:40:9 + ┌─ /tmp/tempfile:37:9 │ -40 │ account_storage::global_move_to(ctx, &sender, value); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +37 │ account_storage::global_move_to(ctx, sender, value); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: resource type "KeyStruct" in function "0x42::test::publish_foo" not defined in current module or not allowed + ┌─ /tmp/tempfile:29:9 + │ +29 │ publish_foo(ctx, s) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/crates/rooch-integration-test-runner/tests/cases/private_generics_indirect_call.move b/crates/rooch-integration-test-runner/tests/cases/private_generics_indirect_call.move index 805595d5a..789bbdb6c 100644 --- a/crates/rooch-integration-test-runner/tests/cases/private_generics_indirect_call.move +++ b/crates/rooch-integration-test-runner/tests/cases/private_generics_indirect_call.move @@ -9,40 +9,35 @@ module creator::test0 { //# publish module creator::test { + use std::string; + use std::debug; + use creator::test0::KeyStruct; + use moveos_std::account_storage; + use moveos_std::storage_context::{Self, StorageContext}; + use moveos_std::object; + use moveos_std::object_id::ObjectID; + use moveos_std::object_storage; + struct Foo has key { x: u64, } - use std::string::{Self}; - use moveos_std::account_storage; #[private_generics(T1)] public fun publish_foo(ctx: &mut StorageContext, s: &signer) { account_storage::global_move_to(ctx, s, Foo { x: 500 }) } - use creator::test0::KeyStruct; - // use moveos_std::account_storage::AccountStorage; - public fun run(ctx: &mut StorageContext, s: &signer) { let _ = string::utf8(b"account_storage"); - publish_foo(ctx, s) + publish_foo(ctx, s) } - use moveos_std::storage_context::{Self, StorageContext}; - use moveos_std::object; - use moveos_std::object_id::ObjectID; - use moveos_std::object_storage; - use std::debug; - - struct S has store, key { v: u8 } - struct Cup has store, key { v: u8 } - - public fun call_moveos_std(ctx: &mut StorageContext, sender: signer, object_id: ObjectID) { + public fun call_moveos_std(ctx: &mut StorageContext, sender: &signer, object_id: ObjectID) { let object_storage = storage_context::object_storage_mut(ctx); - //let obj = object_storage::remove>(object_storage, object_id); + debug::print(&object_id); let obj = object_storage::remove(object_storage, object_id); debug::print(&obj); let (_id,_owner,value) = object::unpack(obj); - account_storage::global_move_to(ctx, &sender, value); + account_storage::global_move_to(ctx, sender, value); } }