mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +00:00
move some pallet test to use construct_runtime (#8049)
* migrate some more pallets * revert example-offcahin-worker as not straightforward * fix mmr
This commit is contained in:
committed by
GitHub
parent
6dea5494f3
commit
86498a1a0c
@@ -21,23 +21,31 @@
|
||||
|
||||
use std::cell::RefCell;
|
||||
|
||||
use crate::{Module, Config};
|
||||
use crate::Config;
|
||||
use sp_runtime::Perbill;
|
||||
use sp_staking::{SessionIndex, offence::{ReportOffence, OffenceError}};
|
||||
use sp_runtime::testing::{Header, UintAuthorityId, TestXt};
|
||||
use sp_runtime::traits::{IdentityLookup, BlakeTwo256, ConvertInto};
|
||||
use sp_core::H256;
|
||||
use frame_support::{impl_outer_origin, impl_outer_dispatch, parameter_types};
|
||||
use frame_support::parameter_types;
|
||||
use crate as imonline;
|
||||
use pallet_session::historical as pallet_session_historical;
|
||||
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Runtime {}
|
||||
}
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
|
||||
type Block = frame_system::mocking::MockBlock<Runtime>;
|
||||
|
||||
impl_outer_dispatch! {
|
||||
pub enum Call for Runtime where origin: Origin {
|
||||
imonline::ImOnline,
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Runtime where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
{
|
||||
System: frame_system::{Module, Call, Config, Storage, Event<T>},
|
||||
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
|
||||
ImOnline: imonline::{Module, Call, Storage, Config<T>, Event<T>},
|
||||
Historical: pallet_session_historical::{Module},
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
thread_local! {
|
||||
pub static VALIDATORS: RefCell<Option<Vec<u64>>> = RefCell::new(Some(vec![
|
||||
@@ -99,9 +107,6 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
t.into()
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Runtime;
|
||||
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: u64 = 250;
|
||||
pub BlockWeights: frame_system::limits::BlockWeights =
|
||||
@@ -122,10 +127,10 @@ impl frame_system::Config for Runtime {
|
||||
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 = ();
|
||||
@@ -149,7 +154,7 @@ impl pallet_session::Config for Runtime {
|
||||
type ValidatorId = u64;
|
||||
type ValidatorIdOf = ConvertInto;
|
||||
type Keys = UintAuthorityId;
|
||||
type Event = ();
|
||||
type Event = Event;
|
||||
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
||||
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
||||
type WeightInfo = ();
|
||||
@@ -177,7 +182,7 @@ parameter_types! {
|
||||
|
||||
impl Config for Runtime {
|
||||
type AuthorityId = UintAuthorityId;
|
||||
type Event = ();
|
||||
type Event = Event;
|
||||
type ReportUnresponsiveness = OffenceHandler;
|
||||
type ValidatorSet = Historical;
|
||||
type SessionDuration = Period;
|
||||
@@ -192,12 +197,6 @@ impl<LocalCall> frame_system::offchain::SendTransactionTypes<LocalCall> for Runt
|
||||
type Extrinsic = Extrinsic;
|
||||
}
|
||||
|
||||
/// Im Online module.
|
||||
pub type ImOnline = Module<Runtime>;
|
||||
pub type System = frame_system::Module<Runtime>;
|
||||
pub type Session = pallet_session::Module<Runtime>;
|
||||
pub type Historical = pallet_session::historical::Module<Runtime>;
|
||||
|
||||
pub fn advance_session() {
|
||||
let now = System::block_number().max(1);
|
||||
System::set_block_number(now + 1);
|
||||
|
||||
Reference in New Issue
Block a user