difftreelog
fix merge test changes
in: master
7 files changed
pallets/inflation/src/tests.rsdiffbeforeafterboth1#[cfg(test)]2mod tests {3 use crate as pallet_inflation;45 use frame_system;6 use frame_support::{traits::{Currency}, parameter_types};7 use frame_support::{traits::OnInitialize};8 use sp_core::H256;9 use sp_runtime::{traits::{BlakeTwo256, IdentityLookup}, testing::Header};1011 type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;12 type Block = frame_system::mocking::MockBlock<Test>;1314 const YEAR: u64 = 5_259_600;1516 parameter_types! {17 pub const ExistentialDeposit: u64 = 1;18 pub const MaxLocks: u32 = 50;19 }20 21 impl pallet_balances::Config for Test {22 type AccountStore = System;23 type Balance = u64;24 type DustRemoval = ();25 type Event = ();26 type ExistentialDeposit = ExistentialDeposit;27 type WeightInfo = ();28 type MaxLocks = MaxLocks;29 }30 31 frame_support::construct_runtime!(32 pub enum Test where33 Block = Block,34 NodeBlock = Block,35 UncheckedExtrinsic = UncheckedExtrinsic,36 {37 Balances: pallet_balances::{Module, Call, Storage},38 System: frame_system::{Module, Call, Config, Storage, Event<T>},39 Inflation: pallet_inflation::{Module, Call, Storage},40 }41 );4243 parameter_types! {44 pub const BlockHashCount: u64 = 250;45 pub BlockWeights: frame_system::limits::BlockWeights =46 frame_system::limits::BlockWeights::simple_max(1024);47 pub const SS58Prefix: u8 = 42;48 }4950 impl frame_system::Config for Test {51 type BaseCallFilter = ();52 type BlockWeights = ();53 type BlockLength = ();54 type DbWeight = ();55 type Origin = Origin;56 type Call = Call;57 type Index = u64;58 type BlockNumber = u64;59 type Hash = H256;60 type Hashing = BlakeTwo256;61 type AccountId = u64;62 type Lookup = IdentityLookup<Self::AccountId>;63 type Header = Header;64 type Event = ();65 type BlockHashCount = BlockHashCount;66 type Version = ();67 type PalletInfo = PalletInfo;68 type AccountData = pallet_balances::AccountData<u64>;69 type OnNewAccount = ();70 type OnKilledAccount = ();71 type SystemWeightInfo = ();72 type SS58Prefix = SS58Prefix;73 }7475 parameter_types! {76 pub TreasuryAccountId: u64 = 1234;77 pub const InflationBlockInterval: u32 = 100; // every time per how many blocks inflation is applied78 }79 80 impl pallet_inflation::Config for Test {81 type Currency = Balances;82 type TreasuryAccountId = TreasuryAccountId;83 type InflationBlockInterval = InflationBlockInterval;84 }8586 // Build genesis storage according to the mock runtime.87 pub fn new_test_ext() -> sp_io::TestExternalities {88 frame_system::GenesisConfig::default().build_storage::<Test>().unwrap().into()89 }9091 #[test]92 fn inflation_works() {93 new_test_ext().execute_with(|| {94 // Total issuance = 1_000_000_00095 let initial_issuance: u64 = 1_000_000_000;96 let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);97 assert_eq!(Balances::free_balance(1234), initial_issuance);9899 // BlockInflation should be set after 1st block and 100 // first inflation deposit should be equal to BlockInflation101 Inflation::on_initialize(1);102 assert!(Inflation::block_inflation() > 0);103 assert_eq!(Balances::free_balance(1234) - initial_issuance, Inflation::block_inflation());104 });105 }106107 #[test]108 fn inflation_second_deposit() {109 new_test_ext().execute_with(|| {110 // Total issuance = 1_000_000_000111 let initial_issuance: u64 = 1_000_000_000;112 let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);113 assert_eq!(Balances::free_balance(1234), initial_issuance);114 Inflation::on_initialize(1);115116 // Next inflation deposit happens when block is multiple of InflationBlockInterval117 let mut block: u32 = 2;118 let balance_before: u64 = Balances::free_balance(1234);119 while block % InflationBlockInterval::get() != 0 {120 Inflation::on_initialize(block as u64);121 block += 1;122 }123 let balance_just_before: u64 = Balances::free_balance(1234);124 assert_eq!(balance_before, balance_just_before);125126 // The block with inflation127 Inflation::on_initialize(block as u64);128 let balance_after: u64 = Balances::free_balance(1234);129 assert_eq!(balance_after - balance_just_before, Inflation::block_inflation());130 });131 }132133 #[test]134 fn inflation_in_1_year() {135 new_test_ext().execute_with(|| {136 // Total issuance = 1_000_000_000137 let initial_issuance: u64 = 1_000_000_000;138 let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);139 assert_eq!(Balances::free_balance(1234), initial_issuance);140 Inflation::on_initialize(1);141 let block_inflation_year_0 = Inflation::block_inflation();142143 Inflation::on_initialize(YEAR);144 let block_inflation_year_1 = Inflation::block_inflation();145146 // Assert that year 1 inflation is less than year 0147 assert!(block_inflation_year_0 > block_inflation_year_1);148 });149 }150151 #[test]152 fn inflation_in_1_to_9_years() {153 new_test_ext().execute_with(|| {154 // Total issuance = 1_000_000_000155 let initial_issuance: u64 = 1_000_000_000;156 let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);157 assert_eq!(Balances::free_balance(1234), initial_issuance);158 Inflation::on_initialize(1);159160 for year in 1..=9 {161 let block_inflation_year_before = Inflation::block_inflation();162 Inflation::on_initialize(YEAR * year);163 let block_inflation_year_after = Inflation::block_inflation();164165 // Assert that next year inflation is less than previous year inflation166 assert!(block_inflation_year_before > block_inflation_year_after);167 }168169 });170 }171172 #[test]173 fn inflation_after_year_10_is_flat() {174 new_test_ext().execute_with(|| {175 // Total issuance = 1_000_000_000176 let initial_issuance: u64 = 1_000_000_000;177 let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);178 assert_eq!(Balances::free_balance(1234), initial_issuance);179 Inflation::on_initialize(YEAR * 9);180181 for year in 10..=20 {182 let block_inflation_year_before = Inflation::block_inflation();183 Inflation::on_initialize(YEAR * year);184 let block_inflation_year_after = Inflation::block_inflation();185186 // Assert that next year inflation is equal to previous year inflation187 assert_eq!(block_inflation_year_before, block_inflation_year_after);188 }189 });190 }191192 #[test]193 fn inflation_rate_by_year() {194 new_test_ext().execute_with(|| {195 let payouts: u64 = YEAR / InflationBlockInterval::get() as u64;196197 // Inflation starts at 10% and does down by 2/3% every year until year 9 (included), 198 // then it is flat.199 let payout_by_year: [u64; 11] = [200 1000,201 933,202 867,203 800,204 733,205 667,206 600,207 533,208 467,209 400,210 400211 ];212213 // For accuracy total issuance = payout0 * payouts * 10;214 let initial_issuance: u64 = payout_by_year[0] * payouts * 10;215 let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);216 assert_eq!(Balances::free_balance(1234), initial_issuance);217218 for year in 0..=10 {219 // Year first block220 Inflation::on_initialize(year*YEAR);221 let mut actual_payout = Inflation::block_inflation();222 assert_eq!(actual_payout, payout_by_year[year as usize]);223224 // Year second block225 Inflation::on_initialize(year*YEAR+1);226 actual_payout = Inflation::block_inflation();227 assert_eq!(actual_payout, payout_by_year[year as usize]);228229 // Year middle block230 Inflation::on_initialize(year*YEAR + YEAR/2);231 actual_payout = Inflation::block_inflation();232 assert_eq!(actual_payout, payout_by_year[year as usize]);233234 // Year last block235 Inflation::on_initialize((year + 1)*YEAR-1);236 actual_payout = Inflation::block_inflation();237 assert_eq!(actual_payout, payout_by_year[year as usize]);238 }239 });240 }241}1#[cfg(test)]2mod tests {3 use crate as pallet_inflation;45 use frame_system;6 use frame_support::{traits::{Currency}, parameter_types};7 use frame_support::{traits::OnInitialize};8 use sp_core::H256;9 use sp_runtime::{traits::{BlakeTwo256, IdentityLookup}, testing::Header};1011 type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;12 type Block = frame_system::mocking::MockBlock<Test>;1314 const YEAR: u64 = 5_259_600;1516 parameter_types! {17 pub const ExistentialDeposit: u64 = 1;18 pub const MaxLocks: u32 = 50;19 }20 21 impl pallet_balances::Config for Test {22 type AccountStore = System;23 type Balance = u64;24 type DustRemoval = ();25 type Event = ();26 type ExistentialDeposit = ExistentialDeposit;27 type WeightInfo = ();28 type MaxLocks = MaxLocks;29 }30 31 frame_support::construct_runtime!(32 pub enum Test where33 Block = Block,34 NodeBlock = Block,35 UncheckedExtrinsic = UncheckedExtrinsic,36 {37 Balances: pallet_balances::{Pallet, Call, Storage},38 System: frame_system::{Pallet, Call, Config, Storage, Event<T>},39 Inflation: pallet_inflation::{Pallet, Call, Storage},40 }41 );4243 parameter_types! {44 pub const BlockHashCount: u64 = 250;45 pub BlockWeights: frame_system::limits::BlockWeights =46 frame_system::limits::BlockWeights::simple_max(1024);47 pub const SS58Prefix: u8 = 42;48 }4950 impl frame_system::Config for Test {51 type BaseCallFilter = ();52 type BlockWeights = ();53 type BlockLength = ();54 type DbWeight = ();55 type Origin = Origin;56 type Call = Call;57 type Index = u64;58 type BlockNumber = u64;59 type Hash = H256;60 type Hashing = BlakeTwo256;61 type AccountId = u64;62 type Lookup = IdentityLookup<Self::AccountId>;63 type Header = Header;64 type Event = ();65 type BlockHashCount = BlockHashCount;66 type Version = ();67 type PalletInfo = PalletInfo;68 type AccountData = pallet_balances::AccountData<u64>;69 type OnNewAccount = ();70 type OnKilledAccount = ();71 type SystemWeightInfo = ();72 type SS58Prefix = SS58Prefix;73 type OnSetCode = ();74 }7576 parameter_types! {77 pub TreasuryAccountId: u64 = 1234;78 pub const InflationBlockInterval: u32 = 100; // every time per how many blocks inflation is applied79 }80 81 impl pallet_inflation::Config for Test {82 type Currency = Balances;83 type TreasuryAccountId = TreasuryAccountId;84 type InflationBlockInterval = InflationBlockInterval;85 }8687 // Build genesis storage according to the mock runtime.88 pub fn new_test_ext() -> sp_io::TestExternalities {89 frame_system::GenesisConfig::default().build_storage::<Test>().unwrap().into()90 }9192 #[test]93 fn inflation_works() {94 new_test_ext().execute_with(|| {95 // Total issuance = 1_000_000_00096 let initial_issuance: u64 = 1_000_000_000;97 let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);98 assert_eq!(Balances::free_balance(1234), initial_issuance);99100 // BlockInflation should be set after 1st block and 101 // first inflation deposit should be equal to BlockInflation102 Inflation::on_initialize(1);103 assert!(Inflation::block_inflation() > 0);104 assert_eq!(Balances::free_balance(1234) - initial_issuance, Inflation::block_inflation());105 });106 }107108 #[test]109 fn inflation_second_deposit() {110 new_test_ext().execute_with(|| {111 // Total issuance = 1_000_000_000112 let initial_issuance: u64 = 1_000_000_000;113 let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);114 assert_eq!(Balances::free_balance(1234), initial_issuance);115 Inflation::on_initialize(1);116117 // Next inflation deposit happens when block is multiple of InflationBlockInterval118 let mut block: u32 = 2;119 let balance_before: u64 = Balances::free_balance(1234);120 while block % InflationBlockInterval::get() != 0 {121 Inflation::on_initialize(block as u64);122 block += 1;123 }124 let balance_just_before: u64 = Balances::free_balance(1234);125 assert_eq!(balance_before, balance_just_before);126127 // The block with inflation128 Inflation::on_initialize(block as u64);129 let balance_after: u64 = Balances::free_balance(1234);130 assert_eq!(balance_after - balance_just_before, Inflation::block_inflation());131 });132 }133134 #[test]135 fn inflation_in_1_year() {136 new_test_ext().execute_with(|| {137 // Total issuance = 1_000_000_000138 let initial_issuance: u64 = 1_000_000_000;139 let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);140 assert_eq!(Balances::free_balance(1234), initial_issuance);141 Inflation::on_initialize(1);142 let block_inflation_year_0 = Inflation::block_inflation();143144 Inflation::on_initialize(YEAR);145 let block_inflation_year_1 = Inflation::block_inflation();146147 // Assert that year 1 inflation is less than year 0148 assert!(block_inflation_year_0 > block_inflation_year_1);149 });150 }151152 #[test]153 fn inflation_in_1_to_9_years() {154 new_test_ext().execute_with(|| {155 // Total issuance = 1_000_000_000156 let initial_issuance: u64 = 1_000_000_000;157 let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);158 assert_eq!(Balances::free_balance(1234), initial_issuance);159 Inflation::on_initialize(1);160161 for year in 1..=9 {162 let block_inflation_year_before = Inflation::block_inflation();163 Inflation::on_initialize(YEAR * year);164 let block_inflation_year_after = Inflation::block_inflation();165166 // Assert that next year inflation is less than previous year inflation167 assert!(block_inflation_year_before > block_inflation_year_after);168 }169170 });171 }172173 #[test]174 fn inflation_after_year_10_is_flat() {175 new_test_ext().execute_with(|| {176 // Total issuance = 1_000_000_000177 let initial_issuance: u64 = 1_000_000_000;178 let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);179 assert_eq!(Balances::free_balance(1234), initial_issuance);180 Inflation::on_initialize(YEAR * 9);181182 for year in 10..=20 {183 let block_inflation_year_before = Inflation::block_inflation();184 Inflation::on_initialize(YEAR * year);185 let block_inflation_year_after = Inflation::block_inflation();186187 // Assert that next year inflation is equal to previous year inflation188 assert_eq!(block_inflation_year_before, block_inflation_year_after);189 }190 });191 }192193 #[test]194 fn inflation_rate_by_year() {195 new_test_ext().execute_with(|| {196 let payouts: u64 = YEAR / InflationBlockInterval::get() as u64;197198 // Inflation starts at 10% and does down by 2/3% every year until year 9 (included), 199 // then it is flat.200 let payout_by_year: [u64; 11] = [201 1000,202 933,203 867,204 800,205 733,206 667,207 600,208 533,209 467,210 400,211 400212 ];213214 // For accuracy total issuance = payout0 * payouts * 10;215 let initial_issuance: u64 = payout_by_year[0] * payouts * 10;216 let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);217 assert_eq!(Balances::free_balance(1234), initial_issuance);218219 for year in 0..=10 {220 // Year first block221 Inflation::on_initialize(year*YEAR);222 let mut actual_payout = Inflation::block_inflation();223 assert_eq!(actual_payout, payout_by_year[year as usize]);224225 // Year second block226 Inflation::on_initialize(year*YEAR+1);227 actual_payout = Inflation::block_inflation();228 assert_eq!(actual_payout, payout_by_year[year as usize]);229230 // Year middle block231 Inflation::on_initialize(year*YEAR + YEAR/2);232 actual_payout = Inflation::block_inflation();233 assert_eq!(actual_payout, payout_by_year[year as usize]);234235 // Year last block236 Inflation::on_initialize((year + 1)*YEAR-1);237 actual_payout = Inflation::block_inflation();238 assert_eq!(actual_payout, payout_by_year[year as usize]);239 }240 });241 }242}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.rsdiffbeforeafterboth--- a/pallets/nft/src/tests.rs
+++ b/pallets/nft/src/tests.rs
@@ -1,9 +1,14 @@
// Tests to be written here
use super::*;
use crate::mock::*;
-use crate::{AccessMode, CollectionMode,
- Ownership, ChainLimits, CreateItemData, CreateNftData, CreateFungibleData, CreateReFungibleData,
- CollectionId, TokenId, MAX_DECIMAL_POINTS};
+use crate::{
+ AccessMode, CollectionMode,
+ Ownership, ChainLimits, CreateItemData,
+};
+use nft_data_structs::{
+ CreateNftData, CreateFungibleData, CreateReFungibleData,
+ CollectionId, TokenId, MAX_DECIMAL_POINTS,
+};
use frame_support::{assert_noop, assert_ok};
use frame_system::{ RawOrigin };
@@ -72,12 +77,16 @@
assert_ok!(TemplateModule::create_item(
origin1.clone(),
collection_id,
- 1,
+ account(1),
data.clone()
));
}
+fn account(sub: u64) -> TestCrossAccountId {
+ TestCrossAccountId::from_sub(sub)
+}
+
// Use cases tests region
// #region
@@ -142,8 +151,8 @@
assert_ok!(TemplateModule::create_multiple_items(
origin1.clone(),
- 1,
1,
+ account(1),
items_data.clone().into_iter().map(|d| { d.into() }).collect()
));
for (index, data) in items_data.iter().enumerate() {
@@ -174,7 +183,7 @@
assert_eq!(
item.owner[0],
Ownership {
- owner: 1,
+ owner: account(1),
fraction: 1023
}
);
@@ -195,7 +204,7 @@
assert_ok!(TemplateModule::create_multiple_items(
origin1.clone(),
1,
- 1,
+ account(1),
items_data.clone().into_iter().map(|d| { d.into() }).collect()
));
for (index, data) in items_data.iter().enumerate() {
@@ -206,7 +215,7 @@
assert_eq!(
item.owner[0],
Ownership {
- owner: 1,
+ owner: account(1),
fraction: 1023
}
);
@@ -271,18 +280,18 @@
assert_eq!(TemplateModule::balance_count(1, 1), 5);
// change owner scenario
- assert_ok!(TemplateModule::transfer(origin1.clone(), 2, 1, 1, 5));
+ assert_ok!(TemplateModule::transfer(origin1.clone(), account(2), 1, 1, 5));
assert_eq!(TemplateModule::fungible_item_id(1, 1).value, 0);
assert_eq!(TemplateModule::balance_count(1, 1), 0);
assert_eq!(TemplateModule::balance_count(1, 2), 5);
// split item scenario
- assert_ok!(TemplateModule::transfer(origin2.clone(), 3, 1, 1, 3));
+ assert_ok!(TemplateModule::transfer(origin2.clone(), account(3), 1, 1, 3));
assert_eq!(TemplateModule::balance_count(1, 2), 2);
assert_eq!(TemplateModule::balance_count(1, 3), 3);
// split item and new owner has account scenario
- assert_ok!(TemplateModule::transfer(origin2.clone(), 3, 1, 1, 1));
+ assert_ok!(TemplateModule::transfer(origin2.clone(), account(3), 1, 1, 1));
assert_eq!(TemplateModule::fungible_item_id(1, 2).value, 1);
assert_eq!(TemplateModule::fungible_item_id(1, 3).value, 4);
assert_eq!(TemplateModule::balance_count(1, 2), 1);
@@ -315,7 +324,7 @@
assert_eq!(
item.owner[0],
Ownership {
- owner: 1,
+ owner: account(1),
fraction: 1023
}
);
@@ -324,11 +333,11 @@
assert_eq!(TemplateModule::address_tokens(1, 1), [1]);
// change owner scenario
- assert_ok!(TemplateModule::transfer(origin1.clone(), 2, 1, 1, 1023));
+ assert_ok!(TemplateModule::transfer(origin1.clone(), account(2), 1, 1, 1023));
assert_eq!(
TemplateModule::refungible_item_id(1, 1).unwrap().owner[0],
Ownership {
- owner: 2,
+ owner: account(2),
fraction: 1023
}
);
@@ -338,20 +347,20 @@
assert_eq!(TemplateModule::address_tokens(1, 2), [1]);
// split item scenario
- assert_ok!(TemplateModule::transfer(origin2.clone(), 3, 1, 1, 500));
+ assert_ok!(TemplateModule::transfer(origin2.clone(), account(3), 1, 1, 500));
{
let item = TemplateModule::refungible_item_id(1, 1).unwrap();
assert_eq!(
item.owner[0],
Ownership {
- owner: 2,
+ owner: account(2),
fraction: 523
}
);
assert_eq!(
item.owner[1],
Ownership {
- owner: 3,
+ owner: account(3),
fraction: 500
}
);
@@ -362,20 +371,20 @@
assert_eq!(TemplateModule::address_tokens(1, 3), [1]);
// split item and new owner has account scenario
- assert_ok!(TemplateModule::transfer(origin2.clone(), 3, 1, 1, 200));
+ assert_ok!(TemplateModule::transfer(origin2.clone(), account(3), 1, 1, 200));
{
let item = TemplateModule::refungible_item_id(1, 1).unwrap();
assert_eq!(
item.owner[0],
Ownership {
- owner: 2,
+ owner: account(2),
fraction: 323
}
);
assert_eq!(
item.owner[1],
Ownership {
- owner: 3,
+ owner: account(3),
fraction: 700
}
);
@@ -401,8 +410,8 @@
let origin1 = Origin::signed(1);
// default scenario
- assert_ok!(TemplateModule::transfer(origin1.clone(), 2, 1, 1, 1000));
- assert_eq!(TemplateModule::nft_item_id(1, 1).unwrap().owner, 2);
+ assert_ok!(TemplateModule::transfer(origin1.clone(), account(2), 1, 1, 1000));
+ assert_eq!(TemplateModule::nft_item_id(1, 1).unwrap().owner, account(2));
assert_eq!(TemplateModule::balance_count(1, 1), 0);
assert_eq!(TemplateModule::balance_count(1, 2), 1);
// assert_eq!(TemplateModule::address_tokens(1, 1), []);
@@ -429,14 +438,14 @@
// neg transfer
assert_noop!(TemplateModule::transfer_from(
origin2.clone(),
- 1,
- 2,
+ account(1),
+ account(2),
1,
1,
1), Error::<Test>::NoPermission);
// do approve
- assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 5));
+ assert_ok!(TemplateModule::approve(origin1.clone(), account(2), 1, 1, 5));
assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 5);
assert_eq!(
TemplateModule::approved(1, (1, 1, 2)),
@@ -445,8 +454,8 @@
assert_ok!(TemplateModule::transfer_from(
origin2.clone(),
- 1,
- 3,
+ account(1),
+ account(3),
1,
1,
1
@@ -482,20 +491,20 @@
1,
AccessMode::WhiteList
));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 1));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 2));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 3));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(2)));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(3)));
// do approve
- assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 5));
+ assert_ok!(TemplateModule::approve(origin1.clone(), account(2), 1, 1, 5));
assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 5);
- assert_ok!(TemplateModule::approve(origin1.clone(), 3, 1, 1, 5));
+ assert_ok!(TemplateModule::approve(origin1.clone(), account(3), 1, 1, 5));
assert_eq!(TemplateModule::approved(1, (1, 1, 3)), 5);
assert_ok!(TemplateModule::transfer_from(
origin2.clone(),
- 1,
- 3,
+ account(1),
+ account(3),
1,
1,
1
@@ -530,18 +539,18 @@
1,
AccessMode::WhiteList
));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 1));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 2));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 3));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(2)));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(3)));
// do approve
- assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 1023));
+ assert_ok!(TemplateModule::approve(origin1.clone(), account(2), 1, 1, 1023));
assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 1023);
assert_ok!(TemplateModule::transfer_from(
origin2.clone(),
- 1,
- 3,
+ account(1),
+ account(3),
1,
1,
100
@@ -583,14 +592,14 @@
1,
AccessMode::WhiteList
));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 1));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 2));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 3));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(2)));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(3)));
// do approve
- assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 5));
+ assert_ok!(TemplateModule::approve(origin1.clone(), account(2), 1, 1, 5));
assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 5);
- assert_ok!(TemplateModule::approve(origin1.clone(), 3, 1, 1, 5));
+ assert_ok!(TemplateModule::approve(origin1.clone(), account(3), 1, 1, 5));
assert_eq!(TemplateModule::approved(1, (1, 1, 3)), 5);
assert_eq!(
TemplateModule::approved(1, (1, 1, 2)),
@@ -599,9 +608,9 @@
assert_ok!(TemplateModule::transfer_from(
origin2.clone(),
+ account(1),
+ account(3),
1,
- 3,
- 1,
1,
4
));
@@ -612,9 +621,9 @@
assert_noop!(TemplateModule::transfer_from(
origin2.clone(),
+ account(1),
+ account(3),
1,
- 3,
- 1,
1,
4
), Error::<Test>::NoPermission);
@@ -658,7 +667,7 @@
let collection_id = create_test_collection(&CollectionMode::NFT, 1);
let origin1 = Origin::signed(1);
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));
let data = default_nft_data();
create_test_item(collection_id, &data.into());
@@ -685,7 +694,7 @@
let collection_id = create_test_collection(&CollectionMode::Fungible(3), 1);
let origin1 = Origin::signed(1);
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));
let data = default_fungible_data();
create_test_item(collection_id, &data.into());
@@ -722,9 +731,9 @@
collection_id,
AccessMode::WhiteList
));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 1));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), 1, 2));
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), 1, account(2)));
let data = default_re_fungible_data();
create_test_item(collection_id, &data.into());
@@ -755,11 +764,11 @@
let origin1 = Origin::signed(1);
// collection admin
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection1_id, 2));
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection1_id, 3));
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection1_id, account(2)));
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection1_id, account(3)));
- assert_eq!(TemplateModule::admin_list_collection(collection1_id).contains(&2), true);
- assert_eq!(TemplateModule::admin_list_collection(collection1_id).contains(&3), true);
+ assert_eq!(TemplateModule::admin_list_collection(collection1_id).contains(&account(2)), true);
+ assert_eq!(TemplateModule::admin_list_collection(collection1_id).contains(&account(3)), true);
});
}
@@ -776,19 +785,19 @@
let origin2 = Origin::signed(2);
// collection admin
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection1_id, 2));
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection1_id, 3));
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection1_id, account(2)));
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection1_id, account(3)));
- assert_eq!(TemplateModule::admin_list_collection(1).contains(&2), true);
- assert_eq!(TemplateModule::admin_list_collection(1).contains(&3), true);
+ assert_eq!(TemplateModule::admin_list_collection(1).contains(&account(2)), true);
+ assert_eq!(TemplateModule::admin_list_collection(1).contains(&account(3)), true);
// remove admin
assert_ok!(TemplateModule::remove_collection_admin(
origin2.clone(),
1,
- 3
+ account(3)
));
- assert_eq!(TemplateModule::admin_list_collection(1).contains(&3), false);
+ assert_eq!(TemplateModule::admin_list_collection(1).contains(&account(3)), false);
});
}
@@ -819,9 +828,9 @@
assert_eq!(TemplateModule::balance_count(nft_collection_id, 1), 1);
assert_eq!(TemplateModule::balance_count(fungible_collection_id, 1), 5);
assert_eq!(TemplateModule::balance_count(re_fungible_collection_id, 1), 1023);
- assert_eq!(TemplateModule::nft_item_id(nft_collection_id, 1).unwrap().owner, 1);
+ assert_eq!(TemplateModule::nft_item_id(nft_collection_id, 1).unwrap().owner, account(1));
assert_eq!(TemplateModule::fungible_item_id(fungible_collection_id, 1).value, 5);
- assert_eq!(TemplateModule::refungible_item_id(re_fungible_collection_id, 1).unwrap().owner[0].owner, 1);
+ assert_eq!(TemplateModule::refungible_item_id(re_fungible_collection_id, 1).unwrap().owner[0].owner, account(1));
});
}
@@ -838,7 +847,7 @@
let origin1 = Origin::signed(1);
// approve
- assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 1));
+ assert_ok!(TemplateModule::approve(origin1.clone(), account(2), 1, 1, 1));
assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 1);
});
}
@@ -856,7 +865,7 @@
create_test_item(collection_id, &data.into());
// approve
- assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 1));
+ assert_ok!(TemplateModule::approve(origin1.clone(), account(2), 1, 1, 1));
assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 1);
assert_ok!(TemplateModule::set_mint_permission(
@@ -869,14 +878,14 @@
1,
AccessMode::WhiteList
));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 1));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 2));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 3));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(2)));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(3)));
assert_ok!(TemplateModule::transfer_from(
origin2.clone(),
- 1,
- 2,
+ account(1),
+ account(2),
1,
1,
1
@@ -901,7 +910,7 @@
let collection_id = create_test_collection(&CollectionMode::NFT, 1);
let origin1 = Origin::signed(1);
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));
assert_eq!(TemplateModule::white_list(collection_id, 2), true);
});
}
@@ -915,8 +924,8 @@
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, 2));
- assert_ok!(TemplateModule::add_to_white_list(origin2.clone(), collection_id, 3));
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));
+ assert_ok!(TemplateModule::add_to_white_list(origin2.clone(), collection_id, account(3)));
assert_eq!(TemplateModule::white_list(collection_id, 3), true);
});
}
@@ -930,7 +939,7 @@
let origin2 = Origin::signed(2);
assert_noop!(
- TemplateModule::add_to_white_list(origin2.clone(), collection_id, 3),
+ TemplateModule::add_to_white_list(origin2.clone(), collection_id, account(3)),
Error::<Test>::NoPermission
);
});
@@ -944,7 +953,7 @@
let origin1 = Origin::signed(1);
assert_noop!(
- TemplateModule::add_to_white_list(origin1.clone(), 1, 2),
+ TemplateModule::add_to_white_list(origin1.clone(), 1, account(2)),
Error::<Test>::CollectionNotFound
);
});
@@ -960,7 +969,7 @@
let origin1 = Origin::signed(1);
assert_ok!(TemplateModule::destroy_collection(origin1.clone(), collection_id));
assert_noop!(
- TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2),
+ TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)),
Error::<Test>::CollectionNotFound
);
});
@@ -975,8 +984,8 @@
let collection_id = create_test_collection(&CollectionMode::NFT, 1);
let origin1 = Origin::signed(1);
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));
assert_eq!(TemplateModule::white_list(collection_id, 2), true);
});
}
@@ -989,11 +998,11 @@
let collection_id = create_test_collection(&CollectionMode::NFT, 1);
let origin1 = Origin::signed(1);
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));
assert_ok!(TemplateModule::remove_from_white_list(
origin1.clone(),
collection_id,
- 2
+ account(2)
));
assert_eq!(TemplateModule::white_list(collection_id, 2), false);
});
@@ -1008,13 +1017,13 @@
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 3));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(3)));
assert_ok!(TemplateModule::remove_from_white_list(
origin2.clone(),
collection_id,
- 3
+ account(3)
));
assert_eq!(TemplateModule::white_list(collection_id, 3), false);
});
@@ -1029,9 +1038,9 @@
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));
assert_noop!(
- TemplateModule::remove_from_white_list(origin2.clone(), collection_id, 2),
+ TemplateModule::remove_from_white_list(origin2.clone(), collection_id, account(2)),
Error::<Test>::NoPermission
);
assert_eq!(TemplateModule::white_list(collection_id, 2), true);
@@ -1045,7 +1054,7 @@
let origin1 = Origin::signed(1);
assert_noop!(
- TemplateModule::remove_from_white_list(origin1.clone(), 1, 2),
+ TemplateModule::remove_from_white_list(origin1.clone(), 1, account(2)),
Error::<Test>::CollectionNotFound
);
});
@@ -1060,10 +1069,10 @@
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));
assert_ok!(TemplateModule::destroy_collection(origin1.clone(), collection_id));
assert_noop!(
- TemplateModule::remove_from_white_list(origin2.clone(), collection_id, 2),
+ TemplateModule::remove_from_white_list(origin2.clone(), collection_id, account(2)),
Error::<Test>::CollectionNotFound
);
assert_eq!(TemplateModule::white_list(collection_id, 2), false);
@@ -1079,16 +1088,16 @@
let collection_id = create_test_collection(&CollectionMode::NFT, 1);
let origin1 = Origin::signed(1);
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));
assert_ok!(TemplateModule::remove_from_white_list(
origin1.clone(),
collection_id,
- 2
+ account(2)
));
assert_ok!(TemplateModule::remove_from_white_list(
origin1.clone(),
collection_id,
- 2
+ account(2)
));
assert_eq!(TemplateModule::white_list(collection_id, 2), false);
});
@@ -1112,10 +1121,10 @@
collection_id,
AccessMode::WhiteList
));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));
assert_noop!(
- TemplateModule::transfer(origin1.clone(), 3, 1, 1, 1),
+ TemplateModule::transfer(origin1.clone(), account(3), 1, 1, 1),
Error::<Test>::AddresNotInWhiteList
);
});
@@ -1137,21 +1146,21 @@
collection_id,
AccessMode::WhiteList
));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 1));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 2));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(2)));
// do approve
- assert_ok!(TemplateModule::approve(origin1.clone(), 1, 1, 1, 1));
+ assert_ok!(TemplateModule::approve(origin1.clone(), account(1), 1, 1, 1));
assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);
assert_ok!(TemplateModule::remove_from_white_list(
origin1.clone(),
1,
- 1
+ account(1)
));
assert_noop!(
- TemplateModule::transfer_from(origin1.clone(), 1, 3, 1, 1, 1),
+ TemplateModule::transfer_from(origin1.clone(), account(1), account(3), 1, 1, 1),
Error::<Test>::AddresNotInWhiteList
);
});
@@ -1175,10 +1184,10 @@
collection_id,
AccessMode::WhiteList
));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 1));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, account(1)));
assert_noop!(
- TemplateModule::transfer(origin1.clone(), 3, 1, 1, 1),
+ TemplateModule::transfer(origin1.clone(), account(3), 1, 1, 1),
Error::<Test>::AddresNotInWhiteList
);
});
@@ -1201,21 +1210,21 @@
collection_id,
AccessMode::WhiteList
));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 1));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(1)));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));
// do approve
- assert_ok!(TemplateModule::approve(origin1.clone(), 1, 1, 1, 1));
+ assert_ok!(TemplateModule::approve(origin1.clone(), account(1), 1, 1, 1));
assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);
assert_ok!(TemplateModule::remove_from_white_list(
origin1.clone(),
collection_id,
- 2
+ account(2)
));
assert_noop!(
- TemplateModule::transfer_from(origin1.clone(), 1, 3, 1, 1, 1),
+ TemplateModule::transfer_from(origin1.clone(), account(1), account(3), 1, 1, 1),
Error::<Test>::AddresNotInWhiteList
);
});
@@ -1267,7 +1276,7 @@
// do approve
assert_noop!(
- TemplateModule::approve(origin1.clone(), 1, 1, 1, 5),
+ TemplateModule::approve(origin1.clone(), account(1), 1, 1, 5),
Error::<Test>::AddresNotInWhiteList
);
});
@@ -1292,10 +1301,10 @@
collection_id,
AccessMode::WhiteList
));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 1));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(1)));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));
- assert_ok!(TemplateModule::transfer(origin1.clone(), 2, 1, 1, 1));
+ assert_ok!(TemplateModule::transfer(origin1.clone(), account(2), 1, 1, 1));
});
}
@@ -1316,17 +1325,17 @@
collection_id,
AccessMode::WhiteList
));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 1));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(1)));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));
// do approve
- assert_ok!(TemplateModule::approve(origin1.clone(), 1, 1, 1, 5));
+ assert_ok!(TemplateModule::approve(origin1.clone(), account(1), 1, 1, 5));
assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 5);
assert_ok!(TemplateModule::transfer_from(
origin1.clone(),
- 1,
- 2,
+ account(1),
+ account(2),
1,
1,
1
@@ -1381,12 +1390,12 @@
false
));
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));
assert_ok!(TemplateModule::create_item(
origin2.clone(),
collection_id,
- 2,
+ account(2),
default_nft_data().into()
));
});
@@ -1413,10 +1422,10 @@
collection_id,
false
));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));
assert_noop!(
- TemplateModule::create_item(origin2.clone(), 1, 2, default_nft_data().into()),
+ TemplateModule::create_item(origin2.clone(), 1, account(2), default_nft_data().into()),
Error::<Test>::PublicMintingNotAllowed
);
});
@@ -1445,7 +1454,7 @@
));
assert_noop!(
- TemplateModule::create_item(origin2.clone(), 1, 2, default_nft_data().into()),
+ TemplateModule::create_item(origin2.clone(), 1, account(2), default_nft_data().into()),
Error::<Test>::PublicMintingNotAllowed
);
});
@@ -1499,12 +1508,12 @@
true
));
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));
assert_ok!(TemplateModule::create_item(
origin2.clone(),
1,
- 2,
+ account(2),
default_nft_data().into()
));
});
@@ -1533,7 +1542,7 @@
));
assert_noop!(
- TemplateModule::create_item(origin2.clone(), 1, 2, default_nft_data().into()),
+ TemplateModule::create_item(origin2.clone(), 1, account(2), default_nft_data().into()),
Error::<Test>::AddresNotInWhiteList
);
});
@@ -1560,12 +1569,12 @@
collection_id,
true
));
- assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
+ assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, account(2)));
assert_ok!(TemplateModule::create_item(
origin2.clone(),
1,
- 2,
+ account(2),
default_nft_data().into()
));
});
@@ -1648,7 +1657,7 @@
assert_noop!(TemplateModule::create_item(
origin1.clone(),
1,
- 1,
+ account(1),
data.into()
), Error::<Test>::AddressOwnershipLimitExceeded);
});
@@ -1675,8 +1684,8 @@
let origin1 = Origin::signed(1);
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, 2));
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, 3));
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(3)));
});
}
@@ -1701,8 +1710,8 @@
let origin1 = Origin::signed(1);
- assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, 2));
- assert_noop!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, 3), Error::<Test>::CollectionAdminsLimitExceeded);
+ assert_ok!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(2)));
+ assert_noop!(TemplateModule::add_collection_admin(origin1.clone(), collection_id, account(3)), Error::<Test>::CollectionAdminsLimitExceeded);
});
}
@@ -1734,7 +1743,7 @@
assert_noop!(TemplateModule::create_item(
origin1.clone(),
collection_id,
- 1,
+ account(1),
too_big_const_data
), Error::<Test>::TokenConstDataLimitExceeded);
});
@@ -1768,7 +1777,7 @@
assert_noop!(TemplateModule::create_item(
origin1.clone(),
collection_id,
- 1,
+ account(1),
too_big_const_data
), Error::<Test>::TokenVariableDataLimitExceeded);
});
@@ -1802,7 +1811,7 @@
assert_noop!(TemplateModule::create_item(
origin1.clone(),
collection_id,
- 1,
+ account(1),
too_big_const_data
), Error::<Test>::TokenConstDataLimitExceeded);
});
@@ -1836,7 +1845,7 @@
assert_noop!(TemplateModule::create_item(
origin1.clone(),
collection_id,
- 1,
+ account(1),
too_big_const_data
), Error::<Test>::TokenVariableDataLimitExceeded);
});
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>;