Skip to content

Commit

Permalink
migrate babe and authorship to use derive-impl (paritytech#1790)
Browse files Browse the repository at this point in the history
Moving a babe and authorship pallets to the latest and greatest
derive_impl.

Part of paritytech#171

---------

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
  • Loading branch information
Dmitry-Borodin and kianenigma authored Oct 7, 2023
1 parent 66d782e commit 19f6ced
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 54 deletions.
33 changes: 3 additions & 30 deletions substrate/frame/authorship/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,10 @@ mod tests {
use super::*;
use crate as pallet_authorship;
use codec::{Decode, Encode};
use frame_support::{
traits::{ConstU32, ConstU64},
ConsensusEngineId,
};
use frame_support::{derive_impl, ConsensusEngineId};
use sp_core::H256;
use sp_runtime::{
generic::DigestItem,
testing::Header,
traits::{BlakeTwo256, Header as HeaderT, IdentityLookup},
BuildStorage,
generic::DigestItem, testing::Header, traits::Header as HeaderT, BuildStorage,
};

type Block = frame_system::mocking::MockBlock<Test>;
Expand All @@ -119,30 +113,9 @@ mod tests {
}
);

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
}

impl pallet::Config for Test {
Expand Down
28 changes: 4 additions & 24 deletions substrate/frame/babe/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ use frame_election_provider_support::{
onchain, SequentialPhragmen,
};
use frame_support::{
parameter_types,
derive_impl, parameter_types,
traits::{ConstU128, ConstU32, ConstU64, KeyOwnerProofSystem, OnInitialize},
};
use pallet_session::historical as pallet_session_historical;
use pallet_staking::FixedNominationsQuota;
use sp_consensus_babe::{AuthorityId, AuthorityPair, Randomness, Slot, VrfSignature};
use sp_core::{
crypto::{KeyTypeId, Pair, VrfSecret},
H256, U256,
U256,
};
use sp_io;
use sp_runtime::{
curve::PiecewiseLinear,
impl_opaque_keys,
testing::{Digest, DigestItem, Header, TestXt},
traits::{Header as _, IdentityLookup, OpaqueKeys},
traits::{Header as _, OpaqueKeys},
BuildStorage, Perbill,
};
use sp_staking::{EraIndex, SessionIndex};
Expand All @@ -63,30 +63,10 @@ frame_support::construct_runtime!(
}
);

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = H256;
type Version = ();
type Hashing = sp_runtime::traits::BlakeTwo256;
type AccountId = DummyValidatorId;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u128>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}

impl<C> frame_system::offchain::SendTransactionTypes<C> for Test
Expand Down

0 comments on commit 19f6ced

Please sign in to comment.