use construct_runtime for more pallet (#7974)

This commit is contained in:
Guillaume Thiolliere
2021-01-25 16:24:38 +01:00
committed by GitHub
parent 62d551a063
commit 681f8408ce
6 changed files with 81 additions and 54 deletions
+17 -12
View File
@@ -396,19 +396,27 @@ impl<T: Config> ProvideInherent for Module<T> {
#[cfg(test)]
mod tests {
use crate as pallet_authorship;
use super::*;
use sp_core::H256;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup}, testing::Header, generic::DigestItem,
};
use frame_support::{parameter_types, impl_outer_origin, ConsensusEngineId};
use frame_support::{parameter_types, ConsensusEngineId};
impl_outer_origin!{
pub enum Origin for Test where system = frame_system {}
}
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
#[derive(Clone, Eq, PartialEq)]
pub struct Test;
frame_support::construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
}
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
@@ -424,16 +432,16 @@ mod tests {
type Origin = Origin;
type Index = u64;
type BlockNumber = u64;
type Call = ();
type Call = Call;
type Hash = H256;
type Hashing = BlakeTwo256;
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 = ();
@@ -452,9 +460,6 @@ mod tests {
type EventHandler = ();
}
type System = frame_system::Module<Test>;
type Authorship = Module<Test>;
const TEST_ID: ConsensusEngineId = [1, 2, 3, 4];
pub struct AuthorGiven;