Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
bitdivine committed Sep 10, 2024
1 parent b64b9ca commit b2a7a7b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/example/paid_service/tests/it/icrc2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ fn patron_pays_by_named_icrc2() {
// In this test, we will exercise the ICRC-2 approve.
let api_method = "cost_1b";
let api_fee = 1_000_000_000u128;
let repetitions = 3;
// Pre-approve payment
for caller in setup.users[2..].iter() {
setup
Expand All @@ -449,7 +450,7 @@ fn patron_pays_by_named_icrc2() {
owner: setup.paid_service.canister_id(),
subaccount: Some(principal2account(caller)),
},
amount: Nat::from(expected_user_balance),
amount: Nat::from((api_fee + LEDGER_FEE) * repetitions),
..ApproveArgs::default()
},
)
Expand All @@ -463,7 +464,7 @@ fn patron_pays_by_named_icrc2() {
);
}
// Now make several identical API calls
for _repetition in 0..5 {
for repetition in 0..repetitions {
// Check the balance beforehand
let service_canister_cycles_before =
setup.pic.cycle_balance(setup.paid_service.canister_id);
Expand All @@ -477,7 +478,8 @@ fn patron_pays_by_named_icrc2() {
assert_eq!(
response,
Ok("Yes, you paid 1 billion cycles!".to_string()),
"Should have succeeded with a generous prepayment",
"Should have succeeded for user {} on repetition {repetition}",
caller.to_string(),
);
let service_canister_cycles_after =
setup.pic.cycle_balance(setup.paid_service.canister_id);
Expand Down

0 comments on commit b2a7a7b

Please sign in to comment.