Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
bitdivine committed Sep 9, 2024
1 parent bb0049b commit dc892ff
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/example/paid_service/tests/it/icrc2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ fn icrc2_payment_works() {
)
.expect("Failed to call the ledger to approve")
.expect("Failed to approve the paid service to spend the user's ICRC-2 tokens");
// Check the balance beforehand
// Check that the user has been charged for the approve.
expected_user_balance -= LEDGER_FEE;
setup.assert_user_balance_eq(expected_user_balance, "Expected the user balance to be charged for the ICRC2 approve".to_string());

// Check the balance beforehand
let service_canister_cycles_before =
setup.pic.cycle_balance(setup.paid_service.canister_id);
// Call the API
Expand All @@ -184,6 +188,7 @@ fn icrc2_payment_works() {
"Should have failed with only {} cycles attached",
payment
);
setup.assert_user_balance_eq(expected_user_balance, "Expected the user balance to be unchanged by a failed ICRC2".to_string());
} else {
assert_eq!(
response,
Expand All @@ -199,7 +204,7 @@ fn icrc2_payment_works() {
service_canister_cycles_before - service_canister_cycles_after
);
expected_user_balance -= api_fee + LEDGER_FEE;
setup.assert_user_balance_eq(expected_balance, "Expected the user balance to be the initial balance minus the fee".to_string());
setup.assert_user_balance_eq(expected_user_balance, "Expected the user balance to be the initial balance minus the ledger and API fees".to_string());
}
}
}

0 comments on commit dc892ff

Please sign in to comment.