git.delta.rocks / unique-network / refs/commits / 623e2e26812b

difftreelog

source

pallets/template/src/mock.rs1.7 KiBsourcehistory
1// Creating mock runtime here23use crate::{Module, Trait};4use sp_core::H256;5use frame_support::{impl_outer_origin, parameter_types, weights::Weight};6use sp_runtime::{7	traits::{BlakeTwo256, IdentityLookup}, testing::Header, Perbill,8};9use frame_system as system;1011impl_outer_origin! {12	pub enum Origin for Test {}13}1415// For testing the pallet, we construct most of a mock runtime. This means16// first constructing a configuration type (`Test`) which `impl`s each of the17// configuration traits of pallets we want to use.18#[derive(Clone, Eq, PartialEq)]19pub struct Test;20parameter_types! {21	pub const BlockHashCount: u64 = 250;22	pub const MaximumBlockWeight: Weight = 1024;23	pub const MaximumBlockLength: u32 = 2 * 1024;24	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);25}26impl system::Trait for Test {27	type Origin = Origin;28	type Call = ();29	type Index = u64;30	type BlockNumber = u64;31	type Hash = H256;32	type Hashing = BlakeTwo256;33	type AccountId = u64;34	type Lookup = IdentityLookup<Self::AccountId>;35	type Header = Header;36	type Event = ();37	type BlockHashCount = BlockHashCount;38	type MaximumBlockWeight = MaximumBlockWeight;39	type MaximumBlockLength = MaximumBlockLength;40	type AvailableBlockRatio = AvailableBlockRatio;41	type Version = ();42	type ModuleToIndex = ();43	type AccountData = ();44	type OnNewAccount = ();45	type OnKilledAccount = ();46}47impl Trait for Test {48	type Event = ();49}50pub type TemplateModule = Module<Test>;5152// This function basically just builds a genesis storage key/value store according to53// our desired mockup.54pub fn new_test_ext() -> sp_io::TestExternalities {55	system::GenesisConfig::default().build_storage::<Test>().unwrap().into()56}