Make pallet use construct_runtime in tests instead of impl_* (#7986)

This commit is contained in:
Guillaume Thiolliere
2021-01-26 15:25:04 +01:00
committed by GitHub
parent 6ae24c91e9
commit b1888395e8
18 changed files with 304 additions and 351 deletions
+17 -30
View File
@@ -19,36 +19,27 @@
use super::*;
use frame_support::{
impl_outer_origin, impl_outer_dispatch, impl_outer_event, parameter_types,
traits::{OnInitialize, OnFinalize},
};
use frame_support::{parameter_types, traits::{OnInitialize, OnFinalize}};
use sp_core::H256;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup}, testing::Header,
};
use crate as recovery;
impl_outer_origin! {
pub enum Origin for Test where system = frame_system {}
}
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
impl_outer_event! {
pub enum TestEvent for Test {
system<T>,
pallet_balances<T>,
recovery<T>,
frame_support::construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
Recovery: recovery::{Module, Call, Storage, Event<T>},
}
}
impl_outer_dispatch! {
pub enum Call for Test where origin: Origin {
pallet_balances::Balances,
recovery::Recovery,
}
}
#[derive(Clone, Eq, PartialEq)]
pub struct Test;
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
@@ -70,10 +61,10 @@ impl frame_system::Config for Test {
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = TestEvent;
type Event = Event;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u128>;
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -89,7 +80,7 @@ impl pallet_balances::Config for Test {
type MaxLocks = ();
type Balance = u128;
type DustRemoval = ();
type Event = TestEvent;
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
@@ -103,7 +94,7 @@ parameter_types! {
}
impl Config for Test {
type Event = TestEvent;
type Event = Event;
type Call = Call;
type Currency = Balances;
type ConfigDepositBase = ConfigDepositBase;
@@ -112,10 +103,6 @@ impl Config for Test {
type RecoveryDeposit = RecoveryDeposit;
}
pub type Recovery = Module<Test>;
pub type System = frame_system::Module<Test>;
pub type Balances = pallet_balances::Module<Test>;
pub type BalancesCall = pallet_balances::Call<Test>;
pub type RecoveryCall = super::Call<Test>;