-
wangjj9219 authoredwangjj9219 authored
mock.rs 1.89 KiB
//! Mocks for the gradually-update module.
#![cfg(test)]
use super::*;
use frame_support::{construct_runtime, parameter_types};
use sp_core::H256;
use sp_runtime::{testing::Header, traits::IdentityLookup};
use crate as gradually_update;
parameter_types! {
pub const BlockHashCount: u64 = 250;
}
pub type AccountId = u128;
pub type BlockNumber = u64;
impl frame_system::Config for Runtime {
type Origin = Origin;
type Index = u64;
type BlockNumber = BlockNumber;
type Call = Call;
type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockWeights = ();
type BlockLength = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type DbWeight = ();
type BaseCallFilter = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
}
parameter_types! {
pub const UpdateFrequency: BlockNumber = 10;
}
impl Config for Runtime {
type Event = Event;
type UpdateFrequency = UpdateFrequency;
type DispatchOrigin = frame_system::EnsureRoot<AccountId>;
type WeightInfo = ();
}
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
type Block = frame_system::mocking::MockBlock<Runtime>;
construct_runtime!(
pub enum Runtime where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Storage, Config, Event<T>},
GraduallyUpdateModule: gradually_update::{Module, Storage, Call, Event<T>},
}
);
pub struct ExtBuilder;
impl Default for ExtBuilder {
fn default() -> Self {
ExtBuilder
}
}
impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
let t = frame_system::GenesisConfig::default()
.build_storage::<Runtime>()
.unwrap();
t.into()
}
}