2021-02-24 14:12:24 +00:00
|
|
|
use crate as pallet_template;
|
|
|
|
use frame_support::parameter_types;
|
2021-07-20 12:44:58 +00:00
|
|
|
use frame_system as system;
|
|
|
|
use sp_core::H256;
|
2020-03-05 16:53:25 +00:00
|
|
|
use sp_runtime::{
|
2021-07-20 12:44:58 +00:00
|
|
|
testing::Header,
|
|
|
|
traits::{BlakeTwo256, IdentityLookup},
|
2020-03-05 16:53:25 +00:00
|
|
|
};
|
|
|
|
|
2021-02-24 14:12:24 +00:00
|
|
|
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
|
|
|
type Block = frame_system::mocking::MockBlock<Test>;
|
2020-03-05 16:53:25 +00:00
|
|
|
|
2020-07-25 12:35:30 +00:00
|
|
|
// Configure a mock runtime to test the pallet.
|
2021-02-24 14:12:24 +00:00
|
|
|
frame_support::construct_runtime!(
|
|
|
|
pub enum Test where
|
|
|
|
Block = Block,
|
|
|
|
NodeBlock = Block,
|
|
|
|
UncheckedExtrinsic = UncheckedExtrinsic,
|
|
|
|
{
|
2021-05-19 06:45:16 +00:00
|
|
|
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
|
|
|
|
TemplateModule: pallet_template::{Pallet, Call, Storage, Event<T>},
|
2021-02-24 14:12:24 +00:00
|
|
|
}
|
|
|
|
);
|
2020-07-25 12:35:30 +00:00
|
|
|
|
2020-03-05 16:53:25 +00:00
|
|
|
parameter_types! {
|
|
|
|
pub const BlockHashCount: u64 = 250;
|
2021-02-24 14:12:24 +00:00
|
|
|
pub const SS58Prefix: u8 = 42;
|
2020-03-05 16:53:25 +00:00
|
|
|
}
|
2020-07-25 12:35:30 +00:00
|
|
|
|
2021-02-24 14:12:24 +00:00
|
|
|
impl system::Config for Test {
|
2021-08-06 14:51:49 +00:00
|
|
|
type BaseCallFilter = frame_support::traits::AllowAll;
|
2021-02-24 14:12:24 +00:00
|
|
|
type BlockWeights = ();
|
|
|
|
type BlockLength = ();
|
|
|
|
type DbWeight = ();
|
2020-03-05 16:53:25 +00:00
|
|
|
type Origin = Origin;
|
2021-02-24 14:12:24 +00:00
|
|
|
type Call = Call;
|
2020-03-05 16:53:25 +00:00
|
|
|
type Index = u64;
|
|
|
|
type BlockNumber = u64;
|
|
|
|
type Hash = H256;
|
|
|
|
type Hashing = BlakeTwo256;
|
|
|
|
type AccountId = u64;
|
|
|
|
type Lookup = IdentityLookup<Self::AccountId>;
|
|
|
|
type Header = Header;
|
2021-02-24 14:12:24 +00:00
|
|
|
type Event = Event;
|
2020-03-05 16:53:25 +00:00
|
|
|
type BlockHashCount = BlockHashCount;
|
|
|
|
type Version = ();
|
2021-02-24 14:12:24 +00:00
|
|
|
type PalletInfo = PalletInfo;
|
2020-03-05 16:53:25 +00:00
|
|
|
type AccountData = ();
|
|
|
|
type OnNewAccount = ();
|
|
|
|
type OnKilledAccount = ();
|
2020-07-25 12:35:30 +00:00
|
|
|
type SystemWeightInfo = ();
|
2021-02-24 14:12:24 +00:00
|
|
|
type SS58Prefix = SS58Prefix;
|
2021-05-19 06:45:16 +00:00
|
|
|
type OnSetCode = ();
|
2020-03-05 16:53:25 +00:00
|
|
|
}
|
2020-07-25 12:35:30 +00:00
|
|
|
|
2021-02-24 14:12:24 +00:00
|
|
|
impl pallet_template::Config for Test {
|
|
|
|
type Event = Event;
|
2020-03-05 16:53:25 +00:00
|
|
|
}
|
2020-07-25 12:35:30 +00:00
|
|
|
|
|
|
|
// Build genesis storage according to the mock runtime.
|
2020-03-05 16:53:25 +00:00
|
|
|
pub fn new_test_ext() -> sp_io::TestExternalities {
|
|
|
|
system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
|
|
|
|
}
|