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

difftreelog

source

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