-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[integration-test-runner] private_generics tests. (#354)
Co-authored-by: Feliciss <[email protected]>
- Loading branch information
Showing
4 changed files
with
88 additions
and
26 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
crates/rooch-integration-test-runner/tests/cases/private_generics_direct_call.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
49 changes: 49 additions & 0 deletions
49
crates/rooch-integration-test-runner/tests/cases/private_generics_direct_call.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<T1: store>(ctx: &mut StorageContext, s: &signer) { | ||
account_storage::global_move_to<Foo>(ctx, s, Foo { x: 500 }) | ||
} | ||
|
||
public fun run(ctx: &mut StorageContext, s: &signer) { | ||
let _ = string::utf8(b"account_storage"); | ||
publish_foo<Foo>(ctx, s) | ||
} | ||
|
||
public fun call_moveos_std<T: store>(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<Foo>(object_storage, object_id); | ||
debug::print(&obj); | ||
let (_id,_owner,value) = object::unpack(obj); | ||
account_storage::global_move_to<Foo>(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters