Skip to content
Snippets Groups Projects
Commit 993b74c9 authored by Gerben van de Wiel's avatar Gerben van de Wiel Committed by GitHub
Browse files

Let mock in pallet-template use construct_runtime (#7991)

parent 12fe61a9
No related merge requests found
......@@ -5056,6 +5056,7 @@ dependencies = [
"frame-support",
"frame-system",
"parity-scale-codec",
"serde",
"sp-core",
"sp-io",
"sp-runtime",
......
......@@ -15,6 +15,9 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "1.3.6", default-features = false, features = ["derive"] }
[dev-dependencies]
serde = { version = "1.0.101" }
[dependencies.frame-support]
default-features = false
version = "2.0.0"
......
use crate::{Module, Config};
use crate as pallet_template;
use sp_core::H256;
use frame_support::{impl_outer_origin, parameter_types};
use frame_support::parameter_types;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup}, testing::Header,
};
use frame_system as system;
impl_outer_origin! {
pub enum Origin for Test {}
}
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
// Configure a mock runtime to test the pallet.
frame_support::construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
TemplateModule: pallet_template::{Module, Call, Storage, Event<T>},
}
);
#[derive(Clone, Eq, PartialEq)]
pub struct Test;
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const SS58Prefix: u8 = 42;
......@@ -25,7 +32,7 @@ impl system::Config for Test {
type BlockLength = ();
type DbWeight = ();
type Origin = Origin;
type Call = ();
type Call = Call;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
......@@ -33,10 +40,10 @@ impl system::Config for Test {
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = ();
type Event = Event;
type BlockHashCount = BlockHashCount;
type Version = ();
type PalletInfo = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
......@@ -44,12 +51,10 @@ impl system::Config for Test {
type SS58Prefix = SS58Prefix;
}
impl Config for Test {
type Event = ();
impl pallet_template::Config for Test {
type Event = Event;
}
pub type TemplateModule = Module<Test>;
// Build genesis storage according to the mock runtime.
pub fn new_test_ext() -> sp_io::TestExternalities {
system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment