mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 05:21:08 +00:00
Migrate some more pallets to construct_runtime (#7975)
* WIP converting balances tests to construct_runtime * Converting balances tests_local to construct_runtime * Fix up system and balances Events * Use static Call instance in tests * Migrate indices to construct_runtime * Migrate babe test to construct_runtime * Update frame/indices/src/mock.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Update frame/babe/src/mock.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Update frame/babe/src/mock.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Remove redundant import Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
//! Test utilities
|
||||
|
||||
use codec::Encode;
|
||||
use super::{Config, Module, CurrentSlot};
|
||||
use crate::{self as pallet_babe, Config, CurrentSlot};
|
||||
use sp_runtime::{
|
||||
Perbill, impl_opaque_keys,
|
||||
curve::PiecewiseLinear,
|
||||
@@ -27,7 +27,7 @@ use sp_runtime::{
|
||||
};
|
||||
use frame_system::InitKind;
|
||||
use frame_support::{
|
||||
impl_outer_dispatch, impl_outer_origin, parameter_types, StorageValue,
|
||||
parameter_types, StorageValue,
|
||||
traits::{KeyOwnerProofSystem, OnInitialize},
|
||||
weights::Weight,
|
||||
};
|
||||
@@ -37,23 +37,29 @@ use sp_consensus_babe::{AuthorityId, AuthorityPair, SlotNumber};
|
||||
use sp_consensus_vrf::schnorrkel::{VRFOutput, VRFProof};
|
||||
use sp_staking::SessionIndex;
|
||||
use pallet_staking::EraIndex;
|
||||
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
impl_outer_dispatch! {
|
||||
pub enum Call for Test where origin: Origin {
|
||||
babe::Babe,
|
||||
staking::Staking,
|
||||
}
|
||||
}
|
||||
use pallet_session::historical as pallet_session_historical;
|
||||
|
||||
type DummyValidatorId = u64;
|
||||
|
||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Test;
|
||||
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>},
|
||||
Historical: pallet_session_historical::{Module},
|
||||
Offences: pallet_offences::{Module, Call, Storage, Event},
|
||||
Babe: pallet_babe::{Module, Call, Storage, Config, Inherent, ValidateUnsigned},
|
||||
Staking: pallet_staking::{Module, Call, Storage, Config<T>, Event<T>},
|
||||
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
|
||||
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
|
||||
}
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: u64 = 250;
|
||||
@@ -79,9 +85,9 @@ impl frame_system::Config for Test {
|
||||
type AccountId = DummyValidatorId;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Event = ();
|
||||
type Event = Event;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type PalletInfo = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
type AccountData = pallet_balances::AccountData<u128>;
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
@@ -104,7 +110,7 @@ impl_opaque_keys! {
|
||||
}
|
||||
|
||||
impl pallet_session::Config for Test {
|
||||
type Event = ();
|
||||
type Event = Event;
|
||||
type ValidatorId = <Self as frame_system::Config>::AccountId;
|
||||
type ValidatorIdOf = pallet_staking::StashOf<Self>;
|
||||
type ShouldEndSession = Babe;
|
||||
@@ -151,7 +157,7 @@ impl pallet_balances::Config for Test {
|
||||
type MaxLocks = ();
|
||||
type Balance = u128;
|
||||
type DustRemoval = ();
|
||||
type Event = ();
|
||||
type Event = Event;
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type AccountStore = System;
|
||||
type WeightInfo = ();
|
||||
@@ -182,7 +188,7 @@ parameter_types! {
|
||||
impl pallet_staking::Config for Test {
|
||||
type RewardRemainder = ();
|
||||
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
|
||||
type Event = ();
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
type Slash = ();
|
||||
type Reward = ();
|
||||
@@ -210,7 +216,7 @@ parameter_types! {
|
||||
}
|
||||
|
||||
impl pallet_offences::Config for Test {
|
||||
type Event = ();
|
||||
type Event = Event;
|
||||
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
|
||||
type OnOffenceHandler = Staking;
|
||||
type WeightSoftLimit = OffencesWeightSoftLimit;
|
||||
@@ -235,15 +241,6 @@ impl Config for Test {
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
pub type Balances = pallet_balances::Module<Test>;
|
||||
pub type Historical = pallet_session::historical::Module<Test>;
|
||||
pub type Offences = pallet_offences::Module<Test>;
|
||||
pub type Session = pallet_session::Module<Test>;
|
||||
pub type Staking = pallet_staking::Module<Test>;
|
||||
pub type System = frame_system::Module<Test>;
|
||||
pub type Timestamp = pallet_timestamp::Module<Test>;
|
||||
pub type Babe = Module<Test>;
|
||||
|
||||
pub fn go_to_block(n: u64, s: u64) {
|
||||
use frame_support::traits::OnFinalize;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user