Skip to content

Commit

Permalink
tests: fix tests for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
thounyy committed Nov 2, 2024
1 parent bfb9fa8 commit 34ab7e2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
Binary file added packages/actions/.coverage_map.mvcov
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/actions/tests/treasury_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fun test_deposit_owned() {
let auth = multisig::authenticate(&extensions, &account, b"".to_string(), scenario.ctx());
treasury::open(auth, &mut account, b"Degen".to_string(), scenario.ctx());

let id = keep_coin(OWNER, 5, &mut scenario);
let id = keep_coin(account.addr(), 5, &mut scenario);
let auth = multisig::authenticate(&extensions, &account, role(b"Deposit", b"Degen"), scenario.ctx());
treasury::deposit_owned<Multisig, Approvals, SUI>(
auth,
Expand Down
Binary file added packages/config/.coverage_map.mvcov
Binary file not shown.
Binary file added packages/extensions/.coverage_map.mvcov
Binary file not shown.
Binary file added packages/protocol/.coverage_map.mvcov
Binary file not shown.
22 changes: 12 additions & 10 deletions packages/protocol/tests/coin_operations_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ fun full_role(): String {
full_role
}

fun keep_coin(addr: address, amount: u64, scenario: &mut Scenario): ID {
let coin = coin::mint_for_testing<SUI>(amount, scenario.ctx());
let id = object::id(&coin);
transfer::public_transfer(coin, addr);

scenario.next_tx(OWNER);
id
}

// === Tests ===

#[test]
Expand Down Expand Up @@ -98,21 +107,14 @@ fun test_merge_2_coins_and_split() {
let (mut scenario, extensions, mut account) = start();
let account_address = account.addr();

let coin1 = coin::mint_for_testing<SUI>(60, scenario.ctx());
transfer::public_transfer(coin1, account_address);
scenario.next_tx(OWNER);
let receiving1 = ts::most_recent_receiving_ticket<Coin<SUI>>(&object::id(&account));
let id1 = keep_coin(account_address, 60, &mut scenario);
let id2 = keep_coin(account_address, 40, &mut scenario);

let coin2 = coin::mint_for_testing<SUI>(40, scenario.ctx());
transfer::public_transfer(coin2, account_address);
scenario.next_tx(OWNER);
let receiving2 = ts::most_recent_receiving_ticket<Coin<SUI>>(&object::id(&account));

let auth = auth::new(&extensions, full_role(), account.addr(), version::current());
let merge_coin_id = coin_operations::merge_and_split<bool, bool, SUI>(
&auth,
&mut account,
vector[receiving1, receiving2],
vector[ts::receiving_ticket_by_id(id1), ts::receiving_ticket_by_id(id2)],
vector[100],
scenario.ctx()
);
Expand Down

0 comments on commit 34ab7e2

Please sign in to comment.