Skip to content

Commit 19f6ced

Browse files
migrate babe and authorship to use derive-impl (paritytech#1790)
Moving a babe and authorship pallets to the latest and greatest derive_impl. Part of paritytech#171 --------- Co-authored-by: Kian Paimani <[email protected]>
1 parent 66d782e commit 19f6ced

File tree

2 files changed

+7
-54
lines changed

2 files changed

+7
-54
lines changed

substrate/frame/authorship/src/lib.rs

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,10 @@ mod tests {
9797
use super::*;
9898
use crate as pallet_authorship;
9999
use codec::{Decode, Encode};
100-
use frame_support::{
101-
traits::{ConstU32, ConstU64},
102-
ConsensusEngineId,
103-
};
100+
use frame_support::{derive_impl, ConsensusEngineId};
104101
use sp_core::H256;
105102
use sp_runtime::{
106-
generic::DigestItem,
107-
testing::Header,
108-
traits::{BlakeTwo256, Header as HeaderT, IdentityLookup},
109-
BuildStorage,
103+
generic::DigestItem, testing::Header, traits::Header as HeaderT, BuildStorage,
110104
};
111105

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

116+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
122117
impl frame_system::Config for Test {
123-
type BaseCallFilter = frame_support::traits::Everything;
124-
type BlockWeights = ();
125-
type BlockLength = ();
126-
type DbWeight = ();
127-
type RuntimeOrigin = RuntimeOrigin;
128-
type Nonce = u64;
129-
type RuntimeCall = RuntimeCall;
130-
type Hash = H256;
131-
type Hashing = BlakeTwo256;
132-
type AccountId = u64;
133-
type Lookup = IdentityLookup<Self::AccountId>;
134118
type Block = Block;
135-
type RuntimeEvent = RuntimeEvent;
136-
type BlockHashCount = ConstU64<250>;
137-
type Version = ();
138-
type PalletInfo = PalletInfo;
139-
type AccountData = ();
140-
type OnNewAccount = ();
141-
type OnKilledAccount = ();
142-
type SystemWeightInfo = ();
143-
type SS58Prefix = ();
144-
type OnSetCode = ();
145-
type MaxConsumers = ConstU32<16>;
146119
}
147120

148121
impl pallet::Config for Test {

substrate/frame/babe/src/mock.rs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ use frame_election_provider_support::{
2424
onchain, SequentialPhragmen,
2525
};
2626
use frame_support::{
27-
parameter_types,
27+
derive_impl, parameter_types,
2828
traits::{ConstU128, ConstU32, ConstU64, KeyOwnerProofSystem, OnInitialize},
2929
};
3030
use pallet_session::historical as pallet_session_historical;
3131
use pallet_staking::FixedNominationsQuota;
3232
use sp_consensus_babe::{AuthorityId, AuthorityPair, Randomness, Slot, VrfSignature};
3333
use sp_core::{
3434
crypto::{KeyTypeId, Pair, VrfSecret},
35-
H256, U256,
35+
U256,
3636
};
3737
use sp_io;
3838
use sp_runtime::{
3939
curve::PiecewiseLinear,
4040
impl_opaque_keys,
4141
testing::{Digest, DigestItem, Header, TestXt},
42-
traits::{Header as _, IdentityLookup, OpaqueKeys},
42+
traits::{Header as _, OpaqueKeys},
4343
BuildStorage, Perbill,
4444
};
4545
use sp_staking::{EraIndex, SessionIndex};
@@ -63,30 +63,10 @@ frame_support::construct_runtime!(
6363
}
6464
);
6565

66+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
6667
impl frame_system::Config for Test {
67-
type BaseCallFilter = frame_support::traits::Everything;
68-
type BlockWeights = ();
69-
type BlockLength = ();
70-
type DbWeight = ();
71-
type RuntimeOrigin = RuntimeOrigin;
72-
type Nonce = u64;
73-
type RuntimeCall = RuntimeCall;
74-
type Hash = H256;
75-
type Version = ();
76-
type Hashing = sp_runtime::traits::BlakeTwo256;
77-
type AccountId = DummyValidatorId;
78-
type Lookup = IdentityLookup<Self::AccountId>;
7968
type Block = Block;
80-
type RuntimeEvent = RuntimeEvent;
81-
type BlockHashCount = ConstU64<250>;
82-
type PalletInfo = PalletInfo;
8369
type AccountData = pallet_balances::AccountData<u128>;
84-
type OnNewAccount = ();
85-
type OnKilledAccount = ();
86-
type SystemWeightInfo = ();
87-
type SS58Prefix = ();
88-
type OnSetCode = ();
89-
type MaxConsumers = frame_support::traits::ConstU32<16>;
9070
}
9171

9272
impl<C> frame_system::offchain::SendTransactionTypes<C> for Test

0 commit comments

Comments
 (0)