Skip to content

Commit

Permalink
chore: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
chungquantin committed Dec 30, 2024
1 parent 439ad31 commit 40a8bd8
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions pallets/nfts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ use crate::{mock::*, Event, SystemConfig, *};

type AccountBalance = crate::AccountBalance<Test>;
type AccountIdOf<Test> = <Test as frame_system::Config>::AccountId;
type AccountBalance = crate::AccountBalance<Test>;
type CollectionApprovals = crate::CollectionApprovals<Test>;
type CollectionApprovalDeposit = <Test as Config>::CollectionApprovalDeposit;
type CollectionId = <Test as Config>::CollectionId;
Expand Down Expand Up @@ -171,9 +170,8 @@ fn clear_collection_approvals(
limit: u32,
) -> DispatchResultWithPostInfo {
match maybe_owner {
Some(owner) => {
Nfts::force_clear_collection_approvals(origin, owner.clone(), collection, limit)
},
Some(owner) =>
Nfts::force_clear_collection_approvals(origin, owner.clone(), collection, limit),
None => Nfts::clear_collection_approvals(origin, collection, limit),
}
}
Expand All @@ -193,9 +191,8 @@ fn approve_collection_transfer(
delegate.clone(),
maybe_deadline,
),
None => {
Nfts::approve_collection_transfer(origin, collection, delegate.clone(), maybe_deadline)
},
None =>
Nfts::approve_collection_transfer(origin, collection, delegate.clone(), maybe_deadline),
}
}

Expand Down Expand Up @@ -3265,9 +3262,9 @@ fn collection_locking_should_work() {

let stored_config = CollectionConfigOf::<Test>::get(collection_id).unwrap();
let full_lock_config = collection_config_from_disabled_settings(
CollectionSetting::TransferableItems
| CollectionSetting::UnlockedMetadata
| CollectionSetting::UnlockedAttributes,
CollectionSetting::TransferableItems |
CollectionSetting::UnlockedMetadata |
CollectionSetting::UnlockedAttributes,
);
assert_eq!(stored_config, full_lock_config);
});
Expand Down Expand Up @@ -4879,11 +4876,13 @@ fn mint_should_update_account_balance_works() {
new_test_ext().execute_with(|| {
let collection_id = 0;
let owner = account(1);
let balance_deposit = balance_deposit();

Balances::make_free_balance_be(&owner, 100);
assert_ok!(Nfts::force_create(
RuntimeOrigin::root(),
owner.clone(),
default_collection_config()
collection_config_with_all_settings_enabled()
));

assert_ok!(Nfts::mint(
Expand All @@ -4893,7 +4892,10 @@ fn mint_should_update_account_balance_works() {
owner.clone(),
None
));
assert_eq!(AccountBalance::get(collection_id, &owner), 1);
assert_eq!(
AccountBalance::get(collection_id, &owner),
Some((1, (owner.clone(), balance_deposit)))
);

// Additive.
assert_ok!(Nfts::mint(
Expand All @@ -4903,17 +4905,23 @@ fn mint_should_update_account_balance_works() {
owner.clone(),
None
));
assert_eq!(AccountBalance::get(collection_id, &owner), 2);
assert_eq!(
AccountBalance::get(collection_id, &owner),
Some((2, (owner.clone(), balance_deposit)))
);

// Mint with witness data.
assert_ok!(Nfts::mint(
RuntimeOrigin::signed(account(1)),
RuntimeOrigin::signed(owner.clone()),
collection_id,
44,
account(2),
Some(MintWitness { mint_price: Some(1), ..Default::default() })
));
assert_eq!(AccountBalance::get(collection_id, account(2)), 1);
assert_eq!(
AccountBalance::get(collection_id, account(2)),
Some((1, (owner, balance_deposit)))
);
});
}

Expand Down Expand Up @@ -4945,7 +4953,10 @@ fn burn_should_update_account_balance_works() {
));

assert_ok!(Nfts::burn(RuntimeOrigin::signed(owner.clone()), collection_id, 42));
assert_eq!(AccountBalance::get(collection_id, &owner), 1);
assert_eq!(
AccountBalance::get(collection_id, &owner),
Some((1, (owner.clone(), balance_deposit())))
);

assert_ok!(Nfts::burn(RuntimeOrigin::signed(owner.clone()), collection_id, 43));
assert!(!AccountBalance::contains_key(collection_id, &owner));
Expand Down Expand Up @@ -4979,7 +4990,7 @@ fn transfer_should_update_account_balance_works() {
dest.clone()
));
assert!(!AccountBalance::contains_key(collection_id, &owner));
assert_eq!(AccountBalance::get(collection_id, &dest), 1);
assert_eq!(AccountBalance::get(collection_id, &dest), Some((1, (owner.clone(), 0))));

assert_ok!(Nfts::approve_transfer(
RuntimeOrigin::signed(dest.clone()),
Expand All @@ -4995,7 +5006,7 @@ fn transfer_should_update_account_balance_works() {
account(4)
));
assert!(!AccountBalance::contains_key(collection_id, &dest));
assert_eq!(AccountBalance::get(collection_id, account(4)), 1);
assert_eq!(AccountBalance::get(collection_id, account(4)), Some((1, (owner, 0))));
});
}

Expand Down Expand Up @@ -5053,8 +5064,8 @@ fn claim_swap_should_update_account_balance_works() {
item_1,
Some(price_with_direction),
));
assert_eq!(AccountBalance::get(collection_id, &user_1), 1);
assert_eq!(AccountBalance::get(collection_id, &user_2), 1);
assert_eq!(AccountBalance::get(collection_id, &user_1), Some((1, (user_1, 0))));
assert_eq!(AccountBalance::get(collection_id, &user_2), Some((1, (user_2, 0))));
});
}

Expand Down Expand Up @@ -5099,8 +5110,8 @@ fn buy_item_should_update_account_balance_works() {
item_1,
price_1 + 1,
));
assert_eq!(AccountBalance::get(collection_id, &user_1), 0);
assert_eq!(AccountBalance::get(collection_id, &user_2), 1);
assert!(!AccountBalance::contains_key(collection_id, &user_1));
assert_eq!(AccountBalance::get(collection_id, &user_2), Some((1, (user_2, 0))));
});
}

Expand Down

0 comments on commit 40a8bd8

Please sign in to comment.