mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 12:51:02 +00:00
Use construct_runtime in tests, remove default PalletInfo impl (#2409)
* Claims * Crowdloan * Runtime common * Parachains registrar * Impls * Purchase * Slots * parachains runtime mock * Use MockGenesisConfig in tests * Update runtime/common/src/claims.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -607,27 +607,30 @@ mod tests {
|
|||||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
|
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
|
||||||
use sp_runtime::{traits::{BlakeTwo256, IdentityLookup, Identity}, testing::Header};
|
use sp_runtime::{traits::{BlakeTwo256, IdentityLookup, Identity}, testing::Header};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
impl_outer_origin, impl_outer_dispatch, assert_ok, assert_err, assert_noop, parameter_types,
|
assert_ok, assert_err, assert_noop, parameter_types,
|
||||||
ord_parameter_types, weights::{Pays, GetDispatchInfo}, traits::ExistenceRequirement,
|
ord_parameter_types, weights::{Pays, GetDispatchInfo}, traits::ExistenceRequirement,
|
||||||
dispatch::DispatchError::BadOrigin,
|
dispatch::DispatchError::BadOrigin,
|
||||||
};
|
};
|
||||||
use pallet_balances;
|
use pallet_balances;
|
||||||
use super::Call as ClaimsCall;
|
use crate::claims;
|
||||||
|
use claims::Call as ClaimsCall;
|
||||||
|
|
||||||
impl_outer_origin! {
|
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||||
pub enum Origin for Test {}
|
type Block = frame_system::mocking::MockBlock<Test>;
|
||||||
}
|
|
||||||
|
|
||||||
impl_outer_dispatch! {
|
frame_support::construct_runtime!(
|
||||||
pub enum Call for Test where origin: Origin {
|
pub enum Test where
|
||||||
claims::Claims,
|
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>},
|
||||||
|
Vesting: pallet_vesting::{Module, Call, Storage, Config<T>, Event<T>},
|
||||||
|
Claims: claims::{Module, Call, Storage, Config<T>, Event<T>, ValidateUnsigned},
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
// For testing the module, we construct most of a mock runtime. This means
|
|
||||||
// first constructing a configuration type (`Test`) which `impl`s each of the
|
|
||||||
// configuration traits of modules we want to use.
|
|
||||||
#[derive(Clone, Eq, PartialEq)]
|
|
||||||
pub struct Test;
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const BlockHashCount: u32 = 250;
|
pub const BlockHashCount: u32 = 250;
|
||||||
}
|
}
|
||||||
@@ -645,10 +648,10 @@ mod tests {
|
|||||||
type AccountId = u64;
|
type AccountId = u64;
|
||||||
type Lookup = IdentityLookup<u64>;
|
type Lookup = IdentityLookup<u64>;
|
||||||
type Header = Header;
|
type Header = Header;
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = PalletInfo;
|
||||||
type AccountData = pallet_balances::AccountData<u64>;
|
type AccountData = pallet_balances::AccountData<u64>;
|
||||||
type OnNewAccount = ();
|
type OnNewAccount = ();
|
||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
@@ -662,7 +665,7 @@ mod tests {
|
|||||||
|
|
||||||
impl pallet_balances::Config for Test {
|
impl pallet_balances::Config for Test {
|
||||||
type Balance = u64;
|
type Balance = u64;
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type DustRemoval = ();
|
type DustRemoval = ();
|
||||||
type ExistentialDeposit = ExistentialDeposit;
|
type ExistentialDeposit = ExistentialDeposit;
|
||||||
type AccountStore = System;
|
type AccountStore = System;
|
||||||
@@ -675,7 +678,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_vesting::Config for Test {
|
impl pallet_vesting::Config for Test {
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
type BlockNumberToBalance = Identity;
|
type BlockNumberToBalance = Identity;
|
||||||
type MinVestedTransfer = MinVestedTransfer;
|
type MinVestedTransfer = MinVestedTransfer;
|
||||||
@@ -690,16 +693,12 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Config for Test {
|
impl Config for Test {
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type VestingSchedule = Vesting;
|
type VestingSchedule = Vesting;
|
||||||
type Prefix = Prefix;
|
type Prefix = Prefix;
|
||||||
type MoveClaimOrigin = frame_system::EnsureSignedBy<Six, u64>;
|
type MoveClaimOrigin = frame_system::EnsureSignedBy<Six, u64>;
|
||||||
type WeightInfo = TestWeightInfo;
|
type WeightInfo = TestWeightInfo;
|
||||||
}
|
}
|
||||||
type System = frame_system::Module<Test>;
|
|
||||||
type Balances = pallet_balances::Module<Test>;
|
|
||||||
type Vesting = pallet_vesting::Module<Test>;
|
|
||||||
type Claims = Module<Test>;
|
|
||||||
|
|
||||||
fn alice() -> secp256k1::SecretKey {
|
fn alice() -> secp256k1::SecretKey {
|
||||||
secp256k1::SecretKey::parse(&keccak_256(b"Alice")).unwrap()
|
secp256k1::SecretKey::parse(&keccak_256(b"Alice")).unwrap()
|
||||||
@@ -723,7 +722,7 @@ mod tests {
|
|||||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||||
// We use default for brevity, but you can configure as desired if needed.
|
// We use default for brevity, but you can configure as desired if needed.
|
||||||
pallet_balances::GenesisConfig::<Test>::default().assimilate_storage(&mut t).unwrap();
|
pallet_balances::GenesisConfig::<Test>::default().assimilate_storage(&mut t).unwrap();
|
||||||
GenesisConfig::<Test>{
|
claims::GenesisConfig::<Test>{
|
||||||
claims: vec![
|
claims: vec![
|
||||||
(eth(&alice()), 100, None, None),
|
(eth(&alice()), 100, None, None),
|
||||||
(eth(&dave()), 200, None, Some(StatementKind::Regular)),
|
(eth(&dave()), 200, None, Some(StatementKind::Regular)),
|
||||||
|
|||||||
@@ -580,7 +580,7 @@ mod tests {
|
|||||||
|
|
||||||
use std::{collections::HashMap, cell::RefCell};
|
use std::{collections::HashMap, cell::RefCell};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
impl_outer_origin, impl_outer_event, assert_ok, assert_noop, parameter_types,
|
assert_ok, assert_noop, parameter_types,
|
||||||
traits::{OnInitialize, OnFinalize},
|
traits::{OnInitialize, OnFinalize},
|
||||||
};
|
};
|
||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
@@ -591,35 +591,27 @@ mod tests {
|
|||||||
Permill, testing::Header,
|
Permill, testing::Header,
|
||||||
traits::{BlakeTwo256, IdentityLookup},
|
traits::{BlakeTwo256, IdentityLookup},
|
||||||
};
|
};
|
||||||
use crate::slots::Registrar;
|
use crate::slots::{self, Registrar};
|
||||||
|
use crate::crowdloan;
|
||||||
|
|
||||||
impl_outer_origin! {
|
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||||
pub enum Origin for Test {}
|
type Block = frame_system::mocking::MockBlock<Test>;
|
||||||
}
|
|
||||||
|
|
||||||
mod runtime_common_slots {
|
frame_support::construct_runtime!(
|
||||||
pub use crate::slots::Event;
|
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>},
|
||||||
|
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
|
||||||
|
Slots: slots::{Module, Call, Storage, Event<T>},
|
||||||
|
Crowdloan: crowdloan::{Module, Call, Storage, Event<T>},
|
||||||
|
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
mod runtime_common_crowdloan {
|
|
||||||
pub use crate::crowdloan::Event;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_outer_event! {
|
|
||||||
pub enum Event for Test {
|
|
||||||
frame_system<T>,
|
|
||||||
pallet_balances<T>,
|
|
||||||
pallet_treasury<T>,
|
|
||||||
runtime_common_slots<T>,
|
|
||||||
runtime_common_crowdloan<T>,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// For testing the module, we construct most of a mock runtime. This means
|
|
||||||
// first constructing a configuration type (`Test`) which `impl`s each of the
|
|
||||||
// configuration traits of modules we want to use.
|
|
||||||
#[derive(Clone, Eq, PartialEq)]
|
|
||||||
pub struct Test;
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const BlockHashCount: u32 = 250;
|
pub const BlockHashCount: u32 = 250;
|
||||||
}
|
}
|
||||||
@@ -630,7 +622,7 @@ mod tests {
|
|||||||
type BlockLength = ();
|
type BlockLength = ();
|
||||||
type DbWeight = ();
|
type DbWeight = ();
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Call = ();
|
type Call = Call;
|
||||||
type Index = u64;
|
type Index = u64;
|
||||||
type BlockNumber = u64;
|
type BlockNumber = u64;
|
||||||
type Hash = H256;
|
type Hash = H256;
|
||||||
@@ -641,7 +633,7 @@ mod tests {
|
|||||||
type Event = Event;
|
type Event = Event;
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = PalletInfo;
|
||||||
type AccountData = pallet_balances::AccountData<u64>;
|
type AccountData = pallet_balances::AccountData<u64>;
|
||||||
type OnNewAccount = ();
|
type OnNewAccount = ();
|
||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
@@ -765,12 +757,6 @@ mod tests {
|
|||||||
type RemoveKeysLimit = RemoveKeysLimit;
|
type RemoveKeysLimit = RemoveKeysLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
type System = frame_system::Module<Test>;
|
|
||||||
type Balances = pallet_balances::Module<Test>;
|
|
||||||
type Slots = slots::Module<Test>;
|
|
||||||
type Treasury = pallet_treasury::Module<Test>;
|
|
||||||
type Crowdloan = Module<Test>;
|
|
||||||
type RandomnessCollectiveFlip = pallet_randomness_collective_flip::Module<Test>;
|
|
||||||
use pallet_balances::Error as BalancesError;
|
use pallet_balances::Error as BalancesError;
|
||||||
use slots::Error as SlotsError;
|
use slots::Error as SlotsError;
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ where
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use frame_system::limits;
|
use frame_system::limits;
|
||||||
use frame_support::{impl_outer_origin, parameter_types, weights::DispatchClass};
|
use frame_support::{parameter_types, weights::DispatchClass};
|
||||||
use frame_support::traits::FindAuthor;
|
use frame_support::traits::FindAuthor;
|
||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
@@ -83,12 +83,20 @@ mod tests {
|
|||||||
};
|
};
|
||||||
use primitives::v1::AccountId;
|
use primitives::v1::AccountId;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||||
pub struct Test;
|
type Block = frame_system::mocking::MockBlock<Test>;
|
||||||
|
|
||||||
impl_outer_origin!{
|
frame_support::construct_runtime!(
|
||||||
pub enum Origin for Test {}
|
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>},
|
||||||
|
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const BlockHashCount: u64 = 250;
|
pub const BlockHashCount: u64 = 250;
|
||||||
@@ -109,19 +117,19 @@ mod tests {
|
|||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Index = u64;
|
type Index = u64;
|
||||||
type BlockNumber = u64;
|
type BlockNumber = u64;
|
||||||
type Call = ();
|
type Call = Call;
|
||||||
type Hash = H256;
|
type Hash = H256;
|
||||||
type Hashing = BlakeTwo256;
|
type Hashing = BlakeTwo256;
|
||||||
type AccountId = AccountId;
|
type AccountId = AccountId;
|
||||||
type Lookup = IdentityLookup<Self::AccountId>;
|
type Lookup = IdentityLookup<Self::AccountId>;
|
||||||
type Header = Header;
|
type Header = Header;
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type BlockLength = BlockLength;
|
type BlockLength = BlockLength;
|
||||||
type BlockWeights = BlockWeights;
|
type BlockWeights = BlockWeights;
|
||||||
type DbWeight = ();
|
type DbWeight = ();
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = PalletInfo;
|
||||||
type AccountData = pallet_balances::AccountData<u64>;
|
type AccountData = pallet_balances::AccountData<u64>;
|
||||||
type OnNewAccount = ();
|
type OnNewAccount = ();
|
||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
@@ -131,7 +139,7 @@ mod tests {
|
|||||||
|
|
||||||
impl pallet_balances::Config for Test {
|
impl pallet_balances::Config for Test {
|
||||||
type Balance = u64;
|
type Balance = u64;
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type DustRemoval = ();
|
type DustRemoval = ();
|
||||||
type ExistentialDeposit = ();
|
type ExistentialDeposit = ();
|
||||||
type AccountStore = System;
|
type AccountStore = System;
|
||||||
@@ -147,7 +155,7 @@ mod tests {
|
|||||||
type Currency = pallet_balances::Module<Test>;
|
type Currency = pallet_balances::Module<Test>;
|
||||||
type ApproveOrigin = frame_system::EnsureRoot<AccountId>;
|
type ApproveOrigin = frame_system::EnsureRoot<AccountId>;
|
||||||
type RejectOrigin = frame_system::EnsureRoot<AccountId>;
|
type RejectOrigin = frame_system::EnsureRoot<AccountId>;
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type OnSlash = ();
|
type OnSlash = ();
|
||||||
type ProposalBond = ();
|
type ProposalBond = ();
|
||||||
type ProposalBondMinimum = ();
|
type ProposalBondMinimum = ();
|
||||||
@@ -174,10 +182,6 @@ mod tests {
|
|||||||
type EventHandler = ();
|
type EventHandler = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
type Treasury = pallet_treasury::Module<Test>;
|
|
||||||
type Balances = pallet_balances::Module<Test>;
|
|
||||||
type System = frame_system::Module<Test>;
|
|
||||||
|
|
||||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||||
// We use default for brevity, but you can configure as desired if needed.
|
// We use default for brevity, but you can configure as desired if needed.
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ impl<T: pallet_session::Config> OneSessionHandler<T::AccountId> for AssignmentSe
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod multiplier_tests {
|
mod multiplier_tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
use frame_support::{parameter_types, weights::Weight};
|
||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
testing::Header,
|
testing::Header,
|
||||||
@@ -196,12 +196,18 @@ mod multiplier_tests {
|
|||||||
Perbill,
|
Perbill,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
|
||||||
pub struct Runtime;
|
type Block = frame_system::mocking::MockBlock<Runtime>;
|
||||||
|
|
||||||
impl_outer_origin!{
|
frame_support::construct_runtime!(
|
||||||
pub enum Origin for Runtime {}
|
pub enum Runtime where
|
||||||
|
Block = Block,
|
||||||
|
NodeBlock = Block,
|
||||||
|
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||||
|
{
|
||||||
|
System: frame_system::{Module, Call, Config, Storage, Event<T>}
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const BlockHashCount: u64 = 250;
|
pub const BlockHashCount: u64 = 250;
|
||||||
@@ -220,16 +226,16 @@ mod multiplier_tests {
|
|||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Index = u64;
|
type Index = u64;
|
||||||
type BlockNumber = u64;
|
type BlockNumber = u64;
|
||||||
type Call = ();
|
type Call = Call;
|
||||||
type Hash = H256;
|
type Hash = H256;
|
||||||
type Hashing = BlakeTwo256;
|
type Hashing = BlakeTwo256;
|
||||||
type AccountId = u64;
|
type AccountId = u64;
|
||||||
type Lookup = IdentityLookup<Self::AccountId>;
|
type Lookup = IdentityLookup<Self::AccountId>;
|
||||||
type Header = Header;
|
type Header = Header;
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = PalletInfo;
|
||||||
type AccountData = ();
|
type AccountData = ();
|
||||||
type OnNewAccount = ();
|
type OnNewAccount = ();
|
||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
@@ -237,8 +243,6 @@ mod multiplier_tests {
|
|||||||
type SS58Prefix = ();
|
type SS58Prefix = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
type System = frame_system::Module<Runtime>;
|
|
||||||
|
|
||||||
fn run_with_system_weight<F>(w: Weight, assertions: F) where F: Fn() -> () {
|
fn run_with_system_weight<F>(w: Weight, assertions: F) where F: Fn() -> () {
|
||||||
let mut t: sp_io::TestExternalities =
|
let mut t: sp_io::TestExternalities =
|
||||||
frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap().into();
|
frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap().into();
|
||||||
|
|||||||
@@ -267,25 +267,32 @@ mod tests {
|
|||||||
use frame_system::limits;
|
use frame_system::limits;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
traits::{Randomness, OnInitialize, OnFinalize},
|
traits::{Randomness, OnInitialize, OnFinalize},
|
||||||
impl_outer_origin, impl_outer_dispatch, assert_ok, parameter_types,
|
assert_ok, parameter_types,
|
||||||
};
|
};
|
||||||
use keyring::Sr25519Keyring;
|
use keyring::Sr25519Keyring;
|
||||||
use runtime_parachains::{initializer, configuration, inclusion, session_info, scheduler, dmp, ump, hrmp};
|
use runtime_parachains::{initializer, configuration, inclusion, session_info, scheduler, dmp, ump, hrmp};
|
||||||
use frame_support::traits::OneSessionHandler;
|
use frame_support::traits::OneSessionHandler;
|
||||||
|
use crate::paras_registrar;
|
||||||
|
|
||||||
impl_outer_origin! {
|
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||||
pub enum Origin for Test {
|
type Block = frame_system::mocking::MockBlock<Test>;
|
||||||
runtime_parachains,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_outer_dispatch! {
|
frame_support::construct_runtime!(
|
||||||
pub enum Call for Test where origin: Origin {
|
pub enum Test where
|
||||||
paras::Parachains,
|
Block = Block,
|
||||||
registrar::Registrar,
|
NodeBlock = Block,
|
||||||
staking::Staking,
|
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||||
}
|
{
|
||||||
|
System: frame_system::{Module, Call, Config, Storage, Event<T>},
|
||||||
|
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
|
||||||
|
Parachains: paras::{Module, Origin, Call, Storage, Config<T>},
|
||||||
|
Inclusion: inclusion::{Module, Call, Storage, Event<T>},
|
||||||
|
Registrar: paras_registrar::{Module, Call, Storage},
|
||||||
|
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
|
||||||
|
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
|
||||||
|
Initializer: initializer::{Module, Call, Storage},
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
pallet_staking_reward_curve::build! {
|
pallet_staking_reward_curve::build! {
|
||||||
const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
|
const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
|
||||||
@@ -298,8 +305,6 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Eq, PartialEq)]
|
|
||||||
pub struct Test;
|
|
||||||
const NORMAL_RATIO: Perbill = Perbill::from_percent(75);
|
const NORMAL_RATIO: Perbill = Perbill::from_percent(75);
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const BlockHashCount: u32 = 250;
|
pub const BlockHashCount: u32 = 250;
|
||||||
@@ -320,13 +325,13 @@ mod tests {
|
|||||||
type AccountId = u64;
|
type AccountId = u64;
|
||||||
type Lookup = IdentityLookup<u64>;
|
type Lookup = IdentityLookup<u64>;
|
||||||
type Header = Header;
|
type Header = Header;
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type DbWeight = ();
|
type DbWeight = ();
|
||||||
type BlockWeights = BlockWeights;
|
type BlockWeights = BlockWeights;
|
||||||
type BlockLength = BlockLength;
|
type BlockLength = BlockLength;
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = PalletInfo;
|
||||||
type AccountData = pallet_balances::AccountData<u128>;
|
type AccountData = pallet_balances::AccountData<u128>;
|
||||||
type OnNewAccount = ();
|
type OnNewAccount = ();
|
||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
@@ -348,7 +353,7 @@ mod tests {
|
|||||||
impl pallet_balances::Config for Test {
|
impl pallet_balances::Config for Test {
|
||||||
type Balance = u128;
|
type Balance = u128;
|
||||||
type DustRemoval = ();
|
type DustRemoval = ();
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type ExistentialDeposit = ExistentialDeposit;
|
type ExistentialDeposit = ExistentialDeposit;
|
||||||
type AccountStore = System;
|
type AccountStore = System;
|
||||||
type MaxLocks = ();
|
type MaxLocks = ();
|
||||||
@@ -377,7 +382,7 @@ mod tests {
|
|||||||
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
||||||
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
||||||
type SessionHandler = pallet_session::TestSessionHandler;
|
type SessionHandler = pallet_session::TestSessionHandler;
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type ValidatorId = u64;
|
type ValidatorId = u64;
|
||||||
type ValidatorIdOf = ();
|
type ValidatorIdOf = ();
|
||||||
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
||||||
@@ -398,7 +403,7 @@ mod tests {
|
|||||||
impl pallet_staking::Config for Test {
|
impl pallet_staking::Config for Test {
|
||||||
type RewardRemainder = ();
|
type RewardRemainder = ();
|
||||||
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
|
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type Currency = pallet_balances::Module<Test>;
|
type Currency = pallet_balances::Module<Test>;
|
||||||
type Slash = ();
|
type Slash = ();
|
||||||
type Reward = ();
|
type Reward = ();
|
||||||
@@ -482,7 +487,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl inclusion::Config for Test {
|
impl inclusion::Config for Test {
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type RewardValidators = TestRewardValidators;
|
type RewardValidators = TestRewardValidators;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,15 +545,6 @@ mod tests {
|
|||||||
type ParathreadDeposit = ParathreadDeposit;
|
type ParathreadDeposit = ParathreadDeposit;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Balances = pallet_balances::Module<Test>;
|
|
||||||
type Parachains = paras::Module<Test>;
|
|
||||||
type Inclusion = inclusion::Module<Test>;
|
|
||||||
type System = frame_system::Module<Test>;
|
|
||||||
type Registrar = Module<Test>;
|
|
||||||
type Session = pallet_session::Module<Test>;
|
|
||||||
type Staking = pallet_staking::Module<Test>;
|
|
||||||
type Initializer = initializer::Module<Test>;
|
|
||||||
|
|
||||||
fn new_test_ext() -> TestExternalities {
|
fn new_test_ext() -> TestExternalities {
|
||||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -398,30 +398,31 @@ mod tests {
|
|||||||
testing::Header
|
testing::Header
|
||||||
};
|
};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
impl_outer_origin, impl_outer_dispatch, assert_ok, assert_noop, parameter_types,
|
assert_ok, assert_noop, parameter_types,
|
||||||
ord_parameter_types, dispatch::DispatchError::BadOrigin,
|
ord_parameter_types, dispatch::DispatchError::BadOrigin,
|
||||||
};
|
};
|
||||||
use frame_support::traits::Currency;
|
use frame_support::traits::Currency;
|
||||||
use pallet_balances::Error as BalancesError;
|
use pallet_balances::Error as BalancesError;
|
||||||
|
use crate::purchase;
|
||||||
|
|
||||||
impl_outer_origin! {
|
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||||
pub enum Origin for Test {}
|
type Block = frame_system::mocking::MockBlock<Test>;
|
||||||
}
|
|
||||||
|
|
||||||
impl_outer_dispatch! {
|
frame_support::construct_runtime!(
|
||||||
pub enum Call for Test where origin: Origin {
|
pub enum Test where
|
||||||
purchase::Purchase,
|
Block = Block,
|
||||||
vesting::Vesting,
|
NodeBlock = Block,
|
||||||
}
|
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||||
|
{
|
||||||
|
System: frame_system::{Module, Call, Config, Storage, Event<T>},
|
||||||
|
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
|
||||||
|
Vesting: pallet_vesting::{Module, Call, Storage, Config<T>, Event<T>},
|
||||||
|
Purchase: purchase::{Module, Call, Storage, Event<T>},
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
type AccountId = AccountId32;
|
type AccountId = AccountId32;
|
||||||
|
|
||||||
// For testing the module, we construct most of a mock runtime. This means
|
|
||||||
// first constructing a configuration type (`Test`) which `impl`s each of the
|
|
||||||
// configuration traits of modules we want to use.
|
|
||||||
#[derive(Clone, Eq, PartialEq)]
|
|
||||||
pub struct Test;
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const BlockHashCount: u32 = 250;
|
pub const BlockHashCount: u32 = 250;
|
||||||
}
|
}
|
||||||
@@ -439,10 +440,10 @@ mod tests {
|
|||||||
type AccountId = AccountId;
|
type AccountId = AccountId;
|
||||||
type Lookup = IdentityLookup<AccountId>;
|
type Lookup = IdentityLookup<AccountId>;
|
||||||
type Header = Header;
|
type Header = Header;
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = PalletInfo;
|
||||||
type AccountData = pallet_balances::AccountData<u64>;
|
type AccountData = pallet_balances::AccountData<u64>;
|
||||||
type OnNewAccount = ();
|
type OnNewAccount = ();
|
||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
@@ -456,7 +457,7 @@ mod tests {
|
|||||||
|
|
||||||
impl pallet_balances::Config for Test {
|
impl pallet_balances::Config for Test {
|
||||||
type Balance = u64;
|
type Balance = u64;
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type DustRemoval = ();
|
type DustRemoval = ();
|
||||||
type ExistentialDeposit = ExistentialDeposit;
|
type ExistentialDeposit = ExistentialDeposit;
|
||||||
type AccountStore = System;
|
type AccountStore = System;
|
||||||
@@ -469,7 +470,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_vesting::Config for Test {
|
impl pallet_vesting::Config for Test {
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
type BlockNumberToBalance = Identity;
|
type BlockNumberToBalance = Identity;
|
||||||
type MinVestedTransfer = MinVestedTransfer;
|
type MinVestedTransfer = MinVestedTransfer;
|
||||||
@@ -489,7 +490,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Config for Test {
|
impl Config for Test {
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
type VestingSchedule = Vesting;
|
type VestingSchedule = Vesting;
|
||||||
type ValidityOrigin = frame_system::EnsureSignedBy<ValidityOrigin, AccountId>;
|
type ValidityOrigin = frame_system::EnsureSignedBy<ValidityOrigin, AccountId>;
|
||||||
@@ -499,11 +500,6 @@ mod tests {
|
|||||||
type MaxUnlocked = MaxUnlocked;
|
type MaxUnlocked = MaxUnlocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
type System = frame_system::Module<Test>;
|
|
||||||
type Balances = pallet_balances::Module<Test>;
|
|
||||||
type Vesting = pallet_vesting::Module<Test>;
|
|
||||||
type Purchase = Module<Test>;
|
|
||||||
|
|
||||||
// This function basically just builds a genesis storage key/value store according to
|
// This function basically just builds a genesis storage key/value store according to
|
||||||
// our desired mockup. It also executes our `setup` function which sets up this pallet for use.
|
// our desired mockup. It also executes our `setup` function which sets up this pallet for use.
|
||||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||||
|
|||||||
@@ -944,21 +944,29 @@ mod tests {
|
|||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use sp_runtime::traits::{BlakeTwo256, Hash, IdentityLookup};
|
use sp_runtime::traits::{BlakeTwo256, Hash, IdentityLookup};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
impl_outer_origin, parameter_types, assert_ok, assert_noop,
|
parameter_types, assert_ok, assert_noop,
|
||||||
traits::{OnInitialize, OnFinalize}
|
traits::{OnInitialize, OnFinalize}
|
||||||
};
|
};
|
||||||
use pallet_balances;
|
use pallet_balances;
|
||||||
use primitives::v1::{BlockNumber, Header, Id as ParaId};
|
use primitives::v1::{BlockNumber, Header, Id as ParaId};
|
||||||
|
use crate::slots;
|
||||||
|
|
||||||
impl_outer_origin! {
|
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||||
pub enum Origin for 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>},
|
||||||
|
Slots: slots::{Module, Call, Storage, Event<T>},
|
||||||
|
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// For testing the module, we construct most of a mock runtime. This means
|
|
||||||
// first constructing a configuration type (`Test`) which `impl`s each of the
|
|
||||||
// configuration traits of modules we want to use.
|
|
||||||
#[derive(Clone, Eq, PartialEq)]
|
|
||||||
pub struct Test;
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const BlockHashCount: u32 = 250;
|
pub const BlockHashCount: u32 = 250;
|
||||||
}
|
}
|
||||||
@@ -968,7 +976,7 @@ mod tests {
|
|||||||
type BlockLength = ();
|
type BlockLength = ();
|
||||||
type DbWeight = ();
|
type DbWeight = ();
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Call = ();
|
type Call = Call;
|
||||||
type Index = u64;
|
type Index = u64;
|
||||||
type BlockNumber = BlockNumber;
|
type BlockNumber = BlockNumber;
|
||||||
type Hash = H256;
|
type Hash = H256;
|
||||||
@@ -976,10 +984,10 @@ mod tests {
|
|||||||
type AccountId = u64;
|
type AccountId = u64;
|
||||||
type Lookup = IdentityLookup<Self::AccountId>;
|
type Lookup = IdentityLookup<Self::AccountId>;
|
||||||
type Header = Header;
|
type Header = Header;
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = PalletInfo;
|
||||||
type AccountData = pallet_balances::AccountData<u64>;
|
type AccountData = pallet_balances::AccountData<u64>;
|
||||||
type OnNewAccount = ();
|
type OnNewAccount = ();
|
||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
@@ -993,7 +1001,7 @@ mod tests {
|
|||||||
|
|
||||||
impl pallet_balances::Config for Test {
|
impl pallet_balances::Config for Test {
|
||||||
type Balance = u64;
|
type Balance = u64;
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type DustRemoval = ();
|
type DustRemoval = ();
|
||||||
type ExistentialDeposit = ExistentialDeposit;
|
type ExistentialDeposit = ExistentialDeposit;
|
||||||
type AccountStore = System;
|
type AccountStore = System;
|
||||||
@@ -1066,7 +1074,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Config for Test {
|
impl Config for Test {
|
||||||
type Event = ();
|
type Event = Event;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
type Parachains = TestParachains;
|
type Parachains = TestParachains;
|
||||||
type LeasePeriod = LeasePeriod;
|
type LeasePeriod = LeasePeriod;
|
||||||
@@ -1074,11 +1082,6 @@ mod tests {
|
|||||||
type Randomness = RandomnessCollectiveFlip;
|
type Randomness = RandomnessCollectiveFlip;
|
||||||
}
|
}
|
||||||
|
|
||||||
type System = frame_system::Module<Test>;
|
|
||||||
type Balances = pallet_balances::Module<Test>;
|
|
||||||
type Slots = Module<Test>;
|
|
||||||
type RandomnessCollectiveFlip = pallet_randomness_collective_flip::Module<Test>;
|
|
||||||
|
|
||||||
// This function basically just builds a genesis storage key/value store according to
|
// This function basically just builds a genesis storage key/value store according to
|
||||||
// our desired mock up.
|
// our desired mock up.
|
||||||
fn new_test_ext() -> sp_io::TestExternalities {
|
fn new_test_ext() -> sp_io::TestExternalities {
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ mod tests {
|
|||||||
use frame_support::StorageValue;
|
use frame_support::StorageValue;
|
||||||
use frame_support::traits::{OnFinalize, OnInitialize};
|
use frame_support::traits::{OnFinalize, OnInitialize};
|
||||||
use parity_scale_codec::Encode;
|
use parity_scale_codec::Encode;
|
||||||
use crate::mock::{Configuration, new_test_ext, System, Dmp, GenesisConfig as MockGenesisConfig};
|
use crate::mock::{Configuration, new_test_ext, System, Dmp, MockGenesisConfig};
|
||||||
|
|
||||||
pub(crate) fn run_to_block(to: BlockNumber, new_session: Option<Vec<BlockNumber>>) {
|
pub(crate) fn run_to_block(to: BlockNumber, new_session: Option<Vec<BlockNumber>>) {
|
||||||
while System::block_number() < to {
|
while System::block_number() < to {
|
||||||
|
|||||||
@@ -1124,7 +1124,7 @@ impl<T: Config> Module<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::mock::{
|
use crate::mock::{
|
||||||
new_test_ext, Test, Configuration, Paras, Hrmp, System, GenesisConfig as MockGenesisConfig,
|
new_test_ext, Test, Configuration, Paras, Hrmp, System, MockGenesisConfig,
|
||||||
};
|
};
|
||||||
use frame_support::{assert_err, traits::Currency as _};
|
use frame_support::{assert_err, traits::Currency as _};
|
||||||
use primitives::v1::BlockNumber;
|
use primitives::v1::BlockNumber;
|
||||||
@@ -1198,7 +1198,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GenesisConfigBuilder {
|
impl GenesisConfigBuilder {
|
||||||
fn build(self) -> crate::mock::GenesisConfig {
|
fn build(self) -> crate::mock::MockGenesisConfig {
|
||||||
let mut genesis = default_genesis_config();
|
let mut genesis = default_genesis_config();
|
||||||
let config = &mut genesis.configuration.config;
|
let config = &mut genesis.configuration.config;
|
||||||
config.hrmp_channel_max_capacity = self.hrmp_channel_max_capacity;
|
config.hrmp_channel_max_capacity = self.hrmp_channel_max_capacity;
|
||||||
|
|||||||
@@ -907,7 +907,7 @@ mod tests {
|
|||||||
use sc_keystore::LocalKeystore;
|
use sc_keystore::LocalKeystore;
|
||||||
use crate::mock::{
|
use crate::mock::{
|
||||||
new_test_ext, Configuration, Paras, System, Inclusion,
|
new_test_ext, Configuration, Paras, System, Inclusion,
|
||||||
GenesisConfig as MockGenesisConfig, Test,
|
MockGenesisConfig, Test,
|
||||||
};
|
};
|
||||||
use crate::initializer::SessionChangeNotification;
|
use crate::initializer::SessionChangeNotification;
|
||||||
use crate::configuration::HostConfiguration;
|
use crate::configuration::HostConfiguration;
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use crate::mock::{
|
use crate::mock::{
|
||||||
new_test_ext, System, GenesisConfig as MockGenesisConfig, Test
|
new_test_ext, System, MockGenesisConfig, Test
|
||||||
};
|
};
|
||||||
|
|
||||||
mod limit_backed_candidates {
|
mod limit_backed_candidates {
|
||||||
@@ -278,7 +278,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use crate::mock::{
|
use crate::mock::{
|
||||||
new_test_ext, System, GenesisConfig as MockGenesisConfig, Test
|
new_test_ext, System, MockGenesisConfig, Test
|
||||||
};
|
};
|
||||||
|
|
||||||
use frame_support::traits::UnfilteredDispatchable;
|
use frame_support::traits::UnfilteredDispatchable;
|
||||||
|
|||||||
@@ -22,38 +22,36 @@ use sp_runtime::traits::{
|
|||||||
BlakeTwo256, IdentityLookup,
|
BlakeTwo256, IdentityLookup,
|
||||||
};
|
};
|
||||||
use primitives::v1::{AuthorityDiscoveryId, Balance, BlockNumber, Header, ValidatorIndex};
|
use primitives::v1::{AuthorityDiscoveryId, Balance, BlockNumber, Header, ValidatorIndex};
|
||||||
use frame_support::{
|
use frame_support::{parameter_types, traits::Randomness as RandomnessT};
|
||||||
impl_outer_origin, impl_outer_dispatch, impl_outer_event, parameter_types,
|
|
||||||
traits::Randomness as RandomnessT,
|
|
||||||
};
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crate::inclusion;
|
use crate::{
|
||||||
use crate as parachains;
|
inclusion, scheduler, dmp, ump, hrmp, session_info, paras, configuration,
|
||||||
|
initializer,
|
||||||
|
};
|
||||||
|
|
||||||
/// A test runtime struct.
|
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||||
#[derive(Clone, Eq, PartialEq)]
|
type Block = frame_system::mocking::MockBlock<Test>;
|
||||||
pub struct Test;
|
|
||||||
|
|
||||||
impl_outer_origin! {
|
frame_support::construct_runtime!(
|
||||||
pub enum Origin for Test {
|
pub enum Test where
|
||||||
parachains
|
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>},
|
||||||
|
Paras: paras::{Module, Origin, Call, Storage, Config<T>},
|
||||||
|
Configuration: configuration::{Module, Call, Storage, Config<T>},
|
||||||
|
Inclusion: inclusion::{Module, Call, Storage, Event<T>},
|
||||||
|
Scheduler: scheduler::{Module, Call, Storage},
|
||||||
|
Initializer: initializer::{Module, Call, Storage},
|
||||||
|
Dmp: dmp::{Module, Call, Storage},
|
||||||
|
Ump: ump::{Module, Call, Storage},
|
||||||
|
Hrmp: hrmp::{Module, Call, Storage},
|
||||||
|
SessionInfo: session_info::{Module, Call, Storage},
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
|
|
||||||
impl_outer_dispatch! {
|
|
||||||
pub enum Call for Test where origin: Origin {
|
|
||||||
initializer::Initializer,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_outer_event! {
|
|
||||||
pub enum TestEvent for Test {
|
|
||||||
frame_system<T>,
|
|
||||||
pallet_balances<T>,
|
|
||||||
inclusion<T>,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct TestRandomness;
|
pub struct TestRandomness;
|
||||||
|
|
||||||
@@ -83,10 +81,10 @@ impl frame_system::Config for Test {
|
|||||||
type AccountId = u64;
|
type AccountId = u64;
|
||||||
type Lookup = IdentityLookup<u64>;
|
type Lookup = IdentityLookup<u64>;
|
||||||
type Header = Header;
|
type Header = Header;
|
||||||
type Event = TestEvent;
|
type Event = Event;
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = PalletInfo;
|
||||||
type AccountData = pallet_balances::AccountData<u128>;
|
type AccountData = pallet_balances::AccountData<u128>;
|
||||||
type OnNewAccount = ();
|
type OnNewAccount = ();
|
||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
@@ -101,7 +99,7 @@ parameter_types! {
|
|||||||
impl pallet_balances::Config for Test {
|
impl pallet_balances::Config for Test {
|
||||||
type MaxLocks = ();
|
type MaxLocks = ();
|
||||||
type Balance = Balance;
|
type Balance = Balance;
|
||||||
type Event = TestEvent;
|
type Event = Event;
|
||||||
type DustRemoval = ();
|
type DustRemoval = ();
|
||||||
type ExistentialDeposit = ExistentialDeposit;
|
type ExistentialDeposit = ExistentialDeposit;
|
||||||
type AccountStore = System;
|
type AccountStore = System;
|
||||||
@@ -132,7 +130,7 @@ impl crate::hrmp::Config for Test {
|
|||||||
impl crate::scheduler::Config for Test { }
|
impl crate::scheduler::Config for Test { }
|
||||||
|
|
||||||
impl crate::inclusion::Config for Test {
|
impl crate::inclusion::Config for Test {
|
||||||
type Event = TestEvent;
|
type Event = Event;
|
||||||
type RewardValidators = TestRewardValidators;
|
type RewardValidators = TestRewardValidators;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,37 +181,8 @@ impl inclusion::RewardValidators for TestRewardValidators {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type System = frame_system::Module<Test>;
|
|
||||||
|
|
||||||
/// Mocked initializer.
|
|
||||||
pub type Initializer = crate::initializer::Module<Test>;
|
|
||||||
|
|
||||||
/// Mocked configuration.
|
|
||||||
pub type Configuration = crate::configuration::Module<Test>;
|
|
||||||
|
|
||||||
/// Mocked paras.
|
|
||||||
pub type Paras = crate::paras::Module<Test>;
|
|
||||||
|
|
||||||
/// Mocked DMP
|
|
||||||
pub type Dmp = crate::dmp::Module<Test>;
|
|
||||||
|
|
||||||
/// Mocked UMP
|
|
||||||
pub type Ump = crate::ump::Module<Test>;
|
|
||||||
|
|
||||||
/// Mocked HRMP
|
|
||||||
pub type Hrmp = crate::hrmp::Module<Test>;
|
|
||||||
|
|
||||||
/// Mocked scheduler.
|
|
||||||
pub type Scheduler = crate::scheduler::Module<Test>;
|
|
||||||
|
|
||||||
/// Mocked inclusion module.
|
|
||||||
pub type Inclusion = crate::inclusion::Module<Test>;
|
|
||||||
|
|
||||||
/// Mocked session info module.
|
|
||||||
pub type SessionInfo = crate::session_info::Module<Test>;
|
|
||||||
|
|
||||||
/// Create a new set of test externalities.
|
/// Create a new set of test externalities.
|
||||||
pub fn new_test_ext(state: GenesisConfig) -> TestExternalities {
|
pub fn new_test_ext(state: MockGenesisConfig) -> TestExternalities {
|
||||||
BACKING_REWARDS.with(|r| r.borrow_mut().clear());
|
BACKING_REWARDS.with(|r| r.borrow_mut().clear());
|
||||||
AVAILABILITY_REWARDS.with(|r| r.borrow_mut().clear());
|
AVAILABILITY_REWARDS.with(|r| r.borrow_mut().clear());
|
||||||
|
|
||||||
@@ -225,7 +194,7 @@ pub fn new_test_ext(state: GenesisConfig) -> TestExternalities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct GenesisConfig {
|
pub struct MockGenesisConfig {
|
||||||
pub system: frame_system::GenesisConfig,
|
pub system: frame_system::GenesisConfig,
|
||||||
pub configuration: crate::configuration::GenesisConfig<Test>,
|
pub configuration: crate::configuration::GenesisConfig<Test>,
|
||||||
pub paras: crate::paras::GenesisConfig<Test>,
|
pub paras: crate::paras::GenesisConfig<Test>,
|
||||||
|
|||||||
@@ -837,7 +837,7 @@ mod tests {
|
|||||||
use primitives::v1::BlockNumber;
|
use primitives::v1::BlockNumber;
|
||||||
use frame_support::traits::{OnFinalize, OnInitialize};
|
use frame_support::traits::{OnFinalize, OnInitialize};
|
||||||
|
|
||||||
use crate::mock::{new_test_ext, Paras, System, GenesisConfig as MockGenesisConfig};
|
use crate::mock::{new_test_ext, Paras, System, MockGenesisConfig};
|
||||||
use crate::configuration::HostConfiguration;
|
use crate::configuration::HostConfiguration;
|
||||||
|
|
||||||
fn run_to_block(to: BlockNumber, new_session: Option<Vec<BlockNumber>>) {
|
fn run_to_block(to: BlockNumber, new_session: Option<Vec<BlockNumber>>) {
|
||||||
|
|||||||
@@ -739,7 +739,7 @@ mod tests {
|
|||||||
use frame_support::traits::{OnFinalize, OnInitialize};
|
use frame_support::traits::{OnFinalize, OnInitialize};
|
||||||
use keyring::Sr25519Keyring;
|
use keyring::Sr25519Keyring;
|
||||||
|
|
||||||
use crate::mock::{new_test_ext, Configuration, Paras, System, Scheduler, GenesisConfig as MockGenesisConfig};
|
use crate::mock::{new_test_ext, Configuration, Paras, System, Scheduler, MockGenesisConfig};
|
||||||
use crate::initializer::SessionChangeNotification;
|
use crate::initializer::SessionChangeNotification;
|
||||||
use crate::configuration::HostConfiguration;
|
use crate::configuration::HostConfiguration;
|
||||||
use crate::paras::ParaGenesisArgs;
|
use crate::paras::ParaGenesisArgs;
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ impl<T: pallet_session::Config + Config> OneSessionHandler<T::AccountId> for Mod
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::mock::{
|
use crate::mock::{
|
||||||
new_test_ext, Configuration, SessionInfo, System, GenesisConfig as MockGenesisConfig,
|
new_test_ext, Configuration, SessionInfo, System, MockGenesisConfig,
|
||||||
Origin,
|
Origin,
|
||||||
};
|
};
|
||||||
use crate::initializer::SessionChangeNotification;
|
use crate::initializer::SessionChangeNotification;
|
||||||
|
|||||||
@@ -661,7 +661,7 @@ pub(crate) mod mock_sink {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use super::mock_sink::Probe;
|
use super::mock_sink::Probe;
|
||||||
use crate::mock::{Configuration, Ump, new_test_ext, GenesisConfig as MockGenesisConfig};
|
use crate::mock::{Configuration, Ump, new_test_ext, MockGenesisConfig};
|
||||||
use frame_support::IterableStorageMap;
|
use frame_support::IterableStorageMap;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
@@ -686,7 +686,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GenesisConfigBuilder {
|
impl GenesisConfigBuilder {
|
||||||
fn build(self) -> crate::mock::GenesisConfig {
|
fn build(self) -> crate::mock::MockGenesisConfig {
|
||||||
let mut genesis = default_genesis_config();
|
let mut genesis = default_genesis_config();
|
||||||
let config = &mut genesis.configuration.config;
|
let config = &mut genesis.configuration.config;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user