Skip to content

Commit

Permalink
update: chain_id - add initialize_for_test instead of change_id
Browse files Browse the repository at this point in the history
  • Loading branch information
linnefromice committed Sep 22, 2022
1 parent c4a0d2e commit 2560a3e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions aptos-move/framework/aptos-framework/sources/chain_id.move
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ module aptos_framework::chain_id {
}

#[test_only]
fun change_id(value: u8) acquires ChainId {
let id = &mut borrow_global_mut<ChainId>(@aptos_framework).id;
*id = value;
public fun initialize_for_test(aptos_framework: &signer, id: u8) {
initialize(aptos_framework, id);
}

#[test(aptos_framework = @0x1)]
fun test_get(aptos_framework: &signer) acquires ChainId {
initialize(aptos_framework, 1u8);
initialize_for_test(aptos_framework, 1u8);
assert!(get() == 1u8, 1);
change_id(2u8);
assert!(get() == 2u8, 1);
}
}

0 comments on commit 2560a3e

Please sign in to comment.