difftreelog
fix merge test changes
in: master
7 files changed
pallets/inflation/src/tests.rsdiffbeforeafterboth--- a/pallets/inflation/src/tests.rs
+++ b/pallets/inflation/src/tests.rs
@@ -34,9 +34,9 @@
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
- Balances: pallet_balances::{Module, Call, Storage},
- System: frame_system::{Module, Call, Config, Storage, Event<T>},
- Inflation: pallet_inflation::{Module, Call, Storage},
+ Balances: pallet_balances::{Pallet, Call, Storage},
+ System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
+ Inflation: pallet_inflation::{Pallet, Call, Storage},
}
);
@@ -70,6 +70,7 @@
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
+ type OnSetCode = ();
}
parameter_types! {
pallets/nft/src/eth/sponsoring.rsdiffbeforeafterboth--- a/pallets/nft/src/eth/sponsoring.rs
+++ b/pallets/nft/src/eth/sponsoring.rs
@@ -32,7 +32,7 @@
match call {
UniqueNFTCall::ERC721UniqueExtensions(ERC721UniqueExtensionsCall::Transfer {token_id, ..}) | UniqueNFTCall::ERC721(ERC721Call::TransferFrom {token_id, ..}) => {
let token_id: u32 = token_id.try_into().map_err(|_| AnyError)?;
- let block_number = <frame_system::Module<T>>::block_number() as T::BlockNumber;
+ let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
let collection_limits = &collection.limits;
let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
collection_limits.sponsor_transfer_timeout
@@ -68,7 +68,7 @@
ChainLimit::get().fungible_sponsor_transfer_timeout
};
- let block_number = <frame_system::Module<T>>::block_number() as T::BlockNumber;
+ let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
let mut sponsored = true;
if <FungibleTransferBasket<T>>::contains_key(collection_id, who.as_sub()) {
let last_tx_block = <FungibleTransferBasket<T>>::get(collection_id, who.as_sub());
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -236,7 +236,6 @@
type EvmAddressMapping: pallet_evm::AddressMapping<Self::AccountId>;
type EvmBackwardsAddressMapping: EvmBackwardsAddressMapping<Self::AccountId>;
- type EvmWithdrawOrigin: pallet_evm::EnsureAddressOrigin<Self::Origin, Success = Self::AccountId>;
type CrossAccountId: CrossAccountId<Self::AccountId>;
type Currency: Currency<Self::AccountId>;
pallets/nft/src/mock.rsdiffbeforeafterboth--- a/pallets/nft/src/mock.rs
+++ b/pallets/nft/src/mock.rs
@@ -11,6 +11,9 @@
};
use pallet_transaction_payment::{ CurrencyAdapter};
use frame_system as system;
+use pallet_evm::AddressMapping;
+use crate::{EvmBackwardsAddressMapping, CrossAccountId};
+use codec::{Encode, Decode};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
@@ -22,9 +25,9 @@
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
- System: frame_system::{Module, Call, Config, Storage, Event<T>},
- TemplateModule: pallet_template::{Module, Call, Storage},
- Balances: pallet_balances::{Module, Call, Storage},
+ System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
+ TemplateModule: pallet_template::{Pallet, Call, Storage},
+ Balances: pallet_balances::{Pallet, Call, Storage},
}
);
@@ -56,6 +59,7 @@
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
+ type OnSetCode = ();
}
parameter_types! {
@@ -78,7 +82,7 @@
}
impl pallet_transaction_payment::Config for Test {
- type OnChargeTransaction = CurrencyAdapter<pallet_balances::Module<Test>, ()>;
+ type OnChargeTransaction = CurrencyAdapter<pallet_balances::Pallet<Test>, ()>;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<u64>;
type FeeMultiplierUpdate = ();
@@ -94,27 +98,26 @@
type WeightInfo = ();
}
-type Timestamp = pallet_timestamp::Module<Test>;
-type Randomness = pallet_randomness_collective_flip::Module<Test>;
+type Timestamp = pallet_timestamp::Pallet<Test>;
+type Randomness = pallet_randomness_collective_flip::Pallet<Test>;
parameter_types! {
pub const TombstoneDeposit: u64 = 1;
pub const DepositPerContract: u64 = 1;
pub const DepositPerStorageByte: u64 = 1;
pub const DepositPerStorageItem: u64 = 1;
- pub RentFraction: Perbill = Perbill::from_rational_approximation(1u32, 30 * 24 * 60 * 10);
+ pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * 24 * 60 * 10);
pub const SurchargeReward: u64 = 1;
pub const SignedClaimHandicap: u32 = 2;
- pub const MaxDepth: u32 = 32;
- pub const MaxValueSize: u32 = 16 * 1024;
pub DeletionWeightLimit: u64 = u64::MAX;//Perbill::from_percent(10);
pub DeletionQueueDepth: u32 = 10;
+ pub Schedule: pallet_contracts::Schedule<Test> = Default::default();
}
impl pallet_contracts::Config for Test {
type Time = Timestamp;
type Randomness = Randomness;
- type Currency = pallet_balances::Module<Test>;
+ type Currency = pallet_balances::Pallet<Test>;
type Event = ();
type RentPayment = ();
type SignedClaimHandicap = SignedClaimHandicap;
@@ -125,26 +128,71 @@
type RentFraction = RentFraction;
type SurchargeReward = SurchargeReward;
type DeletionWeightLimit = DeletionWeightLimit;
- type MaxDepth = MaxDepth;
type DeletionQueueDepth = DeletionQueueDepth;
- type MaxValueSize = MaxValueSize;
type ChainExtension = ();
- type MaxCodeSize = ();
type WeightPrice = ();
type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
+ type Schedule = Schedule;
+ type CallStack = [pallet_contracts::Frame<Self>; 31];
}
parameter_types! {
pub const CollectionCreationPrice: u32 = 0;
pub TreasuryAccountId: u64 = 1234;
+ pub EthereumChainId: u32 = 1111;
+}
+
+pub struct TestEvmAddressMapping;
+impl AddressMapping<u64> for TestEvmAddressMapping {
+ fn into_account_id(addr: sp_core::H160) -> u64 {
+ unimplemented!()
+ }
+}
+
+pub struct TestEvmBackwardsAddressMapping;
+impl EvmBackwardsAddressMapping<u64> for TestEvmBackwardsAddressMapping {
+ fn from_account_id(account_id: u64) -> sp_core::H160 {
+ unimplemented!()
+ }
+}
+
+#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
+pub struct TestCrossAccountId(u64, sp_core::H160);
+impl CrossAccountId<u64> for TestCrossAccountId {
+ fn from_sub(sub: u64) -> Self {
+ let mut eth = [0; 20];
+ eth[12..20].copy_from_slice(&sub.to_be_bytes());
+ Self(sub, sp_core::H160(eth))
+ }
+ fn as_sub(&self) -> &u64 {
+ &self.0
+ }
+ fn from_eth(eth: sp_core::H160) -> Self {
+ unimplemented!()
+ }
+ fn as_eth(&self) -> &sp_core::H160 {
+ &self.1
+ }
}
+pub struct TestEtheremTransactionSender;
+impl pallet_ethereum::EthereumTransactionSender for TestEtheremTransactionSender {
+ fn submit_logs_transaction(tx: pallet_ethereum::Transaction, logs: Vec<pallet_ethereum::Log>) -> Result<(), sp_runtime::DispatchError> {
+ Ok(())
+ }
+}
+
impl pallet_template::Config for Test {
type Event = ();
type WeightInfo = ();
type CollectionCreationPrice = CollectionCreationPrice;
- type Currency = pallet_balances::Module<Test>;
+ type Currency = pallet_balances::Pallet<Test>;
type TreasuryAccountId = TreasuryAccountId;
+ type EvmAddressMapping = TestEvmAddressMapping;
+ type EvmBackwardsAddressMapping = TestEvmBackwardsAddressMapping;
+ type CrossAccountId = TestCrossAccountId;
+ type EthereumChainId = EthereumChainId;
+ type EthereumTransactionSender = TestEtheremTransactionSender;
}
// Build genesis storage according to the mock runtime.
pallets/nft/src/tests.rsdiffbeforeafterboth1// Tests to be written here2use super::*;3use crate::mock::*;4use crate::{5 AccessMode, CollectionMode,6 Ownership, ChainLimits, CreateItemData,7};8use nft_data_structs::{9 CreateNftData, CreateFungibleData, CreateReFungibleData,10 CollectionId, TokenId, MAX_DECIMAL_POINTS,11};12use frame_support::{assert_noop, assert_ok};13use frame_system::{ RawOrigin };1415fn default_collection_numbers_limit() -> u32 {16 1017}1819fn default_limits() {20 assert_ok!(TemplateModule::set_chain_limits(RawOrigin::Root.into(), ChainLimits {21 collection_numbers_limit: default_collection_numbers_limit(),22 account_token_ownership_limit: 10,23 collections_admins_limit: 5,24 custom_data_limit: 2048,25 nft_sponsor_transfer_timeout: 15,26 fungible_sponsor_transfer_timeout: 15,27 refungible_sponsor_transfer_timeout: 15,28 const_on_chain_schema_limit: 1024,29 offchain_schema_limit: 1024,30 variable_on_chain_schema_limit: 1024,31 }));32}3334fn default_nft_data() -> CreateNftData {35 CreateNftData { const_data: vec![1, 2, 3], variable_data: vec![3, 2, 1] }36}3738fn default_fungible_data () -> CreateFungibleData {39 CreateFungibleData { value: 5 }40}4142fn default_re_fungible_data () -> CreateReFungibleData {43 CreateReFungibleData { const_data: vec![1, 2, 3], variable_data: vec![3, 2, 1], pieces: 1023 }44}4546fn create_test_collection_for_owner(mode: &CollectionMode, owner: u64, id: CollectionId) -> CollectionId {47 let col_name1: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();48 let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();49 let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();5051 let origin1 = Origin::signed(owner);52 assert_ok!(TemplateModule::create_collection(53 origin1.clone(),54 col_name1.clone(),55 col_desc1.clone(),56 token_prefix1.clone(),57 mode.clone()58 ));5960 let saved_col_name: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();61 let saved_description: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();62 let saved_prefix: Vec<u8> = b"token_prefix1\0".to_vec();63 assert_eq!(TemplateModule::collection_id(id).unwrap().owner, owner);64 assert_eq!(TemplateModule::collection_id(id).unwrap().name, saved_col_name);65 assert_eq!(TemplateModule::collection_id(id).unwrap().mode, *mode);66 assert_eq!(TemplateModule::collection_id(id).unwrap().description, saved_description);67 assert_eq!(TemplateModule::collection_id(id).unwrap().token_prefix, saved_prefix);68 id69}7071fn create_test_collection(mode: &CollectionMode, id: CollectionId) -> CollectionId {72 create_test_collection_for_owner(&mode, 1, id)73}7475fn create_test_item(collection_id: CollectionId, data: &CreateItemData) {76 let origin1 = Origin::signed(1);77 assert_ok!(TemplateModule::create_item(78 origin1.clone(),79 collection_id,80 account(1),81 data.clone()82 ));8384}8586fn account(sub: u64) -> TestCrossAccountId {87 TestCrossAccountId::from_sub(sub)88}8990// Use cases tests region91// #region9293#[test]94fn set_version_schema() {95 new_test_ext().execute_with(|| {96 default_limits();97 let origin1 = Origin::signed(1);98 let collection_id = create_test_collection(&CollectionMode::NFT, 1);99 100 assert_ok!(TemplateModule::set_schema_version(origin1, collection_id, SchemaVersion::Unique));101 assert_eq!(TemplateModule::collection_id(collection_id).unwrap().schema_version, SchemaVersion::Unique);102 });103}104105#[test]106fn create_fungible_collection_fails_with_large_decimal_numbers() {107 new_test_ext().execute_with(|| {108 default_limits();109110 let col_name1: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();111 let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();112 let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();113114 let origin1 = Origin::signed(1);115 assert_noop!(TemplateModule::create_collection(116 origin1,117 col_name1,118 col_desc1,119 token_prefix1,120 CollectionMode::Fungible(MAX_DECIMAL_POINTS + 1)121 ), Error::<Test>::CollectionDecimalPointLimitExceeded);122 }); 123}124125#[test]126fn create_nft_item() {127 new_test_ext().execute_with(|| {128 default_limits();129 let collection_id = create_test_collection(&CollectionMode::NFT, 1);130 131 let data = default_nft_data();132 create_test_item(collection_id, &data.clone().into());133 let item = TemplateModule::nft_item_id(collection_id, 1).unwrap();134 assert_eq!(item.const_data, data.const_data);135 assert_eq!(item.variable_data, data.variable_data);136 });137}138139// Use cases tests region140// #region141#[test]142fn create_nft_multiple_items() {143 new_test_ext().execute_with(|| {144 default_limits();145 146 create_test_collection(&CollectionMode::NFT, 1);147148 let origin1 = Origin::signed(1);149150 let items_data = vec![default_nft_data(), default_nft_data(), default_nft_data()];151152 assert_ok!(TemplateModule::create_multiple_items(153 origin1.clone(),154 1,155 account(1),156 items_data.clone().into_iter().map(|d| { d.into() }).collect()157 ));158 for (index, data) in items_data.iter().enumerate() {159 let item = TemplateModule::nft_item_id(1, (index + 1) as TokenId).unwrap(); 160 assert_eq!(item.const_data.to_vec(), data.const_data);161 assert_eq!(item.variable_data.to_vec(), data.variable_data);162 }163 });164}165166#[test]167fn create_refungible_item() {168 new_test_ext().execute_with(|| {169 default_limits();170 let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);171172 let data = default_re_fungible_data();173 create_test_item(collection_id, &data.clone().into());174 let item = TemplateModule::refungible_item_id(collection_id, 1).unwrap();175 assert_eq!(176 item.const_data,177 data.const_data178 );179 assert_eq!(180 item.variable_data,181 data.variable_data182 );183 assert_eq!(184 item.owner[0],185 Ownership {186 owner: account(1),187 fraction: 1023188 }189 );190 });191}192193#[test]194fn create_multiple_refungible_items() {195 new_test_ext().execute_with(|| {196 default_limits();197 198 create_test_collection(&CollectionMode::ReFungible, 1);199200 let origin1 = Origin::signed(1);201202 let items_data = vec![default_re_fungible_data(), default_re_fungible_data(), default_re_fungible_data()];203204 assert_ok!(TemplateModule::create_multiple_items(205 origin1.clone(),206 1,207 account(1),208 items_data.clone().into_iter().map(|d| { d.into() }).collect()209 ));210 for (index, data) in items_data.iter().enumerate() {211212 let item = TemplateModule::refungible_item_id(1, (index + 1) as TokenId).unwrap();213 assert_eq!(item.const_data.to_vec(), data.const_data);214 assert_eq!(item.variable_data.to_vec(), data.variable_data);215 assert_eq!(216 item.owner[0],217 Ownership {218 owner: account(1),219 fraction: 1023220 }221 );222 }223 });224}225226#[test]227fn create_fungible_item() {228 new_test_ext().execute_with(|| {229 default_limits();230 231 let collection_id = create_test_collection(&CollectionMode::Fungible(3), 1);232233 let data = default_fungible_data();234 create_test_item(collection_id, &data.into());235236 assert_eq!(TemplateModule::fungible_item_id(collection_id, 1).value, 5);237 });238}239240//#[test]241// fn create_multiple_fungible_items() {242// new_test_ext().execute_with(|| {243// default_limits();244245// create_test_collection(&CollectionMode::Fungible(3), 1);246247// let origin1 = Origin::signed(1);248249// let items_data = vec![default_fungible_data(), default_fungible_data(), default_fungible_data()];250251// assert_ok!(TemplateModule::create_multiple_items(252// origin1.clone(),253// 1,254// 1,255// items_data.clone().into_iter().map(|d| { d.into() }).collect()256// ));257 258// for (index, _) in items_data.iter().enumerate() {259// assert_eq!(TemplateModule::fungible_item_id(1, (index + 1) as TokenId).value, 5);260// }261// assert_eq!(TemplateModule::balance_count(1, 1), 3000);262// assert_eq!(TemplateModule::address_tokens(1, 1), [1, 2, 3]);263// });264// }265266#[test]267fn transfer_fungible_item() {268 new_test_ext().execute_with(|| {269 default_limits();270 271 let collection_id = create_test_collection(&CollectionMode::Fungible(3), 1);272273 let origin1 = Origin::signed(1);274 let origin2 = Origin::signed(2);275276 let data = default_fungible_data();277 create_test_item(collection_id, &data.into());278279 assert_eq!(TemplateModule::fungible_item_id(1, 1).value, 5);280 assert_eq!(TemplateModule::balance_count(1, 1), 5);281282 // change owner scenario283 assert_ok!(TemplateModule::transfer(origin1.clone(), account(2), 1, 1, 5));284 assert_eq!(TemplateModule::fungible_item_id(1, 1).value, 0);285 assert_eq!(TemplateModule::balance_count(1, 1), 0);286 assert_eq!(TemplateModule::balance_count(1, 2), 5);287288 // split item scenario289 assert_ok!(TemplateModule::transfer(origin2.clone(), account(3), 1, 1, 3));290 assert_eq!(TemplateModule::balance_count(1, 2), 2);291 assert_eq!(TemplateModule::balance_count(1, 3), 3);292293 // split item and new owner has account scenario294 assert_ok!(TemplateModule::transfer(origin2.clone(), account(3), 1, 1, 1));295 assert_eq!(TemplateModule::fungible_item_id(1, 2).value, 1);296 assert_eq!(TemplateModule::fungible_item_id(1, 3).value, 4);297 assert_eq!(TemplateModule::balance_count(1, 2), 1);298 assert_eq!(TemplateModule::balance_count(1, 3), 4);299 });300}301302#[test]303fn transfer_refungible_item() {304 new_test_ext().execute_with(|| {305 default_limits();306 307 let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);308309 let data = default_re_fungible_data();310 create_test_item(collection_id, &data.clone().into());311312 let origin1 = Origin::signed(1);313 let origin2 = Origin::signed(2);314 {315 let item = TemplateModule::refungible_item_id(collection_id, 1).unwrap();316 assert_eq!(317 item.const_data,318 data.const_data319 );320 assert_eq!(321 item.variable_data,322 data.variable_data323 );324 assert_eq!(325 item.owner[0],326 Ownership {327 owner: account(1),328 fraction: 1023329 }330 );331 }332 assert_eq!(TemplateModule::balance_count(1, 1), 1023);333 assert_eq!(TemplateModule::address_tokens(1, 1), [1]);334335 // change owner scenario336 assert_ok!(TemplateModule::transfer(origin1.clone(), account(2), 1, 1, 1023));337 assert_eq!(338 TemplateModule::refungible_item_id(1, 1).unwrap().owner[0],339 Ownership {340 owner: account(2),341 fraction: 1023342 }343 );344 assert_eq!(TemplateModule::balance_count(1, 1), 0);345 assert_eq!(TemplateModule::balance_count(1, 2), 1023);346 // assert_eq!(TemplateModule::address_tokens(1, 1), []);347 assert_eq!(TemplateModule::address_tokens(1, 2), [1]);348349 // split item scenario350 assert_ok!(TemplateModule::transfer(origin2.clone(), account(3), 1, 1, 500));351 {352 let item = TemplateModule::refungible_item_id(1, 1).unwrap();353 assert_eq!(354 item.owner[0],355 Ownership {356 owner: account(2),357 fraction: 523358 }359 );360 assert_eq!(361 item.owner[1],362 Ownership {363 owner: account(3),364 fraction: 500365 }366 );367 }368 assert_eq!(TemplateModule::balance_count(1, 2), 523);369 assert_eq!(TemplateModule::balance_count(1, 3), 500);370 assert_eq!(TemplateModule::address_tokens(1, 2), [1]);371 assert_eq!(TemplateModule::address_tokens(1, 3), [1]);372373 // split item and new owner has account scenario374 assert_ok!(TemplateModule::transfer(origin2.clone(), account(3), 1, 1, 200));375 {376 let item = TemplateModule::refungible_item_id(1, 1).unwrap();377 assert_eq!(378 item.owner[0],379 Ownership {380 owner: account(2),381 fraction: 323382 }383 );384 assert_eq!(385 item.owner[1],386 Ownership {387 owner: account(3),388 fraction: 700389 }390 );391 }392 assert_eq!(TemplateModule::balance_count(1, 2), 323);393 assert_eq!(TemplateModule::balance_count(1, 3), 700);394 assert_eq!(TemplateModule::address_tokens(1, 2), [1]);395 assert_eq!(TemplateModule::address_tokens(1, 3), [1]);396 });397}398399#[test]400fn transfer_nft_item() {401 new_test_ext().execute_with(|| {402 default_limits();403 404 let collection_id = create_test_collection(&CollectionMode::NFT, 1);405406 let data = default_nft_data();407 create_test_item(collection_id, &data.into());408 assert_eq!(TemplateModule::balance_count(1, 1), 1);409 assert_eq!(TemplateModule::address_tokens(1, 1), [1]);410411 let origin1 = Origin::signed(1);412 // default scenario413 assert_ok!(TemplateModule::transfer(origin1.clone(), account(2), 1, 1, 1000));414 assert_eq!(TemplateModule::nft_item_id(1, 1).unwrap().owner, account(2));415 assert_eq!(TemplateModule::balance_count(1, 1), 0);416 assert_eq!(TemplateModule::balance_count(1, 2), 1);417 // assert_eq!(TemplateModule::address_tokens(1, 1), []);418 assert_eq!(TemplateModule::address_tokens(1, 2), [1]);419 });420}421422#[test]423fn nft_approve_and_transfer_from() {424 new_test_ext().execute_with(|| {425 default_limits();426 427 let collection_id = create_test_collection(&CollectionMode::NFT, 1);428429 let data = default_nft_data();430 create_test_item(collection_id, &data.into());431432 let origin1 = Origin::signed(1);433 let origin2 = Origin::signed(2);434435 assert_eq!(TemplateModule::balance_count(1, 1), 1);436 assert_eq!(TemplateModule::address_tokens(1, 1), [1]);437438 // neg transfer439 assert_noop!(TemplateModule::transfer_from(440 origin2.clone(),441 account(1),442 account(2),443 1,444 1,445 1), Error::<Test>::NoPermission);446447 // do approve448 assert_ok!(TemplateModule::approve(origin1.clone(), account(2), 1, 1, 5));449 assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 5);450 assert_eq!(451 TemplateModule::approved(1, (1, 1, 2)),452 5453 );454455 assert_ok!(TemplateModule::transfer_from(456 origin2.clone(),457 account(1),458 account(3),459 1,460 1,461 1462 ));463 assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 4);464 });465}466467#[test]468fn nft_approve_and_transfer_from_white_list() {469 new_test_ext().execute_with(|| {470 default_limits();471 472 let collection_id = create_test_collection(&CollectionMode::NFT, 1);473474 let origin1 = Origin::signed(1);475 let origin2 = Origin::signed(2);476477 let data = default_nft_data();478 create_test_item(collection_id, &data.clone().into());479480 assert_eq!(TemplateModule::nft_item_id(1, 1).unwrap().const_data, data.const_data);481 assert_eq!(TemplateModule::balance_count(1, 1), 1);482 assert_eq!(TemplateModule::address_tokens(1, 1), [1]);483484 assert_ok!(TemplateModule::set_mint_permission(485 origin1.clone(),486 1,487 true488 ));489 assert_ok!(TemplateModule::set_public_access_mode(490 origin1.clone(),491 1,492 AccessMode::WhiteList493 ));494 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));495 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(2)));496 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(3)));497498 // do approve499 assert_ok!(TemplateModule::approve(origin1.clone(), account(2), 1, 1, 5));500 assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 5);501 assert_ok!(TemplateModule::approve(origin1.clone(), account(3), 1, 1, 5));502 assert_eq!(TemplateModule::approved(1, (1, 1, 3)), 5);503504 assert_ok!(TemplateModule::transfer_from(505 origin2.clone(),506 account(1),507 account(3),508 1,509 1,510 1511 ));512 assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 4);513 });514}515516#[test]517fn refungible_approve_and_transfer_from() {518 new_test_ext().execute_with(|| {519 default_limits();520 521 let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);522 523 let origin1 = Origin::signed(1);524 let origin2 = Origin::signed(2);525526 let data = default_re_fungible_data();527 create_test_item(collection_id, &data.into());528529 assert_eq!(TemplateModule::balance_count(1, 1), 1023);530 assert_eq!(TemplateModule::address_tokens(1, 1), [1]);531532 assert_ok!(TemplateModule::set_mint_permission(533 origin1.clone(),534 1,535 true536 ));537 assert_ok!(TemplateModule::set_public_access_mode(538 origin1.clone(),539 1,540 AccessMode::WhiteList541 ));542 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));543 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(2)));544 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(3)));545546 // do approve547 assert_ok!(TemplateModule::approve(origin1.clone(), account(2), 1, 1, 1023));548 assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 1023);549550 assert_ok!(TemplateModule::transfer_from(551 origin2.clone(),552 account(1),553 account(3),554 1,555 1,556 100557 ));558 assert_eq!(TemplateModule::balance_count(1, 1), 923);559 assert_eq!(TemplateModule::balance_count(1, 3), 100);560 assert_eq!(TemplateModule::address_tokens(1, 1), [1]);561 assert_eq!(TemplateModule::address_tokens(1, 3), [1]);562563 assert_eq!(564 TemplateModule::approved(1, (1, 1, 2)),565 923566 );567 });568}569570#[test]571fn fungible_approve_and_transfer_from() {572 new_test_ext().execute_with(|| {573 default_limits();574 575 let collection_id = create_test_collection(&CollectionMode::Fungible(3), 1);576 577 let data = default_fungible_data();578 create_test_item(collection_id, &data.into());579580 let origin1 = Origin::signed(1);581 let origin2 = Origin::signed(2);582583 assert_eq!(TemplateModule::balance_count(1, 1), 5);584585 assert_ok!(TemplateModule::set_mint_permission(586 origin1.clone(),587 1,588 true589 ));590 assert_ok!(TemplateModule::set_public_access_mode(591 origin1.clone(),592 1,593 AccessMode::WhiteList594 ));595 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));596 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(2)));597 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(3)));598599 // do approve600 assert_ok!(TemplateModule::approve(origin1.clone(), account(2), 1, 1, 5));601 assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 5);602 assert_ok!(TemplateModule::approve(origin1.clone(), account(3), 1, 1, 5));603 assert_eq!(TemplateModule::approved(1, (1, 1, 3)), 5);604 assert_eq!(605 TemplateModule::approved(1, (1, 1, 2)),606 5607 );608609 assert_ok!(TemplateModule::transfer_from(610 origin2.clone(),611 account(1),612 account(3),613 1,614 1,615 4616 ));617 assert_eq!(TemplateModule::balance_count(1, 1), 1);618 assert_eq!(TemplateModule::balance_count(1, 3), 4);619620 assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 1);621622 assert_noop!(TemplateModule::transfer_from(623 origin2.clone(),624 account(1),625 account(3),626 1,627 1,628 4629 ), Error::<Test>::NoPermission);630 });631}632633#[test]634fn change_collection_owner() {635 new_test_ext().execute_with(|| {636 default_limits();637 638 let collection_id = create_test_collection(&CollectionMode::NFT, 1);639 640 let origin1 = Origin::signed(1);641 assert_ok!(TemplateModule::change_collection_owner(642 origin1.clone(),643 collection_id,644 2645 ));646 assert_eq!(TemplateModule::collection_id(collection_id).unwrap().owner, 2);647 });648}649650#[test]651fn destroy_collection() {652 new_test_ext().execute_with(|| {653 default_limits();654 655 let collection_id = create_test_collection(&CollectionMode::NFT, 1);656 657 let origin1 = Origin::signed(1);658 assert_ok!(TemplateModule::destroy_collection(origin1.clone(), collection_id));659 });660}661662#[test]663fn burn_nft_item() {664 new_test_ext().execute_with(|| {665 default_limits();666 667 let collection_id = create_test_collection(&CollectionMode::NFT, 1);668669 let origin1 = Origin::signed(1);670 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));671 672 let data = default_nft_data();673 create_test_item(collection_id, &data.into());674675 // check balance (collection with id = 1, user id = 1)676 assert_eq!(TemplateModule::balance_count(1, 1), 1);677678 // burn item679 assert_ok!(TemplateModule::burn_item(origin1.clone(), 1, 1, 5));680 assert_noop!(681 TemplateModule::burn_item(origin1.clone(), 1, 1, 5),682 Error::<Test>::TokenNotFound683 );684685 assert_eq!(TemplateModule::balance_count(1, 1), 0);686 });687}688689#[test]690fn burn_fungible_item() {691 new_test_ext().execute_with(|| {692 default_limits();693 694 let collection_id = create_test_collection(&CollectionMode::Fungible(3), 1);695 696 let origin1 = Origin::signed(1);697 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));698 699 let data = default_fungible_data();700 create_test_item(collection_id, &data.into());701702 // check balance (collection with id = 1, user id = 1)703 assert_eq!(TemplateModule::balance_count(1, 1), 5);704705 // burn item706 assert_ok!(TemplateModule::burn_item(origin1.clone(), 1, 1, 5));707 assert_noop!(708 TemplateModule::burn_item(origin1.clone(), 1, 1, 5),709 Error::<Test>::TokenValueNotEnough710 );711712 assert_eq!(TemplateModule::balance_count(1, 1), 0);713 });714}715716#[test]717fn burn_refungible_item() {718 new_test_ext().execute_with(|| {719 default_limits();720 721 let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);722 let origin1 = Origin::signed(1);723724 assert_ok!(TemplateModule::set_mint_permission(725 origin1.clone(),726 collection_id,727 true728 ));729 assert_ok!(TemplateModule::set_public_access_mode(730 origin1.clone(),731 collection_id,732 AccessMode::WhiteList733 ));734 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));735736 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), 1, account(2)));737 738 let data = default_re_fungible_data();739 create_test_item(collection_id, &data.into());740741 // check balance (collection with id = 1, user id = 2)742 assert_eq!(TemplateModule::balance_count(1, 1), 1023);743744 // burn item745 assert_ok!(TemplateModule::burn_item(origin1.clone(), 1, 1, 1023));746 assert_noop!(747 TemplateModule::burn_item(origin1.clone(), 1, 1, 1023),748 Error::<Test>::TokenNotFound749 );750751 assert_eq!(TemplateModule::balance_count(1, 1), 0);752 });753}754755#[test]756fn add_collection_admin() {757 new_test_ext().execute_with(|| {758 default_limits();759 760 let collection1_id = create_test_collection_for_owner(&CollectionMode::NFT, 1, 1);761 create_test_collection_for_owner(&CollectionMode::NFT, 2, 2);762 create_test_collection_for_owner(&CollectionMode::NFT, 3, 3);763 764 let origin1 = Origin::signed(1);765766 // collection admin767 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection1_id, account(2)));768 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection1_id, account(3)));769770 assert_eq!(TemplateModule::admin_list_collection(collection1_id).contains(&account(2)), true);771 assert_eq!(TemplateModule::admin_list_collection(collection1_id).contains(&account(3)), true);772 });773}774775#[test]776fn remove_collection_admin() {777 new_test_ext().execute_with(|| {778 default_limits();779 780 let collection1_id = create_test_collection_for_owner(&CollectionMode::NFT, 1, 1);781 create_test_collection_for_owner(&CollectionMode::NFT, 2, 2);782 create_test_collection_for_owner(&CollectionMode::NFT, 3, 3);783784 let origin1 = Origin::signed(1);785 let origin2 = Origin::signed(2);786787 // collection admin788 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection1_id, account(2)));789 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection1_id, account(3)));790791 assert_eq!(TemplateModule::admin_list_collection(1).contains(&account(2)), true);792 assert_eq!(TemplateModule::admin_list_collection(1).contains(&account(3)), true);793794 // remove admin795 assert_ok!(TemplateModule::remove_collection_admin(796 origin2.clone(),797 1,798 account(3)799 ));800 assert_eq!(TemplateModule::admin_list_collection(1).contains(&account(3)), false);801 });802}803804#[test]805fn balance_of() {806 new_test_ext().execute_with(|| {807 default_limits();808 809 let nft_collection_id = create_test_collection(&CollectionMode::NFT, 1);810 let fungible_collection_id = create_test_collection(&CollectionMode::Fungible(3), 2);811 let re_fungible_collection_id = create_test_collection(&CollectionMode::ReFungible, 3);812 813 // check balance before814 assert_eq!(TemplateModule::balance_count(nft_collection_id, 1), 0);815 assert_eq!(TemplateModule::balance_count(fungible_collection_id, 1), 0);816 assert_eq!(TemplateModule::balance_count(re_fungible_collection_id, 1), 0);817818 let nft_data = default_nft_data();819 create_test_item(nft_collection_id, &nft_data.into());820 821 let fungible_data = default_fungible_data();822 create_test_item(fungible_collection_id, &fungible_data.into());823 824 let re_fungible_data = default_re_fungible_data();825 create_test_item(re_fungible_collection_id, &re_fungible_data.into());826827 // check balance (collection with id = 1, user id = 1)828 assert_eq!(TemplateModule::balance_count(nft_collection_id, 1), 1);829 assert_eq!(TemplateModule::balance_count(fungible_collection_id, 1), 5);830 assert_eq!(TemplateModule::balance_count(re_fungible_collection_id, 1), 1023);831 assert_eq!(TemplateModule::nft_item_id(nft_collection_id, 1).unwrap().owner, account(1));832 assert_eq!(TemplateModule::fungible_item_id(fungible_collection_id, 1).value, 5);833 assert_eq!(TemplateModule::refungible_item_id(re_fungible_collection_id, 1).unwrap().owner[0].owner, account(1));834 });835}836837#[test]838fn approve() {839 new_test_ext().execute_with(|| {840 default_limits();841 842 let collection_id = create_test_collection(&CollectionMode::NFT, 1);843 844 let data = default_nft_data();845 create_test_item(collection_id, &data.into());846847 let origin1 = Origin::signed(1);848 849 // approve850 assert_ok!(TemplateModule::approve(origin1.clone(), account(2), 1, 1, 1));851 assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 1);852 });853}854855#[test]856fn transfer_from() {857 new_test_ext().execute_with(|| {858 default_limits();859 860 let collection_id = create_test_collection(&CollectionMode::NFT, 1);861 let origin1 = Origin::signed(1);862 let origin2 = Origin::signed(2);863864 let data = default_nft_data();865 create_test_item(collection_id, &data.into());866867 // approve868 assert_ok!(TemplateModule::approve(origin1.clone(), account(2), 1, 1, 1));869 assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 1);870871 assert_ok!(TemplateModule::set_mint_permission(872 origin1.clone(),873 1,874 true875 ));876 assert_ok!(TemplateModule::set_public_access_mode(877 origin1.clone(),878 1,879 AccessMode::WhiteList880 ));881 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));882 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(2)));883 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(3)));884885 assert_ok!(TemplateModule::transfer_from(886 origin2.clone(),887 account(1),888 account(2),889 1,890 1,891 1892 ));893894 // after transfer895 assert_eq!(TemplateModule::balance_count(1, 1), 0);896 assert_eq!(TemplateModule::balance_count(1, 2), 1);897 });898}899900// #endregion901902// Coverage tests region903// #region904905#[test]906fn owner_can_add_address_to_white_list() {907 new_test_ext().execute_with(|| {908 default_limits();909 910 let collection_id = create_test_collection(&CollectionMode::NFT, 1);911912 let origin1 = Origin::signed(1);913 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));914 assert_eq!(TemplateModule::white_list(collection_id, 2), true);915 });916}917918#[test]919fn admin_can_add_address_to_white_list() {920 new_test_ext().execute_with(|| {921 default_limits();922 923 let collection_id = create_test_collection(&CollectionMode::NFT, 1);924 let origin1 = Origin::signed(1);925 let origin2 = Origin::signed(2);926927 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));928 assert_ok!(TemplateModule::add_to_white_list(origin2.clone(), collection_id, account(3)));929 assert_eq!(TemplateModule::white_list(collection_id, 3), true);930 });931}932933#[test]934fn nonprivileged_user_cannot_add_address_to_white_list() {935 new_test_ext().execute_with(|| {936 default_limits();937 938 let collection_id = create_test_collection(&CollectionMode::NFT, 1);939940 let origin2 = Origin::signed(2);941 assert_noop!(942 TemplateModule::add_to_white_list(origin2.clone(), collection_id, account(3)),943 Error::<Test>::NoPermission944 );945 });946}947948#[test]949fn nobody_can_add_address_to_white_list_of_nonexisting_collection() {950 new_test_ext().execute_with(|| {951 default_limits();952953 let origin1 = Origin::signed(1);954955 assert_noop!(956 TemplateModule::add_to_white_list(origin1.clone(), 1, account(2)),957 Error::<Test>::CollectionNotFound958 );959 });960}961962#[test]963fn nobody_can_add_address_to_white_list_of_deleted_collection() {964 new_test_ext().execute_with(|| {965 default_limits();966 967 let collection_id = create_test_collection(&CollectionMode::NFT, 1);968969 let origin1 = Origin::signed(1);970 assert_ok!(TemplateModule::destroy_collection(origin1.clone(), collection_id));971 assert_noop!(972 TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)),973 Error::<Test>::CollectionNotFound974 );975 });976}977978// If address is already added to white list, nothing happens979#[test]980fn address_is_already_added_to_white_list() {981 new_test_ext().execute_with(|| {982 default_limits();983 984 let collection_id = create_test_collection(&CollectionMode::NFT, 1);985 let origin1 = Origin::signed(1);986 987 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));988 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));989 assert_eq!(TemplateModule::white_list(collection_id, 2), true);990 });991}992993#[test]994fn owner_can_remove_address_from_white_list() {995 new_test_ext().execute_with(|| {996 default_limits();997 998 let collection_id = create_test_collection(&CollectionMode::NFT, 1);9991000 let origin1 = Origin::signed(1);1001 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));1002 assert_ok!(TemplateModule::remove_from_white_list(1003 origin1.clone(),1004 collection_id,1005 account(2)1006 ));1007 assert_eq!(TemplateModule::white_list(collection_id, 2), false);1008 });1009}10101011#[test]1012fn admin_can_remove_address_from_white_list() {1013 new_test_ext().execute_with(|| {1014 default_limits();1015 1016 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1017 let origin1 = Origin::signed(1);1018 let origin2 = Origin::signed(2);10191020 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));10211022 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(3)));1023 assert_ok!(TemplateModule::remove_from_white_list(1024 origin2.clone(),1025 collection_id,1026 account(3)1027 ));1028 assert_eq!(TemplateModule::white_list(collection_id, 3), false);1029 });1030}10311032#[test]1033fn nonprivileged_user_cannot_remove_address_from_white_list() {1034 new_test_ext().execute_with(|| {1035 default_limits();1036 1037 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1038 let origin1 = Origin::signed(1);1039 let origin2 = Origin::signed(2);10401041 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));1042 assert_noop!(1043 TemplateModule::remove_from_white_list(origin2.clone(), collection_id, account(2)),1044 Error::<Test>::NoPermission1045 );1046 assert_eq!(TemplateModule::white_list(collection_id, 2), true);1047 });1048}10491050#[test]1051fn nobody_can_remove_address_from_white_list_of_nonexisting_collection() {1052 new_test_ext().execute_with(|| {1053 default_limits();1054 let origin1 = Origin::signed(1);10551056 assert_noop!(1057 TemplateModule::remove_from_white_list(origin1.clone(), 1, account(2)),1058 Error::<Test>::CollectionNotFound1059 );1060 });1061}10621063#[test]1064fn nobody_can_remove_address_from_white_list_of_deleted_collection() {1065 new_test_ext().execute_with(|| {1066 default_limits();1067 1068 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1069 let origin1 = Origin::signed(1);1070 let origin2 = Origin::signed(2);10711072 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));1073 assert_ok!(TemplateModule::destroy_collection(origin1.clone(), collection_id));1074 assert_noop!(1075 TemplateModule::remove_from_white_list(origin2.clone(), collection_id, account(2)),1076 Error::<Test>::CollectionNotFound1077 );1078 assert_eq!(TemplateModule::white_list(collection_id, 2), false);1079 });1080}10811082// If address is already removed from white list, nothing happens1083#[test]1084fn address_is_already_removed_from_white_list() {1085 new_test_ext().execute_with(|| {1086 default_limits();1087 1088 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1089 let origin1 = Origin::signed(1);10901091 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));1092 assert_ok!(TemplateModule::remove_from_white_list(1093 origin1.clone(),1094 collection_id,1095 account(2)1096 ));1097 assert_ok!(TemplateModule::remove_from_white_list(1098 origin1.clone(),1099 collection_id,1100 account(2)1101 ));1102 assert_eq!(TemplateModule::white_list(collection_id, 2), false);1103 });1104}11051106// If Public Access mode is set to WhiteList, tokens can’t be transferred from a non-whitelisted address with transfer or transferFrom (2 tests)1107#[test]1108fn white_list_test_1() {1109 new_test_ext().execute_with(|| {1110 default_limits();1111 1112 let collection_id = create_test_collection(&CollectionMode::NFT, 1);11131114 let origin1 = Origin::signed(1);1115 1116 let data = default_nft_data();1117 create_test_item(collection_id, &data.into());11181119 assert_ok!(TemplateModule::set_public_access_mode(1120 origin1.clone(),1121 collection_id,1122 AccessMode::WhiteList1123 ));1124 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));11251126 assert_noop!(1127 TemplateModule::transfer(origin1.clone(), account(3), 1, 1, 1),1128 Error::<Test>::AddresNotInWhiteList1129 );1130 });1131}11321133#[test]1134fn white_list_test_2() {1135 new_test_ext().execute_with(|| {1136 default_limits();1137 1138 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1139 let origin1 = Origin::signed(1);1140 1141 let data = default_nft_data();1142 create_test_item(collection_id, &data.into());11431144 assert_ok!(TemplateModule::set_public_access_mode(1145 origin1.clone(),1146 collection_id,1147 AccessMode::WhiteList1148 ));1149 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));1150 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(2)));11511152 // do approve1153 assert_ok!(TemplateModule::approve(origin1.clone(), account(1), 1, 1, 1));1154 assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);11551156 assert_ok!(TemplateModule::remove_from_white_list(1157 origin1.clone(),1158 1,1159 account(1)1160 ));11611162 assert_noop!(1163 TemplateModule::transfer_from(origin1.clone(), account(1), account(3), 1, 1, 1),1164 Error::<Test>::AddresNotInWhiteList1165 );1166 });1167}11681169// If Public Access mode is set to WhiteList, tokens can’t be transferred to a non-whitelisted address with transfer or transferFrom (2 tests)1170#[test]1171fn white_list_test_3() {1172 new_test_ext().execute_with(|| {1173 default_limits();1174 1175 let collection_id = create_test_collection(&CollectionMode::NFT, 1);11761177 let origin1 = Origin::signed(1);1178 1179 let data = default_nft_data();1180 create_test_item(collection_id, &data.into());11811182 assert_ok!(TemplateModule::set_public_access_mode(1183 origin1.clone(),1184 collection_id,1185 AccessMode::WhiteList1186 ));1187 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));11881189 assert_noop!(1190 TemplateModule::transfer(origin1.clone(), account(3), 1, 1, 1),1191 Error::<Test>::AddresNotInWhiteList1192 );1193 });1194}11951196#[test]1197fn white_list_test_4() {1198 new_test_ext().execute_with(|| {1199 default_limits();1200 1201 let collection_id = create_test_collection(&CollectionMode::NFT, 1);12021203 let origin1 = Origin::signed(1);12041205 let data = default_nft_data();1206 create_test_item(collection_id, &data.into());12071208 assert_ok!(TemplateModule::set_public_access_mode(1209 origin1.clone(),1210 collection_id,1211 AccessMode::WhiteList1212 ));1213 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(1)));1214 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));12151216 // do approve1217 assert_ok!(TemplateModule::approve(origin1.clone(), account(1), 1, 1, 1));1218 assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);12191220 assert_ok!(TemplateModule::remove_from_white_list(1221 origin1.clone(),1222 collection_id,1223 account(2)1224 ));12251226 assert_noop!(1227 TemplateModule::transfer_from(origin1.clone(), account(1), account(3), 1, 1, 1),1228 Error::<Test>::AddresNotInWhiteList1229 );1230 });1231}12321233// If Public Access mode is set to WhiteList, tokens can’t be destroyed by a non-whitelisted address (even if it owned them before enabling WhiteList mode)1234#[test]1235fn white_list_test_5() {1236 new_test_ext().execute_with(|| {1237 default_limits();1238 1239 let collection_id = create_test_collection(&CollectionMode::NFT, 1);12401241 let origin1 = Origin::signed(1);12421243 let data = default_nft_data();1244 create_test_item(collection_id, &data.into());12451246 assert_ok!(TemplateModule::set_public_access_mode(1247 origin1.clone(),1248 collection_id,1249 AccessMode::WhiteList1250 ));1251 assert_noop!(1252 TemplateModule::burn_item(origin1.clone(), 1, 1, 5),1253 Error::<Test>::AddresNotInWhiteList1254 );1255 });1256}12571258// If Public Access mode is set to WhiteList, token transfers can’t be Approved by a non-whitelisted address (see Approve method).1259#[test]1260fn white_list_test_6() {1261 new_test_ext().execute_with(|| {1262 default_limits();1263 1264 let collection_id = create_test_collection(&CollectionMode::NFT, 1);12651266 let origin1 = Origin::signed(1);12671268 let data = default_nft_data();1269 create_test_item(collection_id, &data.into());12701271 assert_ok!(TemplateModule::set_public_access_mode(1272 origin1.clone(),1273 collection_id,1274 AccessMode::WhiteList1275 ));12761277 // do approve1278 assert_noop!(1279 TemplateModule::approve(origin1.clone(), account(1), 1, 1, 5),1280 Error::<Test>::AddresNotInWhiteList1281 );1282 });1283}12841285// If Public Access mode is set to WhiteList, tokens can be transferred from a whitelisted address with transfer or transferFrom (2 tests) and1286// tokens can be transferred from a whitelisted address with transfer or transferFrom (2 tests)1287#[test]1288fn white_list_test_7() {1289 new_test_ext().execute_with(|| {1290 default_limits();1291 1292 let collection_id = create_test_collection(&CollectionMode::NFT, 1);12931294 let data = default_nft_data();1295 create_test_item(collection_id, &data.into());1296 1297 let origin1 = Origin::signed(1);12981299 assert_ok!(TemplateModule::set_public_access_mode(1300 origin1.clone(),1301 collection_id,1302 AccessMode::WhiteList1303 ));1304 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(1)));1305 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));13061307 assert_ok!(TemplateModule::transfer(origin1.clone(), account(2), 1, 1, 1));1308 });1309}13101311#[test]1312fn white_list_test_8() {1313 new_test_ext().execute_with(|| {1314 default_limits();1315 1316 let collection_id = create_test_collection(&CollectionMode::NFT, 1);13171318 let data = default_nft_data();1319 create_test_item(collection_id, &data.into());1320 1321 let origin1 = Origin::signed(1);13221323 assert_ok!(TemplateModule::set_public_access_mode(1324 origin1.clone(),1325 collection_id,1326 AccessMode::WhiteList1327 ));1328 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(1)));1329 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));13301331 // do approve1332 assert_ok!(TemplateModule::approve(origin1.clone(), account(1), 1, 1, 5));1333 assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 5);13341335 assert_ok!(TemplateModule::transfer_from(1336 origin1.clone(),1337 account(1),1338 account(2),1339 1,1340 1,1341 11342 ));1343 });1344}13451346// If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens can be created by owner.1347#[test]1348fn white_list_test_9() {1349 new_test_ext().execute_with(|| {1350 default_limits();1351 1352 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1353 let origin1 = Origin::signed(1);13541355 assert_ok!(TemplateModule::set_public_access_mode(1356 origin1.clone(),1357 collection_id,1358 AccessMode::WhiteList1359 ));1360 assert_ok!(TemplateModule::set_mint_permission(1361 origin1.clone(),1362 collection_id,1363 false1364 ));13651366 let data = default_nft_data();1367 create_test_item(collection_id, &data.into());1368 });1369}13701371// If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens can be created by admin.1372#[test]1373fn white_list_test_10() {1374 new_test_ext().execute_with(|| {1375 default_limits();1376 1377 let collection_id = create_test_collection(&CollectionMode::NFT, 1);13781379 let origin1 = Origin::signed(1);1380 let origin2 = Origin::signed(2);13811382 assert_ok!(TemplateModule::set_public_access_mode(1383 origin1.clone(),1384 collection_id,1385 AccessMode::WhiteList1386 ));1387 assert_ok!(TemplateModule::set_mint_permission(1388 origin1.clone(),1389 collection_id,1390 false1391 ));13921393 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));13941395 assert_ok!(TemplateModule::create_item(1396 origin2.clone(),1397 collection_id,1398 account(2),1399 default_nft_data().into()1400 ));1401 });1402}14031404// If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens cannot be created by non-privileged and white listed address.1405#[test]1406fn white_list_test_11() {1407 new_test_ext().execute_with(|| {1408 default_limits();1409 1410 let collection_id = create_test_collection(&CollectionMode::NFT, 1);14111412 let origin1 = Origin::signed(1);1413 let origin2 = Origin::signed(2);14141415 assert_ok!(TemplateModule::set_public_access_mode(1416 origin1.clone(),1417 collection_id,1418 AccessMode::WhiteList1419 ));1420 assert_ok!(TemplateModule::set_mint_permission(1421 origin1.clone(),1422 collection_id,1423 false1424 ));1425 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));14261427 assert_noop!(1428 TemplateModule::create_item(origin2.clone(), 1, account(2), default_nft_data().into()),1429 Error::<Test>::PublicMintingNotAllowed1430 );1431 });1432}14331434// If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens cannot be created by non-privileged and non-white listed address.1435#[test]1436fn white_list_test_12() {1437 new_test_ext().execute_with(|| {1438 default_limits();1439 1440 let collection_id = create_test_collection(&CollectionMode::NFT, 1);14411442 let origin1 = Origin::signed(1);1443 let origin2 = Origin::signed(2);14441445 assert_ok!(TemplateModule::set_public_access_mode(1446 origin1.clone(),1447 collection_id,1448 AccessMode::WhiteList1449 ));1450 assert_ok!(TemplateModule::set_mint_permission(1451 origin1.clone(),1452 collection_id,1453 false1454 ));14551456 assert_noop!(1457 TemplateModule::create_item(origin2.clone(), 1, account(2), default_nft_data().into()),1458 Error::<Test>::PublicMintingNotAllowed1459 );1460 });1461}14621463// If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by owner.1464#[test]1465fn white_list_test_13() {1466 new_test_ext().execute_with(|| {1467 default_limits();1468 1469 let collection_id = create_test_collection(&CollectionMode::NFT, 1);14701471 let origin1 = Origin::signed(1);14721473 assert_ok!(TemplateModule::set_public_access_mode(1474 origin1.clone(),1475 collection_id,1476 AccessMode::WhiteList1477 ));1478 assert_ok!(TemplateModule::set_mint_permission(1479 origin1.clone(),1480 collection_id,1481 true1482 ));14831484 let data = default_nft_data();1485 create_test_item(collection_id, &data.into());1486 });1487}14881489// If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by admin.1490#[test]1491fn white_list_test_14() {1492 new_test_ext().execute_with(|| {1493 default_limits();1494 1495 let collection_id = create_test_collection(&CollectionMode::NFT, 1);14961497 let origin1 = Origin::signed(1);1498 let origin2 = Origin::signed(2);14991500 assert_ok!(TemplateModule::set_public_access_mode(1501 origin1.clone(),1502 collection_id,1503 AccessMode::WhiteList1504 ));1505 assert_ok!(TemplateModule::set_mint_permission(1506 origin1.clone(),1507 collection_id,1508 true1509 ));15101511 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));15121513 assert_ok!(TemplateModule::create_item(1514 origin2.clone(),1515 1,1516 account(2),1517 default_nft_data().into()1518 ));1519 });1520}15211522// If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens cannot be created by non-privileged and non-white listed address.1523#[test]1524fn white_list_test_15() {1525 new_test_ext().execute_with(|| {1526 default_limits();1527 1528 let collection_id = create_test_collection(&CollectionMode::NFT, 1);15291530 let origin1 = Origin::signed(1);1531 let origin2 = Origin::signed(2);15321533 assert_ok!(TemplateModule::set_public_access_mode(1534 origin1.clone(),1535 collection_id,1536 AccessMode::WhiteList1537 ));1538 assert_ok!(TemplateModule::set_mint_permission(1539 origin1.clone(),1540 collection_id,1541 true1542 ));15431544 assert_noop!(1545 TemplateModule::create_item(origin2.clone(), 1, account(2), default_nft_data().into()),1546 Error::<Test>::AddresNotInWhiteList1547 );1548 });1549}15501551// If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by non-privileged and white listed address.1552#[test]1553fn white_list_test_16() {1554 new_test_ext().execute_with(|| {1555 default_limits();1556 1557 let collection_id = create_test_collection(&CollectionMode::NFT, 1);15581559 let origin1 = Origin::signed(1);1560 let origin2 = Origin::signed(2);15611562 assert_ok!(TemplateModule::set_public_access_mode(1563 origin1.clone(),1564 collection_id,1565 AccessMode::WhiteList1566 ));1567 assert_ok!(TemplateModule::set_mint_permission(1568 origin1.clone(),1569 collection_id,1570 true1571 ));1572 assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));15731574 assert_ok!(TemplateModule::create_item(1575 origin2.clone(),1576 1,1577 account(2),1578 default_nft_data().into()1579 ));1580 });1581}15821583// Total number of collections. Positive test1584#[test]1585fn total_number_collections_bound() {1586 new_test_ext().execute_with(|| {1587 default_limits();1588 1589 create_test_collection(&CollectionMode::NFT, 1);1590 });1591}15921593// Total number of collections. Negotive test1594#[test]1595fn total_number_collections_bound_neg() {1596 new_test_ext().execute_with(|| {1597 default_limits();15981599 let origin1 = Origin::signed(1);16001601 for i in 0..default_collection_numbers_limit() {1602 create_test_collection(&CollectionMode::NFT, i + 1);1603 }16041605 let col_name1: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();1606 let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();1607 let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();16081609 // 11-th collection in chain. Expects error1610 assert_noop!(TemplateModule::create_collection(1611 origin1.clone(),1612 col_name1.clone(),1613 col_desc1.clone(),1614 token_prefix1.clone(),1615 CollectionMode::NFT1616 ), Error::<Test>::TotalCollectionsLimitExceeded);1617 });1618}16191620// Owned tokens by a single address. Positive test1621#[test]1622fn owned_tokens_bound() {1623 new_test_ext().execute_with(|| {1624 default_limits();1625 1626 let collection_id = create_test_collection(&CollectionMode::NFT, 1);16271628 let data = default_nft_data();1629 create_test_item(collection_id, &data.clone().into());1630 create_test_item(collection_id, &data.into());1631 });1632}16331634// Owned tokens by a single address. Negotive test1635#[test]1636fn owned_tokens_bound_neg() {1637 new_test_ext().execute_with(|| {1638 assert_ok!(TemplateModule::set_chain_limits(RawOrigin::Root.into(), ChainLimits { 1639 collection_numbers_limit: 10,1640 account_token_ownership_limit: 1,1641 collections_admins_limit: 5,1642 custom_data_limit: 2048,1643 nft_sponsor_transfer_timeout: 15,1644 fungible_sponsor_transfer_timeout: 15,1645 refungible_sponsor_transfer_timeout: 15,1646 const_on_chain_schema_limit: 1024,1647 offchain_schema_limit: 1024,1648 variable_on_chain_schema_limit: 1024,1649 }));1650 1651 let collection_id = create_test_collection(&CollectionMode::NFT, 1);16521653 let origin1 = Origin::signed(1);1654 let data = default_nft_data();1655 create_test_item(collection_id, &data.clone().into());16561657 assert_noop!(TemplateModule::create_item(1658 origin1.clone(),1659 1,1660 account(1),1661 data.into()1662 ), Error::<Test>::AddressOwnershipLimitExceeded);1663 });1664}16651666// Number of collection admins. Positive test1667#[test]1668fn collection_admins_bound() {1669 new_test_ext().execute_with(|| {1670 assert_ok!(TemplateModule::set_chain_limits(RawOrigin::Root.into(), ChainLimits { 1671 collection_numbers_limit: 10,1672 account_token_ownership_limit: 10,1673 collections_admins_limit: 2,1674 custom_data_limit: 2048,1675 nft_sponsor_transfer_timeout: 15,1676 fungible_sponsor_transfer_timeout: 15,1677 refungible_sponsor_transfer_timeout: 15,1678 const_on_chain_schema_limit: 1024,1679 offchain_schema_limit: 1024,1680 variable_on_chain_schema_limit: 1024,1681 }));1682 1683 let collection_id = create_test_collection(&CollectionMode::NFT, 1);16841685 let origin1 = Origin::signed(1);1686 1687 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));1688 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(3)));1689 });1690}16911692// Number of collection admins. Negotive test1693#[test]1694fn collection_admins_bound_neg() {1695 new_test_ext().execute_with(|| {1696 assert_ok!(TemplateModule::set_chain_limits(RawOrigin::Root.into(), ChainLimits { 1697 collection_numbers_limit: 10,1698 account_token_ownership_limit: 1,1699 collections_admins_limit: 1,1700 custom_data_limit: 2048,1701 nft_sponsor_transfer_timeout: 15,1702 fungible_sponsor_transfer_timeout: 15,1703 refungible_sponsor_transfer_timeout: 15,1704 const_on_chain_schema_limit: 1024,1705 offchain_schema_limit: 1024,1706 variable_on_chain_schema_limit: 1024,1707 }));1708 1709 let collection_id = create_test_collection(&CollectionMode::NFT, 1);17101711 let origin1 = Origin::signed(1);17121713 assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));1714 assert_noop!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(3)), Error::<Test>::CollectionAdminsLimitExceeded);1715 });1716}17171718// NFT custom data size. Negative test const_data.1719#[test]1720fn custom_data_size_nft_const_data_bound_neg() {1721 new_test_ext().execute_with(|| {1722 assert_ok!(TemplateModule::set_chain_limits(RawOrigin::Root.into(), ChainLimits { 1723 collection_numbers_limit: 10,1724 account_token_ownership_limit: 10,1725 collections_admins_limit: 5,1726 custom_data_limit: 2,1727 nft_sponsor_transfer_timeout: 15,1728 fungible_sponsor_transfer_timeout: 15,1729 refungible_sponsor_transfer_timeout: 15,1730 const_on_chain_schema_limit: 1024,1731 offchain_schema_limit: 1024,1732 variable_on_chain_schema_limit: 1024,1733 }));1734 1735 let collection_id = create_test_collection(&CollectionMode::NFT, 1);17361737 let origin1 = Origin::signed(1);1738 let too_big_const_data = CreateItemData::NFT(CreateNftData{1739 const_data: vec![1, 2, 3, 4],1740 variable_data: vec![]1741 });17421743 assert_noop!(TemplateModule::create_item(1744 origin1.clone(),1745 collection_id,1746 account(1),1747 too_big_const_data1748 ), Error::<Test>::TokenConstDataLimitExceeded);1749 });1750}17511752// NFT custom data size. Negative test variable_data.1753#[test]1754fn custom_data_size_nft_variable_data_bound_neg() {1755 new_test_ext().execute_with(|| {1756 assert_ok!(TemplateModule::set_chain_limits(RawOrigin::Root.into(), ChainLimits { 1757 collection_numbers_limit: 10,1758 account_token_ownership_limit: 10,1759 collections_admins_limit: 5,1760 custom_data_limit: 2,1761 nft_sponsor_transfer_timeout: 15,1762 fungible_sponsor_transfer_timeout: 15,1763 refungible_sponsor_transfer_timeout: 15,1764 const_on_chain_schema_limit: 1024,1765 offchain_schema_limit: 1024,1766 variable_on_chain_schema_limit: 1024,1767 }));17681769 let collection_id = create_test_collection(&CollectionMode::NFT, 1);17701771 let origin1 = Origin::signed(1);1772 let too_big_const_data = CreateItemData::NFT(CreateNftData{1773 const_data: vec![],1774 variable_data: vec![1, 2, 3, 4]1775 });17761777 assert_noop!(TemplateModule::create_item(1778 origin1.clone(),1779 collection_id,1780 account(1),1781 too_big_const_data1782 ), Error::<Test>::TokenVariableDataLimitExceeded);1783 });1784}17851786// Re fungible custom data size. Negative test const_data.1787#[test]1788fn custom_data_size_re_fungible_const_data_bound_neg() {1789 new_test_ext().execute_with(|| {1790 assert_ok!(TemplateModule::set_chain_limits(RawOrigin::Root.into(), ChainLimits { 1791 collection_numbers_limit: 10,1792 account_token_ownership_limit: 10,1793 collections_admins_limit: 5,1794 custom_data_limit: 2,1795 nft_sponsor_transfer_timeout: 15,1796 fungible_sponsor_transfer_timeout: 15,1797 refungible_sponsor_transfer_timeout: 15,1798 const_on_chain_schema_limit: 1024,1799 offchain_schema_limit: 1024,1800 variable_on_chain_schema_limit: 1024,1801 }));18021803 let collection_id = create_test_collection(&CollectionMode::NFT, 1);18041805 let origin1 = Origin::signed(1);1806 let too_big_const_data = CreateItemData::NFT(CreateNftData{1807 const_data: vec![1, 2, 3, 4],1808 variable_data: vec![]1809 });18101811 assert_noop!(TemplateModule::create_item(1812 origin1.clone(),1813 collection_id,1814 account(1),1815 too_big_const_data1816 ), Error::<Test>::TokenConstDataLimitExceeded);1817 });1818}18191820// Re fungible custom data size. Negative test variable_data.1821#[test]1822fn custom_data_size_re_fungible_variable_data_bound_neg() {1823 new_test_ext().execute_with(|| {1824 assert_ok!(TemplateModule::set_chain_limits(RawOrigin::Root.into(), ChainLimits { 1825 collection_numbers_limit: 10,1826 account_token_ownership_limit: 10,1827 collections_admins_limit: 5,1828 custom_data_limit: 2,1829 nft_sponsor_transfer_timeout: 15,1830 fungible_sponsor_transfer_timeout: 15,1831 refungible_sponsor_transfer_timeout: 15,1832 const_on_chain_schema_limit: 1024,1833 offchain_schema_limit: 1024,1834 variable_on_chain_schema_limit: 1024,1835 }));18361837 let collection_id = create_test_collection(&CollectionMode::NFT, 1);18381839 let origin1 = Origin::signed(1);1840 let too_big_const_data = CreateItemData::NFT(CreateNftData{1841 const_data: vec![],1842 variable_data: vec![1, 2, 3, 4]1843 });18441845 assert_noop!(TemplateModule::create_item(1846 origin1.clone(),1847 collection_id,1848 account(1),1849 too_big_const_data1850 ), Error::<Test>::TokenVariableDataLimitExceeded);1851 });1852}1853// #endregion18541855#[test]1856fn set_const_on_chain_schema() {1857 new_test_ext().execute_with(|| {1858 default_limits();18591860 let collection_id = create_test_collection(&CollectionMode::NFT, 1);18611862 let origin1 = Origin::signed(1);1863 assert_ok!(TemplateModule::set_const_on_chain_schema(origin1, collection_id, b"test const on chain schema".to_vec()));18641865 assert_eq!(TemplateModule::collection_id(collection_id).unwrap().const_on_chain_schema, b"test const on chain schema".to_vec());1866 assert_eq!(TemplateModule::collection_id(collection_id).unwrap().variable_on_chain_schema, b"".to_vec());1867 });1868}18691870#[test]1871fn set_variable_on_chain_schema() {1872 new_test_ext().execute_with(|| {1873 default_limits();1874 1875 let collection_id = create_test_collection(&CollectionMode::NFT, 1);18761877 let origin1 = Origin::signed(1);1878 assert_ok!(TemplateModule::set_variable_on_chain_schema(origin1, collection_id, b"test variable on chain schema".to_vec()));18791880 assert_eq!(TemplateModule::collection_id(collection_id).unwrap().const_on_chain_schema, b"".to_vec());1881 assert_eq!(TemplateModule::collection_id(collection_id).unwrap().variable_on_chain_schema, b"test variable on chain schema".to_vec());1882 });1883}18841885#[test]1886fn set_variable_meta_data_on_nft_token_stores_variable_meta_data() {1887 new_test_ext().execute_with(|| {1888 default_limits();18891890 let collection_id = create_test_collection(&CollectionMode::NFT, 1);18911892 let origin1 = Origin::signed(1);1893 1894 let data = default_nft_data();1895 create_test_item(1, &data.into());1896 1897 let variable_data = b"test set_variable_meta_data method.".to_vec();1898 assert_ok!(TemplateModule::set_variable_meta_data(origin1, collection_id, 1, variable_data.clone()));18991900 assert_eq!(TemplateModule::nft_item_id(collection_id, 1).unwrap().variable_data, variable_data);1901 });1902}19031904#[test]1905fn set_variable_meta_data_on_re_fungible_token_stores_variable_meta_data() {1906 new_test_ext().execute_with(|| {1907 default_limits();19081909 let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);19101911 let origin1 = Origin::signed(1);19121913 let data = default_re_fungible_data();1914 create_test_item(1, &data.into());19151916 let variable_data = b"test set_variable_meta_data method.".to_vec();1917 assert_ok!(TemplateModule::set_variable_meta_data(origin1, collection_id, 1, variable_data.clone()));19181919 assert_eq!(TemplateModule::refungible_item_id(collection_id, 1).unwrap().variable_data, variable_data);1920 });1921}192219231924#[test]1925fn set_variable_meta_data_on_fungible_token_fails() {1926 new_test_ext().execute_with(|| {1927 default_limits();19281929 let collection_id = create_test_collection(&CollectionMode::Fungible(3), 1);19301931 let origin1 = Origin::signed(1);19321933 let data = default_fungible_data();1934 create_test_item(1, &data.into());19351936 let variable_data = b"test set_variable_meta_data method.".to_vec();1937 assert_noop!(TemplateModule::set_variable_meta_data(origin1, collection_id, 1, variable_data.clone()), Error::<Test>::CantStoreMetadataInFungibleTokens);1938 });1939}19401941#[test]1942fn set_variable_meta_data_on_nft_token_fails_for_big_data() {1943 new_test_ext().execute_with(|| {1944 assert_ok!(TemplateModule::set_chain_limits(RawOrigin::Root.into(), ChainLimits { 1945 collection_numbers_limit: default_collection_numbers_limit(),1946 account_token_ownership_limit: 10,1947 collections_admins_limit: 5,1948 custom_data_limit: 10,1949 nft_sponsor_transfer_timeout: 15,1950 fungible_sponsor_transfer_timeout: 15,1951 refungible_sponsor_transfer_timeout: 15,1952 const_on_chain_schema_limit: 1024,1953 offchain_schema_limit: 1024,1954 variable_on_chain_schema_limit: 1024,1955 }));19561957 let collection_id = create_test_collection(&CollectionMode::NFT, 1);19581959 let origin1 = Origin::signed(1);19601961 let data = default_nft_data();1962 create_test_item(1, &data.into());19631964 let variable_data = b"test set_variable_meta_data method, bigger than limits.".to_vec();1965 assert_noop!(TemplateModule::set_variable_meta_data(origin1, collection_id, 1, variable_data), Error::<Test>::TokenVariableDataLimitExceeded);1966 });1967}19681969#[test]1970fn set_variable_meta_data_on_re_fungible_token_fails_for_big_data() {1971 new_test_ext().execute_with(|| {1972 assert_ok!(TemplateModule::set_chain_limits(RawOrigin::Root.into(), ChainLimits { 1973 collection_numbers_limit: default_collection_numbers_limit(),1974 account_token_ownership_limit: 10,1975 collections_admins_limit: 5,1976 custom_data_limit: 10,1977 nft_sponsor_transfer_timeout: 15,1978 fungible_sponsor_transfer_timeout: 15,1979 refungible_sponsor_transfer_timeout: 15,1980 const_on_chain_schema_limit: 1024,1981 offchain_schema_limit: 1024,1982 variable_on_chain_schema_limit: 1024,1983 }));198419851986 let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);19871988 let origin1 = Origin::signed(1);19891990 let data = default_re_fungible_data();1991 create_test_item(1, &data.into());19921993 let variable_data = b"test set_variable_meta_data method, bigger than limits.".to_vec();1994 assert_noop!(TemplateModule::set_variable_meta_data(origin1, collection_id, 1, variable_data), Error::<Test>::TokenVariableDataLimitExceeded);1995 });1996}pallets/scheduler/src/lib.rsdiffbeforeafterboth--- a/pallets/scheduler/src/lib.rs
+++ b/pallets/scheduler/src/lib.rs
@@ -887,6 +887,7 @@
type ScheduleOrigin = EnsureOneOf<u64, EnsureRoot<u64>, EnsureSignedBy<One, u64>>;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = ();
+ type SponsorshipHandler = ();
}
pub fn new_test_ext() -> sp_io::TestExternalities {
runtime/src/lib.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -689,7 +689,6 @@
type Event = Event;
type WeightInfo = nft_weights::WeightInfo;
- type EvmWithdrawOrigin = EnsureAddressTruncated;
type EvmBackwardsAddressMapping = pallet_nft::MapBackwardsAddressTruncated;
type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
type CrossAccountId = pallet_nft::BasicCrossAccountId<Self>;