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
+21 -15
View File
@@ -18,9 +18,10 @@
//! Test utilities
use super::*;
use crate as pallet_society;
use frame_support::{
impl_outer_origin, parameter_types, ord_parameter_types,
parameter_types, ord_parameter_types,
traits::{OnInitialize, OnFinalize, TestRandomness},
};
use sp_core::H256;
@@ -30,12 +31,21 @@ use sp_runtime::{
};
use frame_system::EnsureSignedBy;
impl_outer_origin! {
pub enum Origin for Test {}
}
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
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>},
Society: pallet_society::{Module, Call, Storage, Event<T>, Config<T>},
}
);
#[derive(Clone, Eq, PartialEq)]
pub struct Test;
parameter_types! {
pub const CandidateDeposit: u64 = 25;
pub const WrongSideDeduction: u64 = 2;
@@ -65,12 +75,12 @@ impl frame_system::Config for Test {
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Call = ();
type Call = Call;
type Hashing = BlakeTwo256;
type AccountId = u128;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = ();
type Event = Event;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = ();
@@ -84,7 +94,7 @@ impl frame_system::Config for Test {
impl pallet_balances::Config for Test {
type MaxLocks = ();
type Balance = u64;
type Event = ();
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
@@ -92,7 +102,7 @@ impl pallet_balances::Config for Test {
}
impl Config for Test {
type Event = ();
type Event = Event;
type Currency = pallet_balances::Module<Self>;
type Randomness = TestRandomness;
type CandidateDeposit = CandidateDeposit;
@@ -108,10 +118,6 @@ impl Config for Test {
type ModuleId = SocietyModuleId;
}
pub type Society = Module<Test>;
pub type System = frame_system::Module<Test>;
pub type Balances = pallet_balances::Module<Test>;
pub struct EnvBuilder {
members: Vec<u128>,
balance: u64,
@@ -147,7 +153,7 @@ impl EnvBuilder {
pallet_balances::GenesisConfig::<Test> {
balances: self.balances,
}.assimilate_storage(&mut t).unwrap();
GenesisConfig::<Test>{
pallet_society::GenesisConfig::<Test>{
members: self.members,
pot: self.pot,
max_members: self.max_members,