-
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.
[Framework Testing] Add test to account_storage exists and move_from (#…
…358)
- Loading branch information
Showing
7 changed files
with
74 additions
and
11 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
crates/rooch-framework-tests/tests/cases/account_storage/exists_and_move_from.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,7 @@ | ||
processed 3 tasks | ||
|
||
task 1 'publish'. lines 3-34: | ||
status EXECUTED | ||
|
||
task 2 'run'. lines 36-44: | ||
status EXECUTED |
44 changes: 44 additions & 0 deletions
44
crates/rooch-framework-tests/tests/cases/account_storage/exists_and_move_from.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,44 @@ | ||
//# init --addresses test=0x42 | ||
|
||
//# publish | ||
module test::m { | ||
use std::signer; | ||
use moveos_std::storage_context::{StorageContext}; | ||
use moveos_std::account_storage; | ||
|
||
struct Test has key{ | ||
addr: address, | ||
version: u64 | ||
} | ||
|
||
fun init(ctx: &mut StorageContext, sender: &signer) { | ||
let sender_addr = signer::address_of(sender); | ||
account_storage::global_move_to(ctx, sender, Test{ | ||
addr: sender_addr, | ||
version: 0, | ||
}); | ||
} | ||
|
||
public fun test_exists_and_move_from(ctx: &mut StorageContext, sender:&signer){ | ||
let sender_addr = signer::address_of(sender); | ||
let test_exists = account_storage::global_exists<Test>(ctx, sender_addr); | ||
assert!(test_exists, 1); | ||
let test = account_storage::global_move_from<Test>(ctx, sender_addr); | ||
let test_exists = account_storage::global_exists<Test>(ctx, sender_addr); | ||
assert!(!test_exists, 2); | ||
let Test{ | ||
addr: _, | ||
version: _ | ||
} = test; | ||
} | ||
} | ||
|
||
//# run --signers test | ||
script { | ||
use moveos_std::storage_context::{StorageContext}; | ||
use test::m; | ||
|
||
fun main(ctx: &mut StorageContext, sender: signer) { | ||
m::test_exists_and_move_from(ctx, &sender); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
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
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