Skip to content

Commit

Permalink
add test to mint tokens and then transfer inside the receiver hook
Browse files Browse the repository at this point in the history
  • Loading branch information
abright committed Sep 20, 2022
1 parent 6038776 commit d0edd2f
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions testing/fil_token_integration/tests/frc46_multi_actor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,37 @@ fn frc46_multi_actor_tests() {
assert_eq!(balance, TokenAmount::from_atto(0));
let balance = tester.get_balance(operator[0].1, token_actor, bob);
assert_eq!(balance, TokenAmount::from_atto(100));

// TEST: mint to alice who transfers to bob inside receiver hook, bob accepts
let ret_val = tester.mint_tokens(
operator[0].1,
token_actor,
alice,
TokenAmount::from_atto(100),
action(TestAction::Transfer(bob, action(TestAction::Accept))),
);
assert!(ret_val.msg_receipt.exit_code.is_success());
let balance = tester.get_balance(operator[0].1, token_actor, alice);
assert_eq!(balance, TokenAmount::from_atto(0));
let balance = tester.get_balance(operator[0].1, token_actor, bob);
assert_eq!(balance, TokenAmount::from_atto(200));

// TEST: mint to alice who transfers to bob inside receiver hook, bob rejects
let ret_val = tester.mint_tokens(
operator[0].1,
token_actor,
alice,
TokenAmount::from_atto(100),
action(TestAction::Transfer(bob, action(TestAction::Reject))),
);
// mint succeeds but the transfer inside the receiver hook would have failed
assert!(ret_val.msg_receipt.exit_code.is_success());
// alice should keep tokens in this case
let balance = tester.get_balance(operator[0].1, token_actor, alice);
assert_eq!(balance, TokenAmount::from_atto(100));
// bob's balance should remain unchanged'
let balance = tester.get_balance(operator[0].1, token_actor, bob);
assert_eq!(balance, TokenAmount::from_atto(200));


}

0 comments on commit d0edd2f

Please sign in to comment.