[NFTs] Fix consumers issue (#2653)

When we call the `set_accept_ownership` method, we increase the number
of account consumers, but then we don't decrease it on collection
transfer, which leads to the wrong consumers number an account has.
This commit is contained in:
Jegor Sidorenko
2023-12-19 15:23:58 +02:00
committed by GitHub
parent 0b74812ce8
commit 166ae5ae12
5 changed files with 33 additions and 21 deletions
+5
View File
@@ -614,8 +614,13 @@ fn transfer_owner_should_work() {
Nfts::transfer_ownership(RuntimeOrigin::signed(account(1)), 0, account(2)),
Error::<Test>::Unaccepted
);
assert_eq!(System::consumers(&account(2)), 0);
assert_ok!(Nfts::set_accept_ownership(RuntimeOrigin::signed(account(2)), Some(0)));
assert_eq!(System::consumers(&account(2)), 1);
assert_ok!(Nfts::transfer_ownership(RuntimeOrigin::signed(account(1)), 0, account(2)));
assert_eq!(System::consumers(&account(2)), 1); // one consumer is added due to deposit repatriation
assert_eq!(collections(), vec![(account(2), 0)]);
assert_eq!(Balances::total_balance(&account(1)), 98);