solutions/pallets/template/src/mock.rs

55 lines
1.4 KiB
Rust
Raw Normal View History

2021-02-24 14:12:24 +00:00
use crate as pallet_template;
2022-02-24 18:09:06 +00:00
use frame_support::traits::{ConstU16, ConstU64};
use sp_core::H256;
2020-03-05 16:53:25 +00:00
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
2020-03-05 16:53:25 +00:00
};
2021-02-24 14:12:24 +00:00
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
2021-02-24 14:12:24 +00:00
{
System: frame_system,
TemplateModule: pallet_template,
2021-02-24 14:12:24 +00:00
}
);
2020-07-25 12:35:30 +00:00
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
2021-02-24 14:12:24 +00:00
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
2020-03-05 16:53:25 +00:00
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
2022-02-24 18:09:06 +00:00
type BlockHashCount = ConstU64<250>;
2020-03-05 16:53:25 +00:00
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 = ();
2022-02-24 18:09:06 +00:00
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
2022-02-24 18:09:06 +00:00
type MaxConsumers = frame_support::traits::ConstU32<16>;
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 RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
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 {
frame_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
2020-03-05 16:53:25 +00:00
}