Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frame/randomness-collective-flip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
35 changes: 19 additions & 16 deletions frame/randomness-collective-flip/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,29 @@ 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::{
testing::Header,
traits::{BlakeTwo256, Header as _, IdentityLookup},
};
use frame_system::limits;
use frame_support::{
impl_outer_origin, parameter_types, traits::{Randomness, OnInitialize},
};

#[derive(Clone, PartialEq, Eq)]
pub struct Test;

impl_outer_origin! {
pub enum Origin for Test where system = frame_system {}
}
use frame_support::{parameter_types, traits::{Randomness, OnInitialize}};

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>},
CollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
}
);

parameter_types! {
pub const BlockHashCount: u64 = 250;
Expand All @@ -166,26 +172,23 @@ 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 = ();
type SystemWeightInfo = ();
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()
Expand Down
49 changes: 18 additions & 31 deletions frame/recovery/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}

impl_outer_event! {
pub enum TestEvent for Test {
system<T>,
pallet_balances<T>,
recovery<T>,
}
}
impl_outer_dispatch! {
pub enum Call for Test where origin: Origin {
pallet_balances::Balances,
recovery::Recovery,
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>},
Recovery: recovery::{Module, Call, Storage, Event<T>},
}
}

#[derive(Clone, Eq, PartialEq)]
pub struct Test;
);

parameter_types! {
pub const BlockHashCount: u64 = 250;
Expand All @@ -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 = ();
Expand All @@ -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 = ();
Expand All @@ -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;
Expand All @@ -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>;

Expand Down
47 changes: 19 additions & 28 deletions frame/scheduler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ mod tests {
use super::*;

use frame_support::{
impl_outer_event, impl_outer_origin, impl_outer_dispatch, parameter_types, assert_ok, ord_parameter_types,
parameter_types, assert_ok, ord_parameter_types,
assert_noop, assert_err, Hashable,
traits::{OnInitialize, OnFinalize, Filter},
weights::constants::RocksDbWeight,
Expand Down Expand Up @@ -781,24 +781,20 @@ mod tests {
}
}

impl_outer_origin! {
pub enum Origin for Test where system = frame_system {}
}

impl_outer_dispatch! {
pub enum Call for Test where origin: Origin {
system::System,
logger::Logger,
}
}

impl_outer_event! {
pub enum Event for Test {
system<T>,
logger,
scheduler<T>,
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>},
Logger: logger::{Module, Call, Event},
Scheduler: scheduler::{Module, Call, Storage, Event<T>},
}
}
);

// Scheduler must dispatch with root and no filter, this tests base filter is indeed not used.
pub struct BaseFilter;
Expand All @@ -808,8 +804,6 @@ mod tests {
}
}

#[derive(Clone, Eq, PartialEq)]
pub struct Test;
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
Expand All @@ -829,18 +823,18 @@ mod tests {
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 = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type SS58Prefix = ();
}
impl logger::Config for Test {
type Event = ();
type Event = Event;
}
parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
Expand All @@ -851,7 +845,7 @@ mod tests {
}

impl Config for Test {
type Event = ();
type Event = Event;
type Origin = Origin;
type PalletsOrigin = OriginCaller;
type Call = Call;
Expand All @@ -860,9 +854,6 @@ mod tests {
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = ();
}
type System = system::Module<Test>;
type Logger = logger::Module<Test>;
type Scheduler = Module<Test>;

pub fn new_test_ext() -> sp_io::TestExternalities {
let t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
Expand Down
37 changes: 22 additions & 15 deletions frame/scored-pool/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,31 @@
//! Test utilities

use super::*;
use crate as pallet_scored_pool;

use std::cell::RefCell;
use frame_support::{impl_outer_origin, parameter_types, ord_parameter_types};
use frame_support::{parameter_types, ord_parameter_types};
use sp_core::H256;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup}, testing::Header,
};
use frame_system::EnsureSignedBy;

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>},
ScoredPool: pallet_scored_pool::{Module, Call, Storage, Config<T>, Event<T>},
}
);

#[derive(Clone, Eq, PartialEq)]
pub struct Test;
parameter_types! {
pub const CandidateDeposit: u64 = 25;
pub const Period: u64 = 4;
Expand All @@ -55,15 +65,15 @@ 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 Version = ();
type PalletInfo = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
Expand All @@ -74,7 +84,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;
Expand Down Expand Up @@ -109,7 +119,7 @@ impl InitializeMembers<u64> for TestChangeMembers {
}

impl Config for Test {
type Event = ();
type Event = Event;
type KickOrigin = EnsureSignedBy<KickOrigin, u64>;
type MembershipInitialized = TestChangeMembers;
type MembershipChanged = TestChangeMembers;
Expand All @@ -120,9 +130,6 @@ impl Config for Test {
type ScoreOrigin = EnsureSignedBy<ScoreOrigin, u64>;
}

type System = frame_system::Module<Test>;
type Balances = pallet_balances::Module<Test>;

pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
pallet_balances::GenesisConfig::<Test> {
Expand All @@ -136,7 +143,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
(99, 1),
],
}.assimilate_storage(&mut t).unwrap();
GenesisConfig::<Test>{
pallet_scored_pool::GenesisConfig::<Test>{
pool: vec![
(5, None),
(10, Some(1)),
Expand Down
Loading