move some pallet test to use construct_runtime (#8049)

* migrate some more pallets

* revert example-offcahin-worker as not straightforward

* fix mmr
This commit is contained in:
Guillaume Thiolliere
2021-02-04 16:57:59 +01:00
committed by GitHub
parent 6dea5494f3
commit 86498a1a0c
13 changed files with 212 additions and 226 deletions
+21 -17
View File
@@ -18,24 +18,31 @@
// Tests for Identity Pallet
use super::*;
use crate as pallet_identity;
use sp_runtime::traits::BadOrigin;
use frame_support::{
assert_ok, assert_noop, impl_outer_origin, parameter_types,
ord_parameter_types,
};
use frame_support::{assert_ok, assert_noop, parameter_types, ord_parameter_types};
use sp_core::H256;
use frame_system::{EnsureSignedBy, EnsureOneOf, EnsureRoot};
use sp_runtime::{
testing::Header, traits::{BlakeTwo256, IdentityLookup},
};
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>;
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>},
Identity: pallet_identity::{Module, Call, Storage, Event<T>},
}
);
#[derive(Clone, Eq, PartialEq)]
pub struct Test;
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
@@ -49,16 +56,16 @@ 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 = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = ();
type Event = Event;
type BlockHashCount = BlockHashCount;
type DbWeight = ();
type Version = ();
type PalletInfo = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -70,7 +77,7 @@ parameter_types! {
}
impl pallet_balances::Config for Test {
type Balance = u64;
type Event = ();
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
@@ -100,7 +107,7 @@ type EnsureTwoOrRoot = EnsureOneOf<
EnsureSignedBy<Two, u64>
>;
impl Config for Test {
type Event = ();
type Event = Event;
type Currency = Balances;
type Slashed = ();
type BasicDeposit = BasicDeposit;
@@ -113,9 +120,6 @@ impl Config for Test {
type ForceOrigin = EnsureTwoOrRoot;
type WeightInfo = ();
}
type System = frame_system::Module<Test>;
type Balances = pallet_balances::Module<Test>;
type Identity = Module<Test>;
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();