Skip to content

Commit a000ba2

Browse files
gupnikggwpez
andauthored
Moves all test runtimes to use derive_impl (paritytech#2409)
Step in paritytech#171 This PR adds `derive_impl` on all `frame_system` config impls for mock runtimes. The overridden configs are maintained as of now to ensure minimal changes. --------- Co-authored-by: Oliver Tale-Yazdi <[email protected]>
1 parent 15a18df commit a000ba2

File tree

104 files changed

+376
-238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+376
-238
lines changed

substrate/bin/node-template/pallets/template/src/mock.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use crate as pallet_template;
2-
use frame_support::traits::{ConstU16, ConstU64};
2+
use frame_support::{
3+
derive_impl,
4+
traits::{ConstU16, ConstU64},
5+
};
36
use sp_core::H256;
47
use sp_runtime::{
58
traits::{BlakeTwo256, IdentityLookup},
@@ -17,6 +20,7 @@ frame_support::construct_runtime!(
1720
}
1821
);
1922

23+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
2024
impl frame_system::Config for Test {
2125
type BaseCallFilter = frame_support::traits::Everything;
2226
type BlockWeights = ();

substrate/client/rpc-spec-v2/src/chain_head/subscription/inner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ impl<Block: BlockT, BE: Backend<Block>> SubscriptionsInner<Block, BE> {
763763
// blocks.
764764
for hash in hashes.clone() {
765765
if !sub.contains_block(hash) {
766-
return Err(SubscriptionManagementError::BlockHashAbsent);
766+
return Err(SubscriptionManagementError::BlockHashAbsent)
767767
}
768768
}
769769

substrate/frame/asset-conversion/src/mock.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use super::*;
2121
use crate as pallet_asset_conversion;
2222

2323
use frame_support::{
24-
construct_runtime,
24+
construct_runtime, derive_impl,
2525
instances::{Instance1, Instance2},
2626
ord_parameter_types, parameter_types,
2727
traits::{AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64},
@@ -48,6 +48,7 @@ construct_runtime!(
4848
}
4949
);
5050

51+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
5152
impl frame_system::Config for Test {
5253
type BaseCallFilter = frame_support::traits::Everything;
5354
type BlockWeights = ();

substrate/frame/asset-rate/src/mock.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
//! The crate's mock.
1919
2020
use crate as pallet_asset_rate;
21-
use frame_support::traits::{ConstU16, ConstU64};
21+
use frame_support::{
22+
derive_impl,
23+
traits::{ConstU16, ConstU64},
24+
};
2225
use sp_core::H256;
2326
use sp_runtime::{
2427
traits::{BlakeTwo256, IdentityLookup},
@@ -36,6 +39,7 @@ frame_support::construct_runtime!(
3639
}
3740
);
3841

42+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
3943
impl frame_system::Config for Test {
4044
type BaseCallFilter = frame_support::traits::Everything;
4145
type BlockWeights = ();

substrate/frame/assets/src/mock.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate as pallet_assets;
2222

2323
use codec::Encode;
2424
use frame_support::{
25-
construct_runtime, parameter_types,
25+
construct_runtime, derive_impl, parameter_types,
2626
traits::{AsEnsureOriginWithArg, ConstU32, ConstU64},
2727
};
2828
use sp_core::H256;
@@ -46,6 +46,7 @@ construct_runtime!(
4646
type AccountId = u64;
4747
type AssetId = u32;
4848

49+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
4950
impl frame_system::Config for Test {
5051
type BaseCallFilter = frame_support::traits::Everything;
5152
type BlockWeights = ();

substrate/frame/atomic-swap/src/tests.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
use super::*;
2121
use crate as pallet_atomic_swap;
2222

23-
use frame_support::traits::{ConstU32, ConstU64};
23+
use frame_support::{
24+
derive_impl,
25+
traits::{ConstU32, ConstU64},
26+
};
2427
use sp_core::H256;
2528
use sp_runtime::{
2629
traits::{BlakeTwo256, IdentityLookup},
@@ -38,6 +41,7 @@ frame_support::construct_runtime!(
3841
}
3942
);
4043

44+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
4145
impl frame_system::Config for Test {
4246
type BaseCallFilter = frame_support::traits::Everything;
4347
type BlockWeights = ();

substrate/frame/aura/src/mock.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
use crate as pallet_aura;
2323
use frame_support::{
24-
parameter_types,
24+
derive_impl, parameter_types,
2525
traits::{ConstU32, ConstU64, DisabledValidators},
2626
};
2727
use sp_consensus_aura::{ed25519::AuthorityId, AuthorityIndex};
@@ -41,6 +41,7 @@ frame_support::construct_runtime!(
4141
}
4242
);
4343

44+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
4445
impl frame_system::Config for Test {
4546
type BaseCallFilter = frame_support::traits::Everything;
4647
type BlockWeights = ();

substrate/frame/authority-discovery/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ mod tests {
169169
use super::*;
170170
use crate as pallet_authority_discovery;
171171
use frame_support::{
172-
parameter_types,
172+
derive_impl, parameter_types,
173173
traits::{ConstU32, ConstU64},
174174
};
175175
use sp_application_crypto::Pair;
@@ -225,6 +225,7 @@ mod tests {
225225
pub const Offset: BlockNumber = 0;
226226
}
227227

228+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
228229
impl frame_system::Config for Test {
229230
type BaseCallFilter = frame_support::traits::Everything;
230231
type BlockWeights = ();

substrate/frame/balances/src/tests/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use crate::{self as pallet_balances, AccountData, Config, CreditOf, Error, Pallet};
2323
use codec::{Decode, Encode, MaxEncodedLen};
2424
use frame_support::{
25-
assert_err, assert_noop, assert_ok, assert_storage_noop,
25+
assert_err, assert_noop, assert_ok, assert_storage_noop, derive_impl,
2626
dispatch::{DispatchInfo, GetDispatchInfo},
2727
parameter_types,
2828
traits::{
@@ -90,6 +90,8 @@ parameter_types! {
9090
);
9191
pub static ExistentialDeposit: u64 = 1;
9292
}
93+
94+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
9395
impl frame_system::Config for Test {
9496
type BaseCallFilter = frame_support::traits::Everything;
9597
type BlockWeights = BlockWeights;

substrate/frame/benchmarking/pov/src/benchmarking.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ frame_benchmarking::benchmarks! {
339339

340340
#[cfg(test)]
341341
mod mock {
342+
use frame_support::derive_impl;
342343
use sp_runtime::{testing::H256, BuildStorage};
343344

344345
type AccountId = u64;
@@ -354,6 +355,7 @@ mod mock {
354355
}
355356
);
356357

358+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
357359
impl frame_system::Config for Test {
358360
type BaseCallFilter = frame_support::traits::Everything;
359361
type BlockWeights = ();

substrate/frame/benchmarking/pov/src/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ fn noop_is_free() {
162162
}
163163

164164
mod mock {
165+
use frame_support::derive_impl;
165166
use sp_runtime::testing::H256;
166167

167168
type Block = frame_system::mocking::MockBlock<Test>;
@@ -174,6 +175,7 @@ mod mock {
174175
}
175176
);
176177

178+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
177179
impl frame_system::Config for Test {
178180
type BaseCallFilter = frame_support::traits::Everything;
179181
type BlockWeights = ();

substrate/frame/benchmarking/src/baseline.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ benchmarks! {
110110

111111
#[cfg(test)]
112112
pub mod mock {
113+
use frame_support::derive_impl;
113114
use sp_runtime::{testing::H256, BuildStorage};
114115

115116
type AccountId = u64;
@@ -124,6 +125,7 @@ pub mod mock {
124125
}
125126
);
126127

128+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
127129
impl frame_system::Config for Test {
128130
type BaseCallFilter = frame_support::traits::Everything;
129131
type BlockWeights = ();

substrate/frame/benchmarking/src/tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
#![cfg(test)]
2121

22-
use frame_support::{parameter_types, traits::ConstU32};
22+
use frame_support::{derive_impl, parameter_types, traits::ConstU32};
2323
use sp_runtime::{
2424
testing::H256,
2525
traits::{BlakeTwo256, IdentityLookup},
@@ -75,6 +75,7 @@ frame_support::construct_runtime!(
7575
}
7676
);
7777

78+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
7879
impl frame_system::Config for Test {
7980
type BaseCallFilter = frame_support::traits::Everything;
8081
type BlockWeights = ();

substrate/frame/benchmarking/src/tests_instance.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
#![cfg(test)]
2121

22-
use frame_support::traits::ConstU32;
22+
use frame_support::{derive_impl, traits::ConstU32};
2323
use sp_runtime::{
2424
testing::H256,
2525
traits::{BlakeTwo256, IdentityLookup},
@@ -85,6 +85,7 @@ frame_support::construct_runtime!(
8585
}
8686
);
8787

88+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
8889
impl frame_system::Config for Test {
8990
type BaseCallFilter = frame_support::traits::Everything;
9091
type BlockWeights = ();

substrate/frame/bounties/src/tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use super::*;
2323
use crate as pallet_bounties;
2424

2525
use frame_support::{
26-
assert_noop, assert_ok, parameter_types,
26+
assert_noop, assert_ok, derive_impl, parameter_types,
2727
traits::{
2828
tokens::{PayFromAccount, UnityAssetBalanceConversion},
2929
ConstU32, ConstU64, OnInitialize,
@@ -59,6 +59,7 @@ parameter_types! {
5959

6060
type Balance = u64;
6161

62+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
6263
impl frame_system::Config for Test {
6364
type BaseCallFilter = frame_support::traits::Everything;
6465
type BlockWeights = ();

substrate/frame/broker/src/mock.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
use crate::{test_fungibles::TestFungibles, *};
2121
use frame_support::{
22-
assert_ok, ensure, ord_parameter_types, parameter_types,
22+
assert_ok, derive_impl, ensure, ord_parameter_types, parameter_types,
2323
traits::{
2424
fungible::{Balanced, Credit, Inspect, ItemOf, Mutate},
2525
nonfungible::Inspect as NftInspect,
@@ -47,6 +47,7 @@ frame_support::construct_runtime!(
4747
}
4848
);
4949

50+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
5051
impl frame_system::Config for Test {
5152
type BaseCallFilter = frame_support::traits::Everything;
5253
type BlockWeights = ();

substrate/frame/child-bounties/src/tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use super::*;
2323
use crate as pallet_child_bounties;
2424

2525
use frame_support::{
26-
assert_noop, assert_ok, parameter_types,
26+
assert_noop, assert_ok, derive_impl, parameter_types,
2727
traits::{
2828
tokens::{PayFromAccount, UnityAssetBalanceConversion},
2929
ConstU32, ConstU64, OnInitialize,
@@ -62,6 +62,7 @@ parameter_types! {
6262

6363
type Balance = u64;
6464

65+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
6566
impl frame_system::Config for Test {
6667
type BaseCallFilter = frame_support::traits::Everything;
6768
type BlockWeights = ();

substrate/frame/collective/src/tests.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use super::{Event as CollectiveEvent, *};
1919
use crate as pallet_collective;
2020
use frame_support::{
21-
assert_noop, assert_ok,
21+
assert_noop, assert_ok, derive_impl,
2222
dispatch::Pays,
2323
parameter_types,
2424
traits::{ConstU32, ConstU64, StorageVersion},
@@ -90,6 +90,8 @@ parameter_types! {
9090
frame_system::limits::BlockWeights::simple_max(Weight::MAX);
9191
pub static MaxProposalWeight: Weight = default_max_proposal_weight();
9292
}
93+
94+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
9395
impl frame_system::Config for Test {
9496
type BaseCallFilter = frame_support::traits::Everything;
9597
type BlockWeights = BlockWeights;

substrate/frame/contracts/mock-network/src/parachain.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::{
2323
};
2424
use core::marker::PhantomData;
2525
use frame_support::{
26-
construct_runtime, parameter_types,
26+
construct_runtime, derive_impl, parameter_types,
2727
traits::{AsEnsureOriginWithArg, Contains, ContainsPair, Everything, EverythingBut, Nothing},
2828
weights::{
2929
constants::{WEIGHT_PROOF_SIZE_PER_MB, WEIGHT_REF_TIME_PER_SECOND},
@@ -53,6 +53,7 @@ parameter_types! {
5353
pub const BlockHashCount: u64 = 250;
5454
}
5555

56+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
5657
impl frame_system::Config for Runtime {
5758
type RuntimeOrigin = RuntimeOrigin;
5859
type RuntimeCall = RuntimeCall;

substrate/frame/contracts/mock-network/src/relay_chain.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//! Relay chain runtime mock.
1818
1919
use frame_support::{
20-
construct_runtime, parameter_types,
20+
construct_runtime, derive_impl, parameter_types,
2121
traits::{Contains, Everything, Nothing},
2222
weights::Weight,
2323
};
@@ -47,6 +47,7 @@ parameter_types! {
4747
pub const BlockHashCount: u64 = 250;
4848
}
4949

50+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
5051
impl frame_system::Config for Runtime {
5152
type RuntimeOrigin = RuntimeOrigin;
5253
type RuntimeCall = RuntimeCall;

substrate/frame/contracts/src/tests.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use assert_matches::assert_matches;
4242
use codec::Encode;
4343
use frame_support::{
4444
assert_err, assert_err_ignore_postinfo, assert_err_with_weight, assert_noop, assert_ok,
45+
derive_impl,
4546
dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo},
4647
parameter_types,
4748
storage::child,
@@ -332,6 +333,8 @@ parameter_types! {
332333
);
333334
pub static ExistentialDeposit: u64 = 1;
334335
}
336+
337+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
335338
impl frame_system::Config for Test {
336339
type BaseCallFilter = frame_support::traits::Everything;
337340
type BlockWeights = BlockWeights;

substrate/frame/conviction-voting/src/tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use std::collections::BTreeMap;
2121

2222
use frame_support::{
23-
assert_noop, assert_ok, parameter_types,
23+
assert_noop, assert_ok, derive_impl, parameter_types,
2424
traits::{ConstU32, ConstU64, Contains, Polling, VoteTally},
2525
};
2626
use sp_core::H256;
@@ -51,6 +51,7 @@ impl Contains<RuntimeCall> for BaseFilter {
5151
}
5252
}
5353

54+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
5455
impl frame_system::Config for Test {
5556
type BaseCallFilter = BaseFilter;
5657
type BlockWeights = ();

substrate/frame/core-fellowship/src/tests.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use std::collections::BTreeMap;
2121

2222
use frame_support::{
23-
assert_noop, assert_ok, ord_parameter_types,
23+
assert_noop, assert_ok, derive_impl, ord_parameter_types,
2424
pallet_prelude::Weight,
2525
parameter_types,
2626
traits::{tokens::GetSalary, ConstU32, ConstU64, Everything, IsInVec, TryMapSuccess},
@@ -50,6 +50,8 @@ parameter_types! {
5050
pub BlockWeights: frame_system::limits::BlockWeights =
5151
frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1_000_000, u64::max_value()));
5252
}
53+
54+
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
5355
impl frame_system::Config for Test {
5456
type BaseCallFilter = Everything;
5557
type BlockWeights = ();

0 commit comments

Comments
 (0)