Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
chungquantin committed Nov 26, 2024
1 parent 5212a5a commit 32ec720
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions pallets/nfts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2383,14 +2383,20 @@ fn clear_all_transfer_approvals_works() {
));

assert_noop!(
Nfts::clear_all_transfer_approvals(RuntimeOrigin::signed(account(3)), 0, Some(42)),
Nfts::clear_all_transfer_approvals(
RuntimeOrigin::signed(account(3)),
0,
Some(42),
ClearAllApprovalsWitness { allowances: 0 }
),
Error::<Test>::NoPermission
);

assert_ok!(Nfts::clear_all_transfer_approvals(
RuntimeOrigin::signed(account(2)),
0,
Some(42)
Some(42),
ClearAllApprovalsWitness { allowances: 0 }
));

assert!(events().contains(&Event::<Test>::AllApprovalsCancelled {
Expand Down Expand Up @@ -2443,17 +2449,38 @@ fn clear_all_collection_approvals_works() {
));

assert_noop!(
Nfts::clear_all_transfer_approvals(RuntimeOrigin::signed(account(2)), 0, None),
Nfts::clear_all_transfer_approvals(
RuntimeOrigin::signed(account(2)),
0,
None,
ClearAllApprovalsWitness { allowances: 2 }
),
Error::<Test>::NoPermission
);

assert_ok!(Nfts::clear_all_transfer_approvals(RuntimeOrigin::signed(account(1)), 0, None));
assert_noop!(
Nfts::clear_all_transfer_approvals(
RuntimeOrigin::signed(account(1)),
0,
None,
ClearAllApprovalsWitness { allowances: 1 }
),
Error::<Test>::BadWitness
);

assert_ok!(Nfts::clear_all_transfer_approvals(
RuntimeOrigin::signed(account(1)),
0,
None,
ClearAllApprovalsWitness { allowances: 2 }
));
assert!(events().contains(&Event::<Test>::AllApprovalsCancelled {
collection: 0,
item: None,
owner: account(1),
}));
assert_eq!(Allowances::<Test>::iter_prefix((0, account(1))).count(), 0);
assert_eq!(AccountAllowances::<Test>::get(0, account(1)), 0);

assert_noop!(
Nfts::transfer(RuntimeOrigin::signed(account(3)), 0, 42, account(5)),
Expand Down

0 comments on commit 32ec720

Please sign in to comment.