git.delta.rocks / unique-network / refs/commits / e133193fa046

difftreelog

source

pallets/nft/src/mock.rs2.0 KiBsourcehistory
1// Creating mock runtime here23use crate::{Module, Trait};4use frame_support::{5    impl_outer_origin, parameter_types, 6    weights::{ 7        Weight,8        constants::{ BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND },9    }};10use frame_system as system;11use sp_core::H256;12use sp_runtime::{13    testing::Header,14    traits::{BlakeTwo256, IdentityLookup},15    Perbill,16};1718impl_outer_origin! {19	pub enum Origin for Test {20	}21}2223// For testing the pallet, we construct most of a mock runtime. This means24// first constructing a configuration type (`Test`) which `impl`s each of the25// configuration traits of pallets we want to use.26#[derive(Clone, Eq, PartialEq)]27pub struct Test;28parameter_types! {29	pub const BlockHashCount: u64 = 250;30	pub const MaximumBlockWeight: Weight = 1024;31	pub const MaximumBlockLength: u32 = 2 * 1024;32	pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);33    pub const MaximumExtrinsicWeight: Weight = 10 * WEIGHT_PER_SECOND;34}3536impl system::Trait for Test {37	type Origin = Origin;38	type Call = ();39	type Index = u64;40	type BlockNumber = u64;41    type BaseCallFilter = ();42    type DbWeight = RocksDbWeight;43    type BlockExecutionWeight = BlockExecutionWeight;44	type Hash = H256;45	type Hashing = BlakeTwo256;46	type AccountId = u64;47	type Lookup = IdentityLookup<Self::AccountId>;48	type Header = Header;49	type Event = ();50	type BlockHashCount = BlockHashCount;51    type ExtrinsicBaseWeight = ExtrinsicBaseWeight;52	type MaximumBlockWeight = MaximumBlockWeight;53	type MaximumBlockLength = MaximumBlockLength;54	type AvailableBlockRatio = AvailableBlockRatio;55	type Version = ();56	type ModuleToIndex = ();57	type AccountData = ();58	type OnNewAccount = ();59	type OnKilledAccount = ();60}6162impl Trait for Test {63	type Event = ();64}6566pub type TemplateModule = Module<Test>;6768// This function basically just builds a genesis storage key/value store according to69// our desired mockup.70pub fn new_test_ext() -> sp_io::TestExternalities {71	system::GenesisConfig::default()72		.build_storage::<Test>()73		.unwrap()74		.into()75}