git.delta.rocks / unique-network / refs/commits / c3c95caf228f

difftreelog

test fix build

Yaroslav Bolyukin2023-10-09parent: #22a5178.patch.diff
in: master

9 files changed

modifiedpallets/collator-selection/src/mock.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/mock.rs
+++ b/pallets/collator-selection/src/mock.rs
@@ -32,23 +32,22 @@
 
 use frame_support::{
 	ord_parameter_types, parameter_types,
-	traits::{FindAuthor, GenesisBuild, ValidatorRegistration},
+	traits::{ConstU32, FindAuthor, ValidatorRegistration},
 	PalletId,
 };
 use frame_system as system;
 use frame_system::EnsureSignedBy;
-use sp_core::H256;
+use sp_core::{ConstBool, H256};
 use sp_runtime::{
-	testing::{Header, UintAuthorityId},
+	testing::UintAuthorityId,
 	traits::{BlakeTwo256, IdentityLookup, OpaqueKeys},
-	Perbill, RuntimeAppPublic,
+	BuildStorage, Perbill, RuntimeAppPublic,
 };
 
 use super::*;
 use crate as collator_selection;
 
-type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
-type Block = frame_system::mocking::MockBlock<Test>;
+type Block = frame_system::mocking::MockBlockU32<Test>;
 
 // Configure a mock runtime to test the pallet.
 frame_support::construct_runtime!(
@@ -64,12 +63,13 @@
 );
 
 parameter_types! {
-	pub const BlockHashCount: u64 = 250;
+	pub const BlockHashCount: u32 = 250;
 	pub const SS58Prefix: u8 = 42;
 }
 
 impl system::Config for Test {
 	type BaseCallFilter = frame_support::traits::Everything;
+	type Block = Block;
 	type BlockWeights = ();
 	type BlockLength = ();
 	type DbWeight = ();
@@ -90,7 +90,7 @@
 	type SystemWeightInfo = ();
 	type SS58Prefix = SS58Prefix;
 	type OnSetCode = ();
-	type MaxConsumers = frame_support::traits::ConstU32<16>;
+	type MaxConsumers = ConstU32<16>;
 }
 
 parameter_types! {
@@ -113,6 +113,7 @@
 	type FreezeIdentifier = [u8; 16];
 	type MaxHolds = MaxHolds;
 	type MaxFreezes = MaxFreezes;
+	type RuntimeHoldReason = RuntimeHoldReason;
 }
 
 pub struct Author4;
@@ -145,6 +146,7 @@
 	type AuthorityId = sp_consensus_aura::sr25519::AuthorityId;
 	type MaxAuthorities = MaxAuthorities;
 	type DisabledValidators = ();
+	type AllowMultipleBlocksPerSlot = ConstBool<true>;
 }
 
 sp_runtime::impl_opaque_keys! {
@@ -162,27 +164,27 @@
 
 parameter_types! {
 	pub static SessionHandlerCollators: Vec<u64> = Vec::new();
-	pub static SessionChangeBlock: u64 = 0;
+	pub static SessionChangeBlock: u32 = 0;
 }
 
 pub struct TestSessionHandler;
 impl pallet_session::SessionHandler<u64> for TestSessionHandler {
 	const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[UintAuthorityId::ID];
 	fn on_genesis_session<Ks: OpaqueKeys>(keys: &[(u64, Ks)]) {
-		SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())
+		SessionHandlerCollators::set(keys.iter().map(|(a, _)| *a).collect::<Vec<_>>())
 	}
 	fn on_new_session<Ks: OpaqueKeys>(_: bool, keys: &[(u64, Ks)], _: &[(u64, Ks)]) {
 		SessionChangeBlock::set(System::block_number());
 		dbg!(keys.len());
-		SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())
+		SessionHandlerCollators::set(keys.iter().map(|(a, _)| *a).collect::<Vec<_>>())
 	}
 	fn on_before_session_ending() {}
 	fn on_disabled(_: u32) {}
 }
 
 parameter_types! {
-	pub const Offset: u64 = 0;
-	pub const Period: u64 = 10;
+	pub const Offset: u32 = 0;
+	pub const Period: u32 = 10;
 }
 
 impl pallet_session::Config for Test {
@@ -201,7 +203,7 @@
 parameter_types! {
 	pub const MaxCollators: u32 = 5;
 	pub const LicenseBond: u64 = 10;
-	pub const KickThreshold: u64 = 10;
+	pub const KickThreshold: u32 = 10;
 	// the following values do not matter and are meaningless, etc.
 	pub const DefaultWeightToFeeCoefficient: u64 = 100_000;
 	pub const DefaultMinGasPrice: u64 = 100_000;
@@ -230,6 +232,7 @@
 
 impl Config for Test {
 	type RuntimeEvent = RuntimeEvent;
+	type RuntimeHoldReason = RuntimeHoldReason;
 	type UpdateOrigin = EnsureSignedBy<RootAccount, u64>;
 	type PotId = PotId;
 	type MaxCollators = MaxCollators;
@@ -238,7 +241,6 @@
 	type ValidatorId = <Self as frame_system::Config>::AccountId;
 	type ValidatorIdOf = IdentityCollator;
 	type ValidatorRegistration = IsRegistered;
-	type LicenceBondIdentifier = LicenceBondIdentifier;
 	type Currency = Balances;
 	type DesiredCollators = MaxCollators;
 	type LicenseBond = LicenseBond;
@@ -248,8 +250,8 @@
 
 pub fn new_test_ext() -> sp_io::TestExternalities {
 	sp_tracing::try_init_simple();
-	let mut t = frame_system::GenesisConfig::default()
-		.build_storage::<Test>()
+	let mut t = <frame_system::GenesisConfig<Test>>::default()
+		.build_storage()
 		.unwrap();
 	let invulnerables = vec![1, 2];
 
@@ -284,9 +286,9 @@
 	t.into()
 }
 
-pub fn initialize_to_block(n: u64) {
+pub fn initialize_to_block(n: u32) {
 	for i in System::block_number() + 1..=n {
 		System::set_block_number(i);
-		<AllPalletsWithSystem as frame_support::traits::OnInitialize<u64>>::on_initialize(i);
+		<AllPalletsWithSystem as frame_support::traits::OnInitialize<u32>>::on_initialize(i);
 	}
 }
modifiedpallets/collator-selection/src/tests.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/tests.rs
+++ b/pallets/collator-selection/src/tests.rs
@@ -32,10 +32,10 @@
 
 use frame_support::{
 	assert_noop, assert_ok,
-	traits::{fungible, GenesisBuild, OnInitialize},
+	traits::{fungible, OnInitialize},
 };
 use scale_info::prelude::*;
-use sp_runtime::{traits::BadOrigin, TokenError};
+use sp_runtime::{traits::BadOrigin, BuildStorage, TokenError};
 
 use crate::{self as collator_selection, mock::*, Config, Error};
 
@@ -464,8 +464,8 @@
 #[should_panic = "duplicate invulnerables in genesis."]
 fn cannot_set_genesis_value_twice() {
 	sp_tracing::try_init_simple();
-	let mut t = frame_system::GenesisConfig::default()
-		.build_storage::<Test>()
+	let mut t = <frame_system::GenesisConfig<Test>>::default()
+		.build_storage()
 		.unwrap();
 	let invulnerables = vec![1, 1];
 
modifiedpallets/identity/src/tests.rsdiffbeforeafterboth
--- a/pallets/identity/src/tests.rs
+++ b/pallets/identity/src/tests.rs
@@ -43,7 +43,6 @@
 use parity_scale_codec::{Decode, Encode};
 use sp_core::H256;
 use sp_runtime::{
-	testing::Header,
 	traits::{BadOrigin, BlakeTwo256, IdentityLookup},
 	BuildStorage,
 };
@@ -51,8 +50,7 @@
 use super::*;
 use crate as pallet_identity;
 
-type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
-type Block = frame_system::mocking::MockBlock<Test>;
+type Block = frame_system::mocking::MockBlockU32<Test>;
 
 frame_support::construct_runtime!(
 	pub enum Test {
@@ -79,7 +77,7 @@
 	type AccountId = u64;
 	type Lookup = IdentityLookup<Self::AccountId>;
 	type RuntimeEvent = RuntimeEvent;
-	type BlockHashCount = ConstU64<250>;
+	type BlockHashCount = ConstU32<250>;
 	type DbWeight = ();
 	type Version = ();
 	type PalletInfo = PalletInfo;
modifiedpallets/inflation/src/tests.rsdiffbeforeafterboth
--- a/pallets/inflation/src/tests.rs
+++ b/pallets/inflation/src/tests.rs
@@ -34,12 +34,12 @@
 
 use crate as pallet_inflation;
 
-type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
-type Block = frame_system::mocking::MockBlock<Test>;
+type Block = frame_system::mocking::MockBlockU32<Test>;
 
-const YEAR: u64 = 5_259_600; // 6-second blocks
-							 // const YEAR: u64 = 2_629_800; // 12-second blocks
-							 // Expected 100-block inflation for year 1 is 100 * 100_000_000 / YEAR = FIRST_YEAR_BLOCK_INFLATION
+// 6-second blocks
+// const YEAR: u32 = 2_629_800; // 12-second blocks
+// Expected 100-block inflation for year 1 is 100 * 100_000_000 / YEAR = FIRST_YEAR_BLOCK_INFLATION
+const YEAR: u32 = 5_259_600;
 const FIRST_YEAR_BLOCK_INFLATION: u64 = 1901;
 
 parameter_types! {
@@ -60,6 +60,7 @@
 	type FreezeIdentifier = ();
 	type MaxHolds = ();
 	type MaxFreezes = ();
+	type RuntimeHoldReason = RuntimeHoldReason;
 }
 
 frame_support::construct_runtime!(
@@ -71,7 +72,7 @@
 );
 
 parameter_types! {
-	pub const BlockHashCount: u64 = 250;
+	pub const BlockHashCount: u32 = 250;
 	pub BlockWeights: frame_system::limits::BlockWeights =
 		frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, 0));
 	pub const SS58Prefix: u8 = 42;
@@ -79,6 +80,7 @@
 
 impl frame_system::Config for Test {
 	type BaseCallFilter = Everything;
+	type Block = Block;
 	type BlockWeights = ();
 	type BlockLength = ();
 	type DbWeight = ();
@@ -187,7 +189,7 @@
 fn inflation_second_deposit() {
 	new_test_ext().execute_with(|| {
 		// Total issuance = 1_000_000_000
-		let initial_issuance: u64 = 1_000_000_000;
+		let initial_issuance = 1_000_000_000;
 		let _ = <Balances as Balanced<_>>::deposit(&1234, initial_issuance, Precision::Exact);
 		assert_eq!(Balances::free_balance(1234), initial_issuance);
 		MockBlockNumberProvider::set(1);
@@ -196,20 +198,20 @@
 		assert_ok!(Inflation::start_inflation(RawOrigin::Root.into(), 1));
 
 		// Next inflation deposit happens when block is greater then or equal to NextInflationBlock
-		let mut block: u64 = 2;
-		let balance_before: u64 = Balances::free_balance(1234);
+		let mut block = 2;
+		let balance_before = Balances::free_balance(1234);
 		while block < <pallet_inflation::NextInflationBlock<Test>>::get() {
-			MockBlockNumberProvider::set(block as u64);
+			MockBlockNumberProvider::set(block);
 			Inflation::on_initialize(0);
 			block += 1;
 		}
-		let balance_just_before: u64 = Balances::free_balance(1234);
+		let balance_just_before = Balances::free_balance(1234);
 		assert_eq!(balance_before, balance_just_before);
 
 		// The block with inflation
-		MockBlockNumberProvider::set(block as u64);
+		MockBlockNumberProvider::set(block);
 		Inflation::on_initialize(0);
-		let balance_after: u64 = Balances::free_balance(1234);
+		let balance_after = Balances::free_balance(1234);
 		assert_eq!(balance_after - balance_just_before, block_inflation!());
 	});
 }
@@ -234,7 +236,7 @@
 			Inflation::on_initialize(0);
 		}
 		assert_eq!(
-			initial_issuance + (FIRST_YEAR_BLOCK_INFLATION * (YEAR / 100)),
+			initial_issuance + (FIRST_YEAR_BLOCK_INFLATION * ((YEAR as u64) / 100)),
 			<Balances as Inspect<_>>::total_issuance()
 		);
 
@@ -243,8 +245,8 @@
 		let block_inflation_year_2 = block_inflation!();
 		// Expected 100-block inflation for year 2: 100 * 9.33% * initial issuance * 110% / YEAR == 1951
 		let expecter_year_2_inflation: u64 = (initial_issuance
-			+ FIRST_YEAR_BLOCK_INFLATION * YEAR / 100)
-			* 933 * 100 / (10000 * YEAR);
+			+ FIRST_YEAR_BLOCK_INFLATION * (YEAR as u64) / 100)
+			* 933 * 100 / (10000 * (YEAR as u64));
 		assert_eq!(block_inflation_year_2 / 10, expecter_year_2_inflation / 10); // divide by 10 for approx. equality
 	});
 }
@@ -253,8 +255,8 @@
 fn inflation_start_large_kusama_block() {
 	new_test_ext().execute_with(|| {
 		// Total issuance = 1_000_000_000
-		let initial_issuance: u64 = 1_000_000_000;
-		let start_block: u64 = 10457457;
+		let initial_issuance = 1_000_000_000;
+		let start_block = 10457457;
 		let _ = <Balances as Balanced<_>>::deposit(&1234, initial_issuance, Precision::Exact);
 		assert_eq!(Balances::free_balance(1234), initial_issuance);
 		MockBlockNumberProvider::set(start_block);
@@ -273,7 +275,7 @@
 			Inflation::on_initialize(0);
 		}
 		assert_eq!(
-			initial_issuance + (FIRST_YEAR_BLOCK_INFLATION * (YEAR / 100)),
+			initial_issuance + (FIRST_YEAR_BLOCK_INFLATION * ((YEAR as u64) / 100)),
 			<Balances as Inspect<_>>::total_issuance()
 		);
 
@@ -282,8 +284,8 @@
 		let block_inflation_year_2 = block_inflation!();
 		// Expected 100-block inflation for year 2: 100 * 9.33% * initial issuance * 110% / YEAR == 1951
 		let expecter_year_2_inflation: u64 = (initial_issuance
-			+ FIRST_YEAR_BLOCK_INFLATION * YEAR / 100)
-			* 933 * 100 / (10000 * YEAR);
+			+ FIRST_YEAR_BLOCK_INFLATION * (YEAR as u64) / 100)
+			* 933 * 100 / (10000 * (YEAR as u64));
 		assert_eq!(block_inflation_year_2 / 10, expecter_year_2_inflation / 10); // divide by 10 for approx. equality
 	});
 }
@@ -320,14 +322,14 @@
 #[test]
 fn inflation_rate_by_year() {
 	new_test_ext().execute_with(|| {
-		let payouts: u64 = YEAR / InflationBlockInterval::get() as u64;
+		let payouts = (YEAR / InflationBlockInterval::get()) as u64;
 
 		// Inflation starts at 10% and does down by 2/3% every year until year 9 (included),
 		// then it is flat.
 		let payout_by_year: [u64; 11] = [1000, 933, 867, 800, 733, 667, 600, 533, 467, 400, 400];
 
 		// For accuracy total issuance = payout0 * payouts * 10;
-		let initial_issuance: u64 = payout_by_year[0] * payouts * 10;
+		let initial_issuance = payout_by_year[0] * payouts * 10;
 		let _ = <Balances as Balanced<_>>::deposit(&1234, initial_issuance, Precision::Exact);
 		assert_eq!(Balances::free_balance(1234), initial_issuance);
 
modifiedruntime/common/tests/mod.rsdiffbeforeafterboth
--- a/runtime/common/tests/mod.rs
+++ b/runtime/common/tests/mod.rs
@@ -19,7 +19,7 @@
 use sp_runtime::{BuildStorage, Storage};
 use up_common::types::AuraId;
 
-use crate::{BuildGenesisConfig, ParachainInfoConfig, Runtime, RuntimeEvent, System};
+use crate::{ParachainInfoConfig, Runtime, RuntimeEvent, RuntimeGenesisConfig, System};
 pub type Balance = u128;
 
 pub mod xcm;
@@ -51,8 +51,8 @@
 fn new_test_ext(balances: Vec<(AccountId, Balance)>) -> sp_io::TestExternalities {
 	let mut storage = make_basic_storage();
 
-	pallet_balances::BuildGenesisConfig::<Runtime> { balances }
-		.build_storage(&mut storage)
+	pallet_balances::GenesisConfig::<Runtime> { balances }
+		.assimilate_storage(&mut storage)
 		.unwrap();
 
 	let mut ext = sp_io::TestExternalities::new(storage);
@@ -95,7 +95,7 @@
 		.map(|acc| get_account_id_from_seed::<sr25519::Public>(acc))
 		.collect::<Vec<_>>();
 
-	let cfg = BuildGenesisConfig {
+	let cfg = RuntimeGenesisConfig {
 		collator_selection: CollatorSelectionConfig { invulnerables },
 		session: SessionConfig { keys },
 		parachain_info: ParachainInfoConfig {
@@ -112,7 +112,7 @@
 fn make_basic_storage() -> Storage {
 	use crate::AuraConfig;
 
-	let cfg = BuildGenesisConfig {
+	let cfg = RuntimeGenesisConfig {
 		aura: AuraConfig {
 			authorities: vec![
 				get_from_seed::<AuraId>("Alice"),
modifiedruntime/common/tests/xcm.rsdiffbeforeafterboth
--- a/runtime/common/tests/xcm.rs
+++ b/runtime/common/tests/xcm.rs
@@ -52,9 +52,9 @@
 
 		let xcm_event = &last_events(1)[0];
 		match xcm_event {
-			RuntimeEvent::PolkadotXcm(pallet_xcm::Event::<Runtime>::Attempted(
-				Outcome::Incomplete(_weight, Error::NoPermission),
-			)) => { /* Pass */ }
+			RuntimeEvent::PolkadotXcm(pallet_xcm::Event::<Runtime>::Attempted {
+				outcome: Outcome::Incomplete(_weight, Error::NoPermission),
+			}) => { /* Pass */ }
 			_ => panic!(
 				"Expected PolkadotXcm.Attempted(Incomplete(_weight, NoPermission)),\
 				found: {xcm_event:#?}"
addedruntime/tests/src/dispatch.rsdiffbeforeafterboth
--- /dev/null
+++ b/runtime/tests/src/dispatch.rs
@@ -0,0 +1 @@
+../../common/dispatch.rs
\ No newline at end of file
modifiedruntime/tests/src/lib.rsdiffbeforeafterboth
before · runtime/tests/src/lib.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![allow(clippy::from_over_into)]1819use frame_support::{20	pallet_prelude::Weight,21	parameter_types,22	traits::{fungible::Inspect, ConstU32, ConstU64, Everything},23	weights::IdentityFee,24};25use frame_system as system;26use pallet_ethereum::PostLogContent;27use pallet_evm::{28	account::CrossAccountId, AddressMapping, BackwardsAddressMapping, EnsureAddressNever,29	SubstrateBlockHashMapping,30};31use pallet_transaction_payment::CurrencyAdapter;32use parity_scale_codec::{Decode, Encode, MaxEncodedLen};33use scale_info::TypeInfo;34use sp_core::{H160, H256, U256};35use sp_runtime::{36	testing::Header,37	traits::{BlakeTwo256, IdentityLookup},38};39use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};4041#[path = "../../common/dispatch.rs"]42mod dispatch;4344use dispatch::CollectionDispatchT;4546#[path = "../../common/weights/mod.rs"]47mod weights;4849use weights::CommonWeights;5051type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;52type Block = frame_system::mocking::MockBlock<Test>;5354#[cfg(test)]55mod tests;5657// Configure a mock runtime to test the pallet.58frame_support::construct_runtime!(59	pub enum Test {60		System: frame_system,61		Timestamp: pallet_timestamp,62		Unique: pallet_unique,63		Balances: pallet_balances,64		Common: pallet_common,65		Fungible: pallet_fungible,66		Refungible: pallet_refungible,67		Nonfungible: pallet_nonfungible,68		Structure: pallet_structure,69		TransactionPayment: pallet_transaction_payment,70		Ethereum: pallet_ethereum,71		EVM: pallet_evm,72	}73);7475parameter_types! {76	pub const BlockHashCount: u64 = 250;77	pub const SS58Prefix: u8 = 42;78}7980impl system::Config for Test {81	type RuntimeEvent = RuntimeEvent;82	type BaseCallFilter = Everything;83	type BlockWeights = ();84	type BlockLength = ();85	type DbWeight = ();86	type RuntimeOrigin = RuntimeOrigin;87	type RuntimeCall = RuntimeCall;88	type Nonce = u64;89	type Hash = H256;90	type Hashing = BlakeTwo256;91	type AccountId = u64;92	type Lookup = IdentityLookup<Self::AccountId>;93	type BlockHashCount = BlockHashCount;94	type Version = ();95	type PalletInfo = PalletInfo;96	type AccountData = pallet_balances::AccountData<u64>;97	type OnNewAccount = ();98	type OnKilledAccount = ();99	type SystemWeightInfo = ();100	type SS58Prefix = SS58Prefix;101	type OnSetCode = ();102	type MaxConsumers = ConstU32<16>;103}104105parameter_types! {106	pub const ExistentialDeposit: u64 = 1;107	pub const MaxLocks: u32 = 50;108}109//frame_system::Module<Test>;110impl pallet_balances::Config for Test {111	type RuntimeEvent = RuntimeEvent;112	type AccountStore = System;113	type Balance = u64;114	type DustRemoval = ();115	type ExistentialDeposit = ExistentialDeposit;116	type WeightInfo = ();117	type MaxLocks = MaxLocks;118	type MaxReserves = ();119	type ReserveIdentifier = [u8; 8];120	type MaxFreezes = MaxLocks;121	type FreezeIdentifier = [u8; 8];122	type MaxHolds = MaxLocks;123}124125parameter_types! {126	pub const OperationalFeeMultiplier: u8 = 5;127}128129impl pallet_transaction_payment::Config for Test {130	type RuntimeEvent = RuntimeEvent;131	type OnChargeTransaction = CurrencyAdapter<pallet_balances::Pallet<Test>, ()>;132	type LengthToFee = IdentityFee<u64>;133	type WeightToFee = IdentityFee<u64>;134	type FeeMultiplierUpdate = ();135	type OperationalFeeMultiplier = OperationalFeeMultiplier;136}137138parameter_types! {139	pub const MinimumPeriod: u64 = 1;140}141impl pallet_timestamp::Config for Test {142	type Moment = u64;143	type OnTimestampSet = ();144	type MinimumPeriod = MinimumPeriod;145	type WeightInfo = ();146}147148parameter_types! {149	pub const CollectionCreationPrice: u32 = 100;150	pub TreasuryAccountId: u64 = 1234;151	pub EthereumChainId: u32 = 1111;152}153154pub struct TestEvmAddressMapping;155impl AddressMapping<u64> for TestEvmAddressMapping {156	fn into_account_id(_addr: sp_core::H160) -> u64 {157		unimplemented!()158	}159}160161pub struct TestEvmBackwardsAddressMapping;162impl BackwardsAddressMapping<u64> for TestEvmBackwardsAddressMapping {163	fn from_account_id(_account_id: u64) -> sp_core::H160 {164		unimplemented!()165	}166}167168#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo, MaxEncodedLen)]169pub struct TestCrossAccountId(u64, sp_core::H160, bool);170impl CrossAccountId<u64> for TestCrossAccountId {171	fn as_sub(&self) -> &u64 {172		&self.0173	}174	fn as_eth(&self) -> &sp_core::H160 {175		&self.1176	}177	fn from_sub(sub: u64) -> Self {178		let mut eth = [0; 20];179		eth[12..20].copy_from_slice(&sub.to_be_bytes());180		Self(sub, sp_core::H160(eth), true)181	}182	fn from_eth(eth: sp_core::H160) -> Self {183		let mut sub_raw = [0; 8];184		sub_raw.copy_from_slice(&eth.0[0..8]);185		let sub = u64::from_be_bytes(sub_raw);186		Self(sub, eth, false)187	}188	fn conv_eq(&self, other: &Self) -> bool {189		self.as_sub() == other.as_sub()190	}191	fn is_canonical_substrate(&self) -> bool {192		self.2193	}194}195196impl Default for TestCrossAccountId {197	fn default() -> Self {198		Self::from_sub(0)199	}200}201202parameter_types! {203	pub BlockGasLimit: U256 = 0u32.into();204	pub WeightPerGas: Weight = Weight::from_parts(20, 0);205	pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes;206}207208impl pallet_ethereum::Config for Test {209	type RuntimeEvent = RuntimeEvent;210	type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;211	type PostLogContent = PostBlockAndTxnHashes;212	type ExtraDataLength = ConstU32<32>;213}214215impl pallet_evm::Config for Test {216	type WeightInfo = pallet_evm::weights::SubstrateWeight<Self>;217	type CrossAccountId = TestCrossAccountId;218	type AddressMapping = TestEvmAddressMapping;219	type BackwardsAddressMapping = TestEvmBackwardsAddressMapping;220	type RuntimeEvent = RuntimeEvent;221	type FeeCalculator = ();222	type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;223	type WeightPerGas = WeightPerGas;224	type CallOrigin = EnsureAddressNever<Self>;225	type WithdrawOrigin = EnsureAddressNever<Self>;226	type Currency = Balances;227	type PrecompilesType = ();228	type PrecompilesValue = ();229	type Runner = pallet_evm::runner::stack::Runner<Self>;230	type ChainId = ConstU64<0>;231	type BlockGasLimit = BlockGasLimit;232	type OnMethodCall = ();233	type OnCreate = ();234	type OnChargeTransaction = ();235	type FindAuthor = ();236	type BlockHashMapping = SubstrateBlockHashMapping<Self>;237	type Timestamp = Timestamp;238	type GasLimitPovSizeRatio = ConstU64<0>;239}240impl pallet_evm_coder_substrate::Config for Test {}241242impl pallet_common::Config for Test {243	type WeightInfo = ();244	type RuntimeEvent = RuntimeEvent;245	type Currency = Balances;246	type CollectionCreationPrice = CollectionCreationPrice;247	type TreasuryAccountId = TreasuryAccountId;248249	type CollectionDispatch = CollectionDispatchT<Self>;250	type EvmTokenAddressMapping = EvmTokenAddressMapping;251	type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;252	type ContractAddress = EvmCollectionHelpersAddress;253}254255impl pallet_structure::Config for Test {256	type WeightInfo = ();257	type RuntimeEvent = RuntimeEvent;258	type RuntimeCall = RuntimeCall;259}260impl pallet_fungible::Config for Test {261	type WeightInfo = ();262}263impl pallet_refungible::Config for Test {264	type WeightInfo = ();265}266impl pallet_nonfungible::Config for Test {267	type WeightInfo = ();268}269parameter_types! {270	pub const Decimals: u8 = 18;271	pub Name: String = "Test".to_string();272	pub Symbol: String = "TST".to_string();273}274impl pallet_balances_adapter::Config for Test {275	type Inspect = Balances;276	type Mutate = Balances;277	type CurrencyBalance = <Balances as Inspect<Self::AccountId>>::Balance;278	type Decimals = Decimals;279	type Name = Name;280	type Symbol = Symbol;281	type WeightInfo = ();282}283284parameter_types! {285	// 0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f286	pub const EvmCollectionHelpersAddress: H160 = H160([287		0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,288	]);289}290291impl pallet_unique::Config for Test {292	type WeightInfo = ();293	type CommonWeightInfo = CommonWeights<Self>;294	type RefungibleExtensionsWeightInfo = CommonWeights<Self>;295}296297// Build genesis storage according to the mock runtime.298pub fn new_test_ext() -> sp_io::TestExternalities {299	system::GenesisConfig::default()300		.build_storage::<Test>()301		.unwrap()302		.into()303}
after · runtime/tests/src/lib.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![allow(clippy::from_over_into)]1819use frame_support::{20	pallet_prelude::Weight,21	parameter_types,22	traits::{fungible::Inspect, ConstU32, ConstU64, Everything},23	weights::IdentityFee,24};25use frame_system as system;26use pallet_ethereum::PostLogContent;27use pallet_evm::{28	account::CrossAccountId, AddressMapping, BackwardsAddressMapping, EnsureAddressNever,29	SubstrateBlockHashMapping,30};31use pallet_transaction_payment::CurrencyAdapter;32use parity_scale_codec::{Decode, Encode, MaxEncodedLen};33use scale_info::TypeInfo;34use sp_core::{H160, H256, U256};35use sp_runtime::{36	traits::{BlakeTwo256, IdentityLookup},37	BuildStorage,38};39use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};4041mod dispatch;4243use dispatch::CollectionDispatchT;4445mod weights;4647use weights::CommonWeights;4849type Block = frame_system::mocking::MockBlockU32<Test>;5051#[cfg(test)]52mod tests;5354// Configure a mock runtime to test the pallet.55frame_support::construct_runtime!(56	pub enum Test {57		System: frame_system,58		Timestamp: pallet_timestamp,59		Unique: pallet_unique,60		Balances: pallet_balances,61		Common: pallet_common,62		Fungible: pallet_fungible,63		Refungible: pallet_refungible,64		Nonfungible: pallet_nonfungible,65		Structure: pallet_structure,66		TransactionPayment: pallet_transaction_payment,67		Ethereum: pallet_ethereum,68		EVM: pallet_evm,69	}70);7172parameter_types! {73	pub const BlockHashCount: u32 = 250;74	pub const SS58Prefix: u8 = 42;75}7677impl system::Config for Test {78	type RuntimeEvent = RuntimeEvent;79	type BaseCallFilter = Everything;80	type Block = Block;81	type BlockWeights = ();82	type BlockLength = ();83	type DbWeight = ();84	type RuntimeOrigin = RuntimeOrigin;85	type RuntimeCall = RuntimeCall;86	type Nonce = u64;87	type Hash = H256;88	type Hashing = BlakeTwo256;89	type AccountId = u64;90	type Lookup = IdentityLookup<Self::AccountId>;91	type BlockHashCount = BlockHashCount;92	type Version = ();93	type PalletInfo = PalletInfo;94	type AccountData = pallet_balances::AccountData<u64>;95	type OnNewAccount = ();96	type OnKilledAccount = ();97	type SystemWeightInfo = ();98	type SS58Prefix = SS58Prefix;99	type OnSetCode = ();100	type MaxConsumers = ConstU32<16>;101}102103parameter_types! {104	pub const ExistentialDeposit: u64 = 1;105	pub const MaxLocks: u32 = 50;106}107//frame_system::Module<Test>;108impl pallet_balances::Config for Test {109	type RuntimeEvent = RuntimeEvent;110	type AccountStore = System;111	type Balance = u64;112	type DustRemoval = ();113	type ExistentialDeposit = ExistentialDeposit;114	type WeightInfo = ();115	type MaxLocks = MaxLocks;116	type MaxReserves = ();117	type ReserveIdentifier = [u8; 8];118	type MaxFreezes = MaxLocks;119	type FreezeIdentifier = [u8; 8];120	type MaxHolds = MaxLocks;121	type RuntimeHoldReason = RuntimeHoldReason;122}123124parameter_types! {125	pub const OperationalFeeMultiplier: u8 = 5;126}127128impl pallet_transaction_payment::Config for Test {129	type RuntimeEvent = RuntimeEvent;130	type OnChargeTransaction = CurrencyAdapter<pallet_balances::Pallet<Test>, ()>;131	type LengthToFee = IdentityFee<u64>;132	type WeightToFee = IdentityFee<u64>;133	type FeeMultiplierUpdate = ();134	type OperationalFeeMultiplier = OperationalFeeMultiplier;135}136137parameter_types! {138	pub const MinimumPeriod: u64 = 1;139}140impl pallet_timestamp::Config for Test {141	type Moment = u64;142	type OnTimestampSet = ();143	type MinimumPeriod = MinimumPeriod;144	type WeightInfo = ();145}146147parameter_types! {148	pub const CollectionCreationPrice: u32 = 100;149	pub TreasuryAccountId: u64 = 1234;150	pub EthereumChainId: u32 = 1111;151}152153pub struct TestEvmAddressMapping;154impl AddressMapping<u64> for TestEvmAddressMapping {155	fn into_account_id(_addr: sp_core::H160) -> u64 {156		unimplemented!()157	}158}159160pub struct TestEvmBackwardsAddressMapping;161impl BackwardsAddressMapping<u64> for TestEvmBackwardsAddressMapping {162	fn from_account_id(_account_id: u64) -> sp_core::H160 {163		unimplemented!()164	}165}166167#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo, MaxEncodedLen)]168pub struct TestCrossAccountId(u64, sp_core::H160, bool);169impl CrossAccountId<u64> for TestCrossAccountId {170	fn as_sub(&self) -> &u64 {171		&self.0172	}173	fn as_eth(&self) -> &sp_core::H160 {174		&self.1175	}176	fn from_sub(sub: u64) -> Self {177		let mut eth = [0; 20];178		eth[12..20].copy_from_slice(&sub.to_be_bytes());179		Self(sub, sp_core::H160(eth), true)180	}181	fn from_eth(eth: sp_core::H160) -> Self {182		let mut sub_raw = [0; 8];183		sub_raw.copy_from_slice(&eth.0[0..8]);184		let sub = u64::from_be_bytes(sub_raw);185		Self(sub, eth, false)186	}187	fn conv_eq(&self, other: &Self) -> bool {188		self.as_sub() == other.as_sub()189	}190	fn is_canonical_substrate(&self) -> bool {191		self.2192	}193}194195impl Default for TestCrossAccountId {196	fn default() -> Self {197		Self::from_sub(0)198	}199}200201parameter_types! {202	pub BlockGasLimit: U256 = 0u32.into();203	pub WeightPerGas: Weight = Weight::from_parts(20, 0);204	pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes;205}206207impl pallet_ethereum::Config for Test {208	type RuntimeEvent = RuntimeEvent;209	type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;210	type PostLogContent = PostBlockAndTxnHashes;211	type ExtraDataLength = ConstU32<32>;212}213214impl pallet_evm::Config for Test {215	type WeightInfo = pallet_evm::weights::SubstrateWeight<Self>;216	type CrossAccountId = TestCrossAccountId;217	type AddressMapping = TestEvmAddressMapping;218	type BackwardsAddressMapping = TestEvmBackwardsAddressMapping;219	type RuntimeEvent = RuntimeEvent;220	type FeeCalculator = ();221	type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;222	type WeightPerGas = WeightPerGas;223	type CallOrigin = EnsureAddressNever<Self>;224	type WithdrawOrigin = EnsureAddressNever<Self>;225	type Currency = Balances;226	type PrecompilesType = ();227	type PrecompilesValue = ();228	type Runner = pallet_evm::runner::stack::Runner<Self>;229	type ChainId = ConstU64<0>;230	type BlockGasLimit = BlockGasLimit;231	type OnMethodCall = ();232	type OnCreate = ();233	type OnChargeTransaction = ();234	type OnCheckEvmTransaction = ();235	type FindAuthor = ();236	type BlockHashMapping = SubstrateBlockHashMapping<Self>;237	type Timestamp = Timestamp;238	type GasLimitPovSizeRatio = ConstU64<0>;239}240impl pallet_evm_coder_substrate::Config for Test {}241242impl pallet_common::Config for Test {243	type WeightInfo = ();244	type RuntimeEvent = RuntimeEvent;245	type Currency = Balances;246	type CollectionCreationPrice = CollectionCreationPrice;247	type TreasuryAccountId = TreasuryAccountId;248249	type CollectionDispatch = CollectionDispatchT<Self>;250	type EvmTokenAddressMapping = EvmTokenAddressMapping;251	type CrossTokenAddressMapping = CrossTokenAddressMapping<Self::AccountId>;252	type ContractAddress = EvmCollectionHelpersAddress;253}254255impl pallet_structure::Config for Test {256	type WeightInfo = ();257	type RuntimeEvent = RuntimeEvent;258	type RuntimeCall = RuntimeCall;259}260impl pallet_fungible::Config for Test {261	type WeightInfo = ();262}263impl pallet_refungible::Config for Test {264	type WeightInfo = ();265}266impl pallet_nonfungible::Config for Test {267	type WeightInfo = ();268}269parameter_types! {270	pub const Decimals: u8 = 18;271	pub Name: String = "Test".to_string();272	pub Symbol: String = "TST".to_string();273}274impl pallet_balances_adapter::Config for Test {275	type Inspect = Balances;276	type Mutate = Balances;277	type CurrencyBalance = <Balances as Inspect<Self::AccountId>>::Balance;278	type Decimals = Decimals;279	type Name = Name;280	type Symbol = Symbol;281	type WeightInfo = ();282}283284parameter_types! {285	// 0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f286	pub const EvmCollectionHelpersAddress: H160 = H160([287		0x6c, 0x4e, 0x9f, 0xe1, 0xae, 0x37, 0xa4, 0x1e, 0x93, 0xce, 0xe4, 0x29, 0xe8, 0xe1, 0x88, 0x1a, 0xbd, 0xcb, 0xb5, 0x4f,288	]);289}290291impl pallet_unique::Config for Test {292	type WeightInfo = ();293	type CommonWeightInfo = CommonWeights<Self>;294	type RefungibleExtensionsWeightInfo = CommonWeights<Self>;295}296297// Build genesis storage according to the mock runtime.298pub fn new_test_ext() -> sp_io::TestExternalities {299	<system::GenesisConfig<Test>>::default()300		.build_storage()301		.unwrap()302		.into()303}
addedruntime/tests/src/weightsdiffbeforeafterboth
--- /dev/null
+++ b/runtime/tests/src/weights
@@ -0,0 +1 @@
+../../common/weights
\ No newline at end of file