Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chungquantin committed Dec 31, 2024
1 parent d3b3141 commit 7820d79
Showing 1 changed file with 38 additions and 15 deletions.
53 changes: 38 additions & 15 deletions pallets/nfts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5031,9 +5031,6 @@ fn destroy_with_collection_approvals_returns_error() {
});
}

#[test]
fn burn_removes_deposit_works() {}

#[test]
fn mint_requires_deposit_works() {
new_test_ext().execute_with(|| {
Expand All @@ -5049,18 +5046,6 @@ fn mint_requires_deposit_works() {
collection_config_with_all_settings_enabled()
));

// Throws error `BalancesError::InsufficientBalance`.
assert_noop!(
Nfts::mint(
RuntimeOrigin::signed(collection_owner.clone()),
collection_id,
item_id,
item_owner.clone(),
None
),
BalancesError::<Test>::InsufficientBalance
);

Balances::make_free_balance_be(&collection_owner, 100);
// Minting reserves deposit from the collection owner.
{
Expand Down Expand Up @@ -5102,6 +5087,44 @@ fn mint_requires_deposit_works() {
});
}

#[test]
fn burn_removes_deposit_works() {
new_test_ext().execute_with(|| {
let collection_id = 0;
let owner = account(1);

assert_ok!(Nfts::force_create(
RuntimeOrigin::root(),
owner.clone(),
collection_config_with_all_settings_enabled()
));

Balances::make_free_balance_be(&owner, 100);
assert_ok!(Nfts::mint(
RuntimeOrigin::signed(owner.clone()),
collection_id,
42,
owner.clone(),
None
));
assert_ok!(Nfts::mint(
RuntimeOrigin::signed(owner.clone()),
collection_id,
43,
owner.clone(),
None
));

assert_ok!(Nfts::burn(RuntimeOrigin::signed(owner.clone()), collection_id, 42));
assert_eq!(Balances::reserved_balance(&owner), 1 + balance_deposit());
assert_eq!(items(), vec![(owner.clone(), 0, 43)]);

assert_ok!(Nfts::burn(RuntimeOrigin::signed(owner.clone()), collection_id, 43));
assert_eq!(Balances::reserved_balance(&owner), 0);
assert_eq!(items(), vec![]);
});
}

#[test]
fn transfer_requires_deposit_works() {
new_test_ext().execute_with(|| {
Expand Down

0 comments on commit 7820d79

Please sign in to comment.