mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +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:
@@ -232,7 +232,7 @@ mod tests {
|
||||
use frame_support::StorageValue;
|
||||
use frame_support::traits::{OnFinalize, OnInitialize};
|
||||
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>>) {
|
||||
while System::block_number() < to {
|
||||
|
||||
@@ -1124,7 +1124,7 @@ impl<T: Config> Module<T> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
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 primitives::v1::BlockNumber;
|
||||
@@ -1198,7 +1198,7 @@ mod tests {
|
||||
}
|
||||
|
||||
impl GenesisConfigBuilder {
|
||||
fn build(self) -> crate::mock::GenesisConfig {
|
||||
fn build(self) -> crate::mock::MockGenesisConfig {
|
||||
let mut genesis = default_genesis_config();
|
||||
let config = &mut genesis.configuration.config;
|
||||
config.hrmp_channel_max_capacity = self.hrmp_channel_max_capacity;
|
||||
|
||||
@@ -907,7 +907,7 @@ mod tests {
|
||||
use sc_keystore::LocalKeystore;
|
||||
use crate::mock::{
|
||||
new_test_ext, Configuration, Paras, System, Inclusion,
|
||||
GenesisConfig as MockGenesisConfig, Test,
|
||||
MockGenesisConfig, Test,
|
||||
};
|
||||
use crate::initializer::SessionChangeNotification;
|
||||
use crate::configuration::HostConfiguration;
|
||||
|
||||
@@ -225,7 +225,7 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
use crate::mock::{
|
||||
new_test_ext, System, GenesisConfig as MockGenesisConfig, Test
|
||||
new_test_ext, System, MockGenesisConfig, Test
|
||||
};
|
||||
|
||||
mod limit_backed_candidates {
|
||||
@@ -278,7 +278,7 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
use crate::mock::{
|
||||
new_test_ext, System, GenesisConfig as MockGenesisConfig, Test
|
||||
new_test_ext, System, MockGenesisConfig, Test
|
||||
};
|
||||
|
||||
use frame_support::traits::UnfilteredDispatchable;
|
||||
|
||||
@@ -22,38 +22,36 @@ use sp_runtime::traits::{
|
||||
BlakeTwo256, IdentityLookup,
|
||||
};
|
||||
use primitives::v1::{AuthorityDiscoveryId, Balance, BlockNumber, Header, ValidatorIndex};
|
||||
use frame_support::{
|
||||
impl_outer_origin, impl_outer_dispatch, impl_outer_event, parameter_types,
|
||||
traits::Randomness as RandomnessT,
|
||||
};
|
||||
use frame_support::{parameter_types, traits::Randomness as RandomnessT};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use crate::inclusion;
|
||||
use crate as parachains;
|
||||
use crate::{
|
||||
inclusion, scheduler, dmp, ump, hrmp, session_info, paras, configuration,
|
||||
initializer,
|
||||
};
|
||||
|
||||
/// A test runtime struct.
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
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 {
|
||||
parachains
|
||||
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>},
|
||||
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;
|
||||
|
||||
@@ -83,10 +81,10 @@ impl frame_system::Config for Test {
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<u64>;
|
||||
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 = ();
|
||||
@@ -101,7 +99,7 @@ parameter_types! {
|
||||
impl pallet_balances::Config for Test {
|
||||
type MaxLocks = ();
|
||||
type Balance = Balance;
|
||||
type Event = TestEvent;
|
||||
type Event = Event;
|
||||
type DustRemoval = ();
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type AccountStore = System;
|
||||
@@ -132,7 +130,7 @@ impl crate::hrmp::Config for Test {
|
||||
impl crate::scheduler::Config for Test { }
|
||||
|
||||
impl crate::inclusion::Config for Test {
|
||||
type Event = TestEvent;
|
||||
type Event = Event;
|
||||
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.
|
||||
pub fn new_test_ext(state: GenesisConfig) -> TestExternalities {
|
||||
pub fn new_test_ext(state: MockGenesisConfig) -> TestExternalities {
|
||||
BACKING_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)]
|
||||
pub struct GenesisConfig {
|
||||
pub struct MockGenesisConfig {
|
||||
pub system: frame_system::GenesisConfig,
|
||||
pub configuration: crate::configuration::GenesisConfig<Test>,
|
||||
pub paras: crate::paras::GenesisConfig<Test>,
|
||||
|
||||
@@ -837,7 +837,7 @@ mod tests {
|
||||
use primitives::v1::BlockNumber;
|
||||
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;
|
||||
|
||||
fn run_to_block(to: BlockNumber, new_session: Option<Vec<BlockNumber>>) {
|
||||
|
||||
@@ -739,7 +739,7 @@ mod tests {
|
||||
use frame_support::traits::{OnFinalize, OnInitialize};
|
||||
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::configuration::HostConfiguration;
|
||||
use crate::paras::ParaGenesisArgs;
|
||||
|
||||
@@ -165,7 +165,7 @@ impl<T: pallet_session::Config + Config> OneSessionHandler<T::AccountId> for Mod
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::mock::{
|
||||
new_test_ext, Configuration, SessionInfo, System, GenesisConfig as MockGenesisConfig,
|
||||
new_test_ext, Configuration, SessionInfo, System, MockGenesisConfig,
|
||||
Origin,
|
||||
};
|
||||
use crate::initializer::SessionChangeNotification;
|
||||
|
||||
@@ -661,7 +661,7 @@ pub(crate) mod mock_sink {
|
||||
mod tests {
|
||||
use super::*;
|
||||
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 std::collections::HashSet;
|
||||
|
||||
@@ -686,7 +686,7 @@ mod tests {
|
||||
}
|
||||
|
||||
impl GenesisConfigBuilder {
|
||||
fn build(self) -> crate::mock::GenesisConfig {
|
||||
fn build(self) -> crate::mock::MockGenesisConfig {
|
||||
let mut genesis = default_genesis_config();
|
||||
let config = &mut genesis.configuration.config;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user