git.delta.rocks / unique-network / refs/commits / 2e2e4a210638

difftreelog

source

pallets/nft/src/mock.rs2.3 KiBsourcehistory
1// Creating mock runtime here23use crate::{Module, Trait};4use frame_support::{5    impl_outer_origin, parameter_types,6    weights::{7        constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},8        Weight,9    },10};11use frame_system as system;12use sp_core::H256;13use sp_runtime::{14    testing::Header,15    traits::{BlakeTwo256, IdentityLookup, Saturating},16    Perbill,17};1819impl_outer_origin! {20    pub enum Origin for Test {}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 MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()34    .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();35}3637impl system::Trait for Test {38    type Origin = Origin;39    type Call = ();40    type Index = u64;41    type BlockNumber = u64;42    type Hash = H256;43    type Hashing = BlakeTwo256;44    type AccountId = u64;45    type Lookup = IdentityLookup<Self::AccountId>;46    type Header = Header;47    type Event = ();48    type BlockHashCount = BlockHashCount;49    type MaximumBlockWeight = MaximumBlockWeight;50    type MaximumBlockLength = MaximumBlockLength;51    type AvailableBlockRatio = AvailableBlockRatio;52    type BaseCallFilter = ();53    type DbWeight = RocksDbWeight;54    type BlockExecutionWeight = BlockExecutionWeight;55    type ExtrinsicBaseWeight = ExtrinsicBaseWeight;56    type MaximumExtrinsicWeight = MaximumExtrinsicWeight;57    type Version = ();58    type ModuleToIndex = ();59    type AccountData = ();60    type OnNewAccount = ();61    type OnKilledAccount = ();62}63impl Trait for Test {64    type Event = ();65}66pub 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}