difftreelog
test fix mocks
in: master
3 files changed
pallets/inflation/src/tests.rsdiffbeforeafterboth--- a/pallets/inflation/src/tests.rs
+++ b/pallets/inflation/src/tests.rs
@@ -6,7 +6,9 @@
traits::{Currency},
parameter_types,
};
-use frame_support::{traits::OnInitialize};
+use frame_support::{
+ traits::{OnInitialize, Everything},
+};
use sp_core::H256;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
@@ -55,7 +57,7 @@
}
impl frame_system::Config for Test {
- type BaseCallFilter = ();
+ type BaseCallFilter = Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
pallets/nft/src/mock.rsdiffbeforeafterboth1#![allow(clippy::from_over_into)]23use crate as pallet_template;4use sp_core::H256;5use frame_support::{parameter_types, weights::IdentityFee};6use sp_runtime::{7 traits::{BlakeTwo256, IdentityLookup},8 testing::Header,9};10use pallet_transaction_payment::{CurrencyAdapter};11use frame_system as system;12use pallet_evm::AddressMapping;13use crate::{EvmBackwardsAddressMapping, CrossAccountId};14use codec::{Encode, Decode};1516type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;17type Block = frame_system::mocking::MockBlock<Test>;1819// Configure a mock runtime to test the pallet.20frame_support::construct_runtime!(21 pub enum Test where22 Block = Block,23 NodeBlock = Block,24 UncheckedExtrinsic = UncheckedExtrinsic,25 {26 System: frame_system::{Pallet, Call, Config, Storage, Event<T>},27 TemplateModule: pallet_template::{Pallet, Call, Storage},28 Balances: pallet_balances::{Pallet, Call, Storage},29 }30);3132parameter_types! {33 pub const BlockHashCount: u64 = 250;34 pub const SS58Prefix: u8 = 42;35}3637impl system::Config for Test {38 type BaseCallFilter = ();39 type BlockWeights = ();40 type BlockLength = ();41 type DbWeight = ();42 type Origin = Origin;43 type Call = Call;44 type Index = u64;45 type BlockNumber = u64;46 type Hash = H256;47 type Hashing = BlakeTwo256;48 type AccountId = u64;49 type Lookup = IdentityLookup<Self::AccountId>;50 type Header = Header;51 type Event = ();52 type BlockHashCount = BlockHashCount;53 type Version = ();54 type PalletInfo = PalletInfo;55 type AccountData = pallet_balances::AccountData<u64>;56 type OnNewAccount = ();57 type OnKilledAccount = ();58 type SystemWeightInfo = ();59 type SS58Prefix = SS58Prefix;60 type OnSetCode = ();61}6263parameter_types! {64 pub const ExistentialDeposit: u64 = 1;65 pub const MaxLocks: u32 = 50;66}67//frame_system::Module<Test>;68impl pallet_balances::Config for Test {69 type AccountStore = System;70 type Balance = u64;71 type DustRemoval = ();72 type Event = ();73 type ExistentialDeposit = ExistentialDeposit;74 type WeightInfo = ();75 type MaxLocks = MaxLocks;76 type MaxReserves = ();77 type ReserveIdentifier = [u8; 8];78}7980parameter_types! {81 pub const TransactionByteFee: u64 = 1;82}8384impl pallet_transaction_payment::Config for Test {85 type OnChargeTransaction = CurrencyAdapter<pallet_balances::Pallet<Test>, ()>;86 type TransactionByteFee = TransactionByteFee;87 type WeightToFee = IdentityFee<u64>;88 type FeeMultiplierUpdate = ();89}9091parameter_types! {92 pub const MinimumPeriod: u64 = 1;93}94impl pallet_timestamp::Config for Test {95 type Moment = u64;96 type OnTimestampSet = ();97 type MinimumPeriod = MinimumPeriod;98 type WeightInfo = ();99}100101parameter_types! {102 pub const CollectionCreationPrice: u32 = 0;103 pub TreasuryAccountId: u64 = 1234;104 pub EthereumChainId: u32 = 1111;105}106107pub struct TestEvmAddressMapping;108impl AddressMapping<u64> for TestEvmAddressMapping {109 fn into_account_id(_addr: sp_core::H160) -> u64 {110 unimplemented!()111 }112}113114pub struct TestEvmBackwardsAddressMapping;115impl EvmBackwardsAddressMapping<u64> for TestEvmBackwardsAddressMapping {116 fn from_account_id(_account_id: u64) -> sp_core::H160 {117 unimplemented!()118 }119}120121#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]122pub struct TestCrossAccountId(u64, sp_core::H160);123impl CrossAccountId<u64> for TestCrossAccountId {124 fn from_sub(sub: u64) -> Self {125 let mut eth = [0; 20];126 eth[12..20].copy_from_slice(&sub.to_be_bytes());127 Self(sub, sp_core::H160(eth))128 }129 fn as_sub(&self) -> &u64 {130 &self.0131 }132 fn from_eth(eth: sp_core::H160) -> Self {133 let mut sub_raw = [0; 8];134 sub_raw.copy_from_slice(ð.0[0..8]);135 let sub = u64::from_be_bytes(sub_raw);136 Self(sub, eth)137 }138 fn as_eth(&self) -> &sp_core::H160 {139 &self.1140 }141}142143pub struct TestEtheremTransactionSender;144impl pallet_ethereum::EthereumTransactionSender for TestEtheremTransactionSender {145 fn submit_logs_transaction(146 _tx: pallet_ethereum::Transaction,147 _logs: Vec<pallet_ethereum::Log>,148 ) -> Result<(), sp_runtime::DispatchError> {149 Ok(())150 }151}152153impl pallet_evm_coder_substrate::Config for Test {154 type EthereumTransactionSender = TestEtheremTransactionSender;155}156157impl pallet_template::Config for Test {158 type Event = ();159 type WeightInfo = ();160 type CollectionCreationPrice = CollectionCreationPrice;161 type Currency = pallet_balances::Pallet<Test>;162 type TreasuryAccountId = TreasuryAccountId;163 type EvmAddressMapping = TestEvmAddressMapping;164 type EvmBackwardsAddressMapping = TestEvmBackwardsAddressMapping;165 type CrossAccountId = TestCrossAccountId;166}167168// Build genesis storage according to the mock runtime.169pub fn new_test_ext() -> sp_io::TestExternalities {170 system::GenesisConfig::default()171 .build_storage::<Test>()172 .unwrap()173 .into()174}1#![allow(clippy::from_over_into)]23use crate as pallet_template;4use sp_core::H256;5use frame_support::{parameter_types, traits::Everything, weights::IdentityFee};6use sp_runtime::{7 traits::{BlakeTwo256, IdentityLookup},8 testing::Header,9};10use pallet_transaction_payment::{CurrencyAdapter};11use frame_system as system;12use pallet_evm::AddressMapping;13use crate::{EvmBackwardsAddressMapping, CrossAccountId};14use codec::{Encode, Decode};15use scale_info::TypeInfo;1617type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;18type Block = frame_system::mocking::MockBlock<Test>;1920// Configure a mock runtime to test the pallet.21frame_support::construct_runtime!(22 pub enum Test where23 Block = Block,24 NodeBlock = Block,25 UncheckedExtrinsic = UncheckedExtrinsic,26 {27 System: frame_system::{Pallet, Call, Config, Storage, Event<T>},28 TemplateModule: pallet_template::{Pallet, Call, Storage},29 Balances: pallet_balances::{Pallet, Call, Storage},30 }31);3233parameter_types! {34 pub const BlockHashCount: u64 = 250;35 pub const SS58Prefix: u8 = 42;36}3738impl system::Config for Test {39 type BaseCallFilter = Everything;40 type BlockWeights = ();41 type BlockLength = ();42 type DbWeight = ();43 type Origin = Origin;44 type Call = Call;45 type Index = u64;46 type BlockNumber = u64;47 type Hash = H256;48 type Hashing = BlakeTwo256;49 type AccountId = u64;50 type Lookup = IdentityLookup<Self::AccountId>;51 type Header = Header;52 type Event = ();53 type BlockHashCount = BlockHashCount;54 type Version = ();55 type PalletInfo = PalletInfo;56 type AccountData = pallet_balances::AccountData<u64>;57 type OnNewAccount = ();58 type OnKilledAccount = ();59 type SystemWeightInfo = ();60 type SS58Prefix = SS58Prefix;61 type OnSetCode = ();62}6364parameter_types! {65 pub const ExistentialDeposit: u64 = 1;66 pub const MaxLocks: u32 = 50;67}68//frame_system::Module<Test>;69impl pallet_balances::Config for Test {70 type AccountStore = System;71 type Balance = u64;72 type DustRemoval = ();73 type Event = ();74 type ExistentialDeposit = ExistentialDeposit;75 type WeightInfo = ();76 type MaxLocks = MaxLocks;77 type MaxReserves = ();78 type ReserveIdentifier = [u8; 8];79}8081parameter_types! {82 pub const TransactionByteFee: u64 = 1;83 pub const OperationalFeeMultiplier: u8 = 5;84}8586impl pallet_transaction_payment::Config for Test {87 type OnChargeTransaction = CurrencyAdapter<pallet_balances::Pallet<Test>, ()>;88 type TransactionByteFee = TransactionByteFee;89 type WeightToFee = IdentityFee<u64>;90 type FeeMultiplierUpdate = ();91 type OperationalFeeMultiplier = OperationalFeeMultiplier;92}9394parameter_types! {95 pub const MinimumPeriod: u64 = 1;96}97impl pallet_timestamp::Config for Test {98 type Moment = u64;99 type OnTimestampSet = ();100 type MinimumPeriod = MinimumPeriod;101 type WeightInfo = ();102}103104parameter_types! {105 pub const CollectionCreationPrice: u32 = 0;106 pub TreasuryAccountId: u64 = 1234;107 pub EthereumChainId: u32 = 1111;108}109110pub struct TestEvmAddressMapping;111impl AddressMapping<u64> for TestEvmAddressMapping {112 fn into_account_id(_addr: sp_core::H160) -> u64 {113 unimplemented!()114 }115}116117pub struct TestEvmBackwardsAddressMapping;118impl EvmBackwardsAddressMapping<u64> for TestEvmBackwardsAddressMapping {119 fn from_account_id(_account_id: u64) -> sp_core::H160 {120 unimplemented!()121 }122}123124#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo)]125pub struct TestCrossAccountId(u64, sp_core::H160);126impl CrossAccountId<u64> for TestCrossAccountId {127 fn from_sub(sub: u64) -> Self {128 let mut eth = [0; 20];129 eth[12..20].copy_from_slice(&sub.to_be_bytes());130 Self(sub, sp_core::H160(eth))131 }132 fn as_sub(&self) -> &u64 {133 &self.0134 }135 fn from_eth(eth: sp_core::H160) -> Self {136 let mut sub_raw = [0; 8];137 sub_raw.copy_from_slice(ð.0[0..8]);138 let sub = u64::from_be_bytes(sub_raw);139 Self(sub, eth)140 }141 fn as_eth(&self) -> &sp_core::H160 {142 &self.1143 }144}145146pub struct TestEtheremTransactionSender;147impl pallet_ethereum::EthereumTransactionSender for TestEtheremTransactionSender {148 fn submit_logs_transaction(149 _tx: pallet_ethereum::Transaction,150 _logs: Vec<pallet_ethereum::Log>,151 ) -> Result<(), sp_runtime::DispatchError> {152 Ok(())153 }154}155156impl pallet_evm_coder_substrate::Config for Test {157 type EthereumTransactionSender = TestEtheremTransactionSender;158}159160impl pallet_template::Config for Test {161 type Event = ();162 type WeightInfo = ();163 type CollectionCreationPrice = CollectionCreationPrice;164 type Currency = pallet_balances::Pallet<Test>;165 type TreasuryAccountId = TreasuryAccountId;166 type EvmAddressMapping = TestEvmAddressMapping;167 type EvmBackwardsAddressMapping = TestEvmBackwardsAddressMapping;168 type CrossAccountId = TestCrossAccountId;169}170171// Build genesis storage according to the mock runtime.172pub fn new_test_ext() -> sp_io::TestExternalities {173 system::GenesisConfig::default()174 .build_storage::<Test>()175 .unwrap()176 .into()177}pallets/scheduler/src/lib.rsdiffbeforeafterboth--- a/pallets/scheduler/src/lib.rs
+++ b/pallets/scheduler/src/lib.rs
@@ -796,7 +796,7 @@
use frame_support::{
Hashable, assert_err, assert_noop, assert_ok, ord_parameter_types, parameter_types,
- traits::{Contains, Filter, OnFinalize, OnInitialize},
+ traits::{Contains, OnFinalize, OnInitialize},
weights::constants::RocksDbWeight,
};
use sp_core::H256;
@@ -873,7 +873,7 @@
pub struct BaseFilter;
impl Contains<Call> for BaseFilter {
fn contains(call: &Call) -> bool {
- !matches!(call, Call::Logger(logger::Call::log(_, _)))
+ !matches!(call, Call::Logger(logger::Call::log { .. }))
}
}