diff --git a/vm/framework/starcoin-framework/integration-tests/object/basic.exp b/vm/framework/starcoin-framework/integration-tests/object/basic.exp new file mode 100644 index 0000000000..5b3b20e7c6 --- /dev/null +++ b/vm/framework/starcoin-framework/integration-tests/object/basic.exp @@ -0,0 +1,12 @@ +processed 3 tasks + +task 2 'run'. lines 60-93: +{ + "gas_used": 678890, + "status": { + "MoveAbort": { + "location": "Script", + "abort_code": "10001" + } + } +} diff --git a/vm/framework/starcoin-framework/integration-tests/object/basic.move b/vm/framework/starcoin-framework/integration-tests/object/basic.move new file mode 100644 index 0000000000..63d5863029 --- /dev/null +++ b/vm/framework/starcoin-framework/integration-tests/object/basic.move @@ -0,0 +1,93 @@ +//# init -n dev + +//# faucet --addr alice --amount 10000000000000000 + +// +// //# publish +// module alice::basic_module { +// use std::option; +// use std::signer; +// use std::string; +// +// use starcoin_framework::coin; +// use starcoin_framework::fungible_asset::{create_store, FungibleStore}; +// use starcoin_framework::object; +// use starcoin_framework::starcoin_coin::STC; +// use starcoin_std::debug; +// +// #[resource_group_member(group = starcoin_framework::object::ObjectGroup)] +// struct Sample has key { +// value: u64 +// } +// +// struct ObjectWrap has key { +// obj_addr: address, +// store: object::Object +// } +// +// public fun create_sample(account: &signer, value: u64) { +// debug::print(&string::utf8(b"alice::basic_module::create_sample | 1")); +// +// let ref = object::create_object_from_account(account); +// move_to(&object::generate_signer(&ref), Sample { +// value +// }); +// +// debug::print(&string::utf8(b"alice::basic_module::create_sample | 2")); +// +// let metadata = coin::paired_metadata(); +// +// debug::print(&string::utf8(b"alice::basic_module::create_sample | 3")); +// +// let store = create_store(&ref, option::destroy_some(metadata)); +// +// debug::print(&string::utf8(b"alice::basic_module::create_sample | 4")); +// +// move_to(account, ObjectWrap { +// obj_addr: object::address_from_constructor_ref(&ref), +// store, +// }); +// +// debug::print(&string::utf8(b"alice::basic_module::create_sample | 5")); +// } +// +// public fun check_value(account: &signer): u64 acquires ObjectWrap, Sample { +// let obj_wrap = borrow_global(signer::address_of(account)); +// borrow_global(obj_wrap.obj_addr).value +// } +// } + +//# run --signers alice +script { + use std::option; + use starcoin_framework::object; + use starcoin_framework::coin; + use starcoin_framework::starcoin_coin::STC; + + fun test_metadata(_account: &signer) { + let metadata = coin::paired_metadata(); + assert!(option::is_some(&metadata), 10000); + let metdata_obj = option::destroy_some(metadata); + assert!(object::is_object(object::object_address(&metdata_obj)), 10001); + } +} + + +// //# run --signers alice +// script { +// use alice::basic_module; +// +// fun test_create_object(account: &signer) { +// basic_module::create_sample(account, 10); +// } +// } +// +// +// //# run --signers alice +// script { +// use alice::basic_module; +// +// fun test_create_object(account: &signer) { +// assert!(basic_module::check_value(account) == 10, 10010); +// } +// } \ No newline at end of file