mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 09:17:58 +00:00
pallet-uniques: decrement total_deposit when clearing collection metadata (#3976)
Decrements `total_deposit` when collection metadata is cleared in `pallet-nfts` and `pallet-uniques`.
This commit is contained in:
@@ -1062,3 +1062,41 @@ fn buy_item_should_work() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clear_collection_metadata_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Start with an account with 100 balance, 10 of which are reserved
|
||||
Balances::make_free_balance_be(&1, 100);
|
||||
Balances::reserve(&1, 10).unwrap();
|
||||
|
||||
// Create a Unique which increases total_deposit by 2
|
||||
assert_ok!(Uniques::create(RuntimeOrigin::signed(1), 0, 123));
|
||||
assert_eq!(Collection::<Test>::get(0).unwrap().total_deposit, 2);
|
||||
assert_eq!(Balances::reserved_balance(&1), 12);
|
||||
|
||||
// Set collection metadata which increases total_deposit by 10
|
||||
assert_ok!(Uniques::set_collection_metadata(
|
||||
RuntimeOrigin::signed(1),
|
||||
0,
|
||||
bvec![0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
false
|
||||
));
|
||||
assert_eq!(Collection::<Test>::get(0).unwrap().total_deposit, 12);
|
||||
assert_eq!(Balances::reserved_balance(&1), 22);
|
||||
|
||||
// Clearing collection metadata reduces total_deposit by the expected amount
|
||||
assert_ok!(Uniques::clear_collection_metadata(RuntimeOrigin::signed(1), 0));
|
||||
assert_eq!(Collection::<Test>::get(0).unwrap().total_deposit, 2);
|
||||
assert_eq!(Balances::reserved_balance(&1), 12);
|
||||
|
||||
// Destroying the collection removes it from storage
|
||||
assert_ok!(Uniques::destroy(
|
||||
RuntimeOrigin::signed(1),
|
||||
0,
|
||||
DestroyWitness { items: 0, item_metadatas: 0, attributes: 0 }
|
||||
));
|
||||
assert_eq!(Collection::<Test>::get(0), None);
|
||||
assert_eq!(Balances::reserved_balance(&1), 10);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user