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
@@ -23,6 +23,7 @@ sp-std = { version = "2.0.0", default-features = false, path = "../../primitives
[dev-dependencies]
sp-core = { version = "2.0.0", path = "../../primitives/core" }
sp-io = { version = "2.0.0", path = "../../primitives/io" }
serde = { version = "1.0.101" }
[features]
default = ["std"]
@@ -132,6 +132,7 @@ impl<T: Config> Randomness<T::Hash> for Module<T> {
#[cfg(test)]
mod tests {
use crate as pallet_randomness_collective_flip;
use super::*;
use sp_core::H256;
use sp_runtime::{
@@ -139,16 +140,21 @@ mod tests {
traits::{BlakeTwo256, Header as _, IdentityLookup},
};
use frame_system::limits;
use frame_support::{
impl_outer_origin, parameter_types, traits::{Randomness, OnInitialize},
};
use frame_support::{parameter_types, traits::{Randomness, OnInitialize}};
#[derive(Clone, PartialEq, Eq)]
pub struct Test;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
impl_outer_origin! {
pub enum Origin for Test where system = frame_system {}
}
frame_support::construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
CollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
}
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
@@ -166,16 +172,16 @@ mod tests {
type Origin = Origin;
type Index = u64;
type BlockNumber = u64;
type Call = ();
type Call = Call;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = ();
type Event = Event;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
@@ -183,9 +189,6 @@ mod tests {
type SS58Prefix = ();
}
type System = frame_system::Module<Test>;
type CollectiveFlip = Module<Test>;
fn new_test_ext() -> sp_io::TestExternalities {
let t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
t.into()