2020-03-05 16:53:25 +00:00
|
|
|
// Creating mock runtime here
|
|
|
|
|
|
|
|
use crate::{Module, Trait};
|
|
|
|
use sp_core::H256;
|
|
|
|
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
|
|
|
use sp_runtime::{
|
|
|
|
traits::{BlakeTwo256, IdentityLookup}, testing::Header, Perbill,
|
|
|
|
};
|
2020-04-15 11:33:19 +00:00
|
|
|
use frame_system as system;
|
2020-03-05 16:53:25 +00:00
|
|
|
|
|
|
|
impl_outer_origin! {
|
|
|
|
pub enum Origin for Test {}
|
|
|
|
}
|
|
|
|
|
|
|
|
// For testing the pallet, we construct most of a mock runtime. This means
|
|
|
|
// first constructing a configuration type (`Test`) which `impl`s each of the
|
|
|
|
// configuration traits of pallets we want to use.
|
|
|
|
#[derive(Clone, Eq, PartialEq)]
|
|
|
|
pub struct Test;
|
|
|
|
parameter_types! {
|
|
|
|
pub const BlockHashCount: u64 = 250;
|
|
|
|
pub const MaximumBlockWeight: Weight = 1024;
|
|
|
|
pub const MaximumBlockLength: u32 = 2 * 1024;
|
|
|
|
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
|
|
|
|
}
|
|
|
|
impl system::Trait for Test {
|
2020-06-27 16:14:55 +00:00
|
|
|
type BaseCallFilter = ();
|
2020-03-05 16:53:25 +00:00
|
|
|
type Origin = Origin;
|
|
|
|
type Call = ();
|
|
|
|
type Index = u64;
|
|
|
|
type BlockNumber = u64;
|
|
|
|
type Hash = H256;
|
|
|
|
type Hashing = BlakeTwo256;
|
|
|
|
type AccountId = u64;
|
|
|
|
type Lookup = IdentityLookup<Self::AccountId>;
|
|
|
|
type Header = Header;
|
|
|
|
type Event = ();
|
|
|
|
type BlockHashCount = BlockHashCount;
|
|
|
|
type MaximumBlockWeight = MaximumBlockWeight;
|
2020-05-06 20:25:03 +00:00
|
|
|
type DbWeight = ();
|
2020-05-16 13:32:11 +00:00
|
|
|
type BlockExecutionWeight = ();
|
2020-05-06 20:25:03 +00:00
|
|
|
type ExtrinsicBaseWeight = ();
|
2020-05-25 21:48:38 +00:00
|
|
|
type MaximumExtrinsicWeight = MaximumBlockWeight;
|
2020-05-16 13:32:11 +00:00
|
|
|
type MaximumBlockLength = MaximumBlockLength;
|
|
|
|
type AvailableBlockRatio = AvailableBlockRatio;
|
2020-03-05 16:53:25 +00:00
|
|
|
type Version = ();
|
|
|
|
type ModuleToIndex = ();
|
|
|
|
type AccountData = ();
|
|
|
|
type OnNewAccount = ();
|
|
|
|
type OnKilledAccount = ();
|
|
|
|
}
|
|
|
|
impl Trait for Test {
|
|
|
|
type Event = ();
|
|
|
|
}
|
|
|
|
pub type TemplateModule = Module<Test>;
|
|
|
|
|
|
|
|
// This function basically just builds a genesis storage key/value store according to
|
|
|
|
// our desired mockup.
|
|
|
|
pub fn new_test_ext() -> sp_io::TestExternalities {
|
|
|
|
system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
|
|
|
|
}
|