Skip to content
Snippets Groups Projects
mock.rs 2.17 KiB
Newer Older
//! Mocks for the gradually-update module.

#![cfg(test)]

use super::*;
brettkolodny's avatar
brettkolodny committed
use frame_support::{construct_runtime, parameter_types};
use sp_core::H256;
Shaopeng Wang's avatar
Shaopeng Wang committed
use sp_runtime::{testing::Header, traits::IdentityLookup};
brettkolodny's avatar
brettkolodny committed
use crate as gradually_update;

parameter_types! {
	pub const BlockHashCount: u64 = 250;
}

pub type AccountId = u128;
pub type BlockNumber = u64;

Shaopeng Wang's avatar
Shaopeng Wang committed
impl frame_system::Config for Runtime {
	type Origin = Origin;
	type Index = u64;
	type BlockNumber = BlockNumber;
brettkolodny's avatar
brettkolodny committed
	type Call = Call;
	type Hash = H256;
	type Hashing = ::sp_runtime::traits::BlakeTwo256;
	type AccountId = AccountId;
	type Lookup = IdentityLookup<Self::AccountId>;
	type Header = Header;
brettkolodny's avatar
brettkolodny committed
	type Event = Event;
	type BlockHashCount = BlockHashCount;
Shaopeng Wang's avatar
Shaopeng Wang committed
	type BlockWeights = ();
	type BlockLength = ();
	type Version = ();
brettkolodny's avatar
brettkolodny committed
	type PalletInfo = PalletInfo;
	type AccountData = ();
	type OnNewAccount = ();
	type OnKilledAccount = ();
	type DbWeight = ();
	type BaseCallFilter = ();
Xiliang Chen's avatar
Xiliang Chen committed
	type SystemWeightInfo = ();
Shaopeng Wang's avatar
Shaopeng Wang committed
	type SS58Prefix = ();
	type OnSetCode = ();
}

parameter_types! {
	pub const UpdateFrequency: BlockNumber = 10;
	pub MaxGraduallyUpdate: u32 = 3;
	pub MaxStorageKeyBytes: u32 = 100_000;
	pub MaxStorageValueBytes: u32 = 100_000;
Shaopeng Wang's avatar
Shaopeng Wang committed
impl Config for Runtime {
brettkolodny's avatar
brettkolodny committed
	type Event = Event;
	type UpdateFrequency = UpdateFrequency;
	type DispatchOrigin = frame_system::EnsureRoot<AccountId>;
zjb0807's avatar
zjb0807 committed
	type WeightInfo = ();
	type MaxGraduallyUpdate = MaxGraduallyUpdate;
	type MaxStorageKeyBytes = MaxStorageKeyBytes;
	type MaxStorageValueBytes = MaxStorageValueBytes;
wangjj9219's avatar
wangjj9219 committed
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
type Block = frame_system::mocking::MockBlock<Runtime>;
brettkolodny's avatar
brettkolodny committed

construct_runtime!(
	pub enum Runtime where
		Block = Block,
		NodeBlock = Block,
		UncheckedExtrinsic = UncheckedExtrinsic,
	{
		System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
		GraduallyUpdateModule: gradually_update::{Pallet, Storage, Call, Event<T>},
brettkolodny's avatar
brettkolodny committed
	}
);

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()
	}
}