Skip to content

Commit

Permalink
Mocks updated to use TestDefaultConfig (#1410)
Browse files Browse the repository at this point in the history
* Config mocks updated

* Cleanup default parameters

* Further cleanup of default parameters
  • Loading branch information
grbIzl authored Jan 23, 2025
1 parent 7e4745c commit a154d0e
Show file tree
Hide file tree
Showing 22 changed files with 121 additions and 950 deletions.
75 changes: 9 additions & 66 deletions chain-extensions/pallet-assets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
use crate::AssetsExtension;
use frame_support::traits::{AsEnsureOriginWithArg, ConstU128, Currency, Randomness};
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64, Nothing},
derive_impl, parameter_types,
traits::{ConstU64, Nothing},
weights::Weight,
};
use frame_system::EnsureSigned;
use pallet_contracts::chain_extension::RegisteredChainExtension;
use pallet_contracts::{Config, DefaultAddressGenerator, Frame};
use pallet_contracts::{Config, Frame};
use sp_core::crypto::AccountId32;
use sp_runtime::{
testing::H256,
traits::{BlakeTwo256, Convert, IdentityLookup, Zero},
traits::{Convert, IdentityLookup, Zero},
BuildStorage, Perbill,
};

Expand All @@ -47,36 +47,12 @@ parameter_types! {
Weight::from_parts(2_000_000_000_000, u64::MAX),
);
}
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = BlockWeights;
type BlockLength = ();
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u32;
type Block = Block;
type Hash = H256;
type RuntimeCall = RuntimeCall;
type Hashing = BlakeTwo256;
type AccountId = AccountId32;
type Lookup = IdentityLookup<Self::AccountId>;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = RuntimeTask;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

parameter_types! {
Expand All @@ -96,6 +72,7 @@ impl Randomness<H256, BlockNumber> for DummyDeprecatedRandomness {
}
}

#[derive_impl(pallet_contracts::config_preludes::TestDefaultConfig)]
impl pallet_contracts::Config for Test {
type Time = Timestamp;
type Randomness = DummyDeprecatedRandomness;
Expand All @@ -104,29 +81,12 @@ impl pallet_contracts::Config for Test {
type RuntimeCall = RuntimeCall;
type CallFilter = Nothing;
type CallStack = [Frame<Self>; 5];
type WeightPrice = Self;
type WeightInfo = ();
type ChainExtension = AssetsExtension<Self>;
type Schedule = Schedule;
type DepositPerByte = DepositPerByte;
type DepositPerItem = DepositPerItem;
type DefaultDepositLimit = DefaultDepositLimit;
type AddressGenerator = DefaultAddressGenerator;
type MaxCodeLen = ConstU32<{ 123 * 1024 }>;
type MaxStorageKeyLen = ConstU32<128>;
type UnsafeUnstableInterface = UnstableInterface;
type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>;
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type Debug = ();
type Environment = ();
type MaxDelegateDependencies = MaxDelegateDependencies;
type Migrations = ();
type RuntimeHoldReason = RuntimeHoldReason;
type Xcm = ();
type UploadOrigin = EnsureSigned<AccountId32>;
type InstantiateOrigin = EnsureSigned<AccountId32>;
type ApiVersion = ();
type MaxTransientStorageSize = ConstU32<{ 1 * 1024 * 1024 }>;
}

impl RegisteredChainExtension<Test> for AssetsExtension<Test> {
Expand All @@ -137,29 +97,19 @@ parameter_types! {
pub static ExistentialDeposit: u64 = 1;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type Balance = Balance;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
type RuntimeHoldReason = RuntimeHoldReason;
type FreezeIdentifier = ();
type RuntimeFreezeReason = ();
type MaxFreezes = ConstU32<0>;
}

#[derive_impl(pallet_timestamp::config_preludes::TestDefaultConfig)]
impl pallet_timestamp::Config for Test {
type Moment = u64;
type OnTimestampSet = ();
type MinimumPeriod = ConstU64<1>;
type WeightInfo = ();
}

#[derive_impl(pallet_assets::config_preludes::TestDefaultConfig)]
impl pallet_assets::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
Expand All @@ -173,14 +123,7 @@ impl pallet_assets::Config for Test {
type MetadataDepositBase = ConstU128<1>;
type MetadataDepositPerByte = ConstU128<1>;
type ApprovalDeposit = ConstU128<1>;
type StringLimit = ConstU32<50>;
type Freezer = ();
type WeightInfo = ();
type CallbackHandle = ();
type Extra = ();
type RemoveItemsLimit = ConstU32<5>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}

type Block = frame_system::mocking::MockBlockU32<Test>;
Expand Down
52 changes: 6 additions & 46 deletions pallets/astar-xcm-benchmarks/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ use crate::{fungible, generic, *};
use astar_primitives::xcm::ReserveAssetFilter;
use frame_benchmarking::BenchmarkError;
use frame_support::{
assert_ok, parameter_types,
assert_ok, derive_impl, parameter_types,
traits::{fungible::ItemOf, AsEnsureOriginWithArg, Everything, Nothing},
weights::Weight,
};
use frame_system::{EnsureRoot, EnsureSigned};

use core::marker::PhantomData;
use sp_core::{ConstU32, ConstU64, Get, H256};
use sp_runtime::traits::{BlakeTwo256, IdentityLookup};
use sp_core::{ConstU64, Get};
use sp_runtime::traits::IdentityLookup;
use xcm::latest::prelude::*;
use xcm_builder::{AllowUnpaidExecutionFrom, FungiblesAdapter, MintLocation, NoChecking};

Expand Down Expand Up @@ -104,58 +104,25 @@ parameter_types! {
frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, u64::MAX));
pub UniversalLocation: InteriorLocation = Here;
}
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = Everything;
type BlockWeights = ();
type BlockLength = ();
type Block = Block;
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type Hash = H256;
type RuntimeCall = RuntimeCall;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
type RuntimeTask = RuntimeTask;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

parameter_types! {
pub const ExistentialDeposit: u64 = 10;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type Balance = Balance;
type DustRemoval = ();
type RuntimeEvent = RuntimeEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
type RuntimeHoldReason = RuntimeHoldReason;
type FreezeIdentifier = ();
type RuntimeFreezeReason = ();
type MaxFreezes = ConstU32<0>;
}

#[derive_impl(pallet_assets::config_preludes::TestDefaultConfig)]
impl pallet_assets::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
Expand All @@ -169,14 +136,7 @@ impl pallet_assets::Config for Test {
type MetadataDepositPerByte = ConstU64<1>;
type AssetAccountDeposit = ConstU64<10>;
type ApprovalDeposit = ConstU64<10>;
type StringLimit = ConstU32<50>;
type Freezer = ();
type Extra = ();
type RemoveItemsLimit = ConstU32<100>;
type CallbackHandle = ();
type WeightInfo = ();
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}

pub struct MatchOnlyAsset<MatchAsset>(PhantomData<MatchAsset>);
Expand Down
53 changes: 7 additions & 46 deletions pallets/collator-selection/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@
use super::*;
use crate as collator_selection;
use frame_support::{
ord_parameter_types, parameter_types,
traits::{ConstU32, FindAuthor, ValidatorRegistration},
derive_impl, ord_parameter_types, parameter_types,
traits::{FindAuthor, ValidatorRegistration},
PalletId,
};
use frame_system as system;
use frame_system::EnsureSignedBy;
use sp_core::{ConstBool, H256};
use sp_core::ConstBool;
use sp_runtime::{
testing::UintAuthorityId,
traits::{BlakeTwo256, IdentityLookup, OpaqueKeys},
BuildStorage, Perbill, RuntimeAppPublic,
testing::UintAuthorityId, traits::OpaqueKeys, BuildStorage, Perbill, RuntimeAppPublic,
};

type Block = frame_system::mocking::MockBlock<Test>;
Expand All @@ -51,57 +49,21 @@ parameter_types! {
pub const SS58Prefix: u8 = 42;
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
type Block = Block;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type RuntimeTask = RuntimeTask;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
}

parameter_types! {
pub const ExistentialDeposit: u64 = 5;
pub const MaxReserves: u32 = 50;
}

#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type Balance = u64;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
type MaxLocks = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = ();
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<0>;
}

pub struct Author4;
Expand All @@ -123,11 +85,10 @@ parameter_types! {
pub const MinimumPeriod: u64 = 1;
}

#[derive_impl(pallet_timestamp::config_preludes::TestDefaultConfig)]
impl pallet_timestamp::Config for Test {
type Moment = u64;
type OnTimestampSet = Aura;
type MinimumPeriod = MinimumPeriod;
type WeightInfo = ();
}

impl pallet_aura::Config for Test {
Expand Down
Loading

0 comments on commit a154d0e

Please sign in to comment.