Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moves all test runtimes to use derive_impl #2409

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cumulus/pallets/xcmp-queue/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use core::marker::PhantomData;
use cumulus_pallet_parachain_system::AnyRelayNumber;
use cumulus_primitives_core::{ChannelInfo, IsSystem, ParaId};
use frame_support::{
parameter_types,
derive_impl, parameter_types,
traits::{ConstU32, Everything, Nothing, OriginTrait},
BoundedSlice,
};
Expand Down Expand Up @@ -55,6 +55,7 @@ parameter_types! {

type AccountId = u64;

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
gupnik marked this conversation as resolved.
Show resolved Hide resolved
impl frame_system::Config for Test {
type BaseCallFilter = Everything;
type BlockWeights = ();
Expand Down
3 changes: 2 additions & 1 deletion cumulus/parachains/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<T: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation> for AssetsFr
mod tests {
use super::*;
use frame_support::{
parameter_types,
derive_impl, parameter_types,
traits::{ConstU32, FindAuthor, ValidatorRegistration},
PalletId,
};
Expand Down Expand Up @@ -155,6 +155,7 @@ mod tests {
pub const MaxReserves: u32 = 50;
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
Expand Down
3 changes: 2 additions & 1 deletion cumulus/parachains/pallets/collective-content/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
pub use crate as pallet_collective_content;
use crate::WeightInfo;
use frame_support::{
ord_parameter_types, parameter_types,
derive_impl, ord_parameter_types, parameter_types,
traits::{ConstU32, ConstU64},
weights::Weight,
};
Expand Down Expand Up @@ -55,6 +55,7 @@ impl pallet_collective_content::Config for Test {
type WeightInfo = CCWeightInfo;
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = ();
type BlockWeights = ();
Expand Down
4 changes: 3 additions & 1 deletion cumulus/parachains/runtimes/starters/seedling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use sp_version::RuntimeVersion;

// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime,
construct_runtime, derive_impl,
dispatch::DispatchClass,
genesis_builder_helper::{build_config, create_default_config},
parameter_types,
Expand Down Expand Up @@ -134,6 +134,8 @@ parameter_types! {
.build_or_panic();
pub const SS58Prefix: u8 = 42;
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Runtime {
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
Expand Down
3 changes: 2 additions & 1 deletion cumulus/parachains/runtimes/starters/shell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use sp_version::RuntimeVersion;

// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime,
construct_runtime, derive_impl,
dispatch::DispatchClass,
genesis_builder_helper::{build_config, create_default_config},
parameter_types,
Expand Down Expand Up @@ -143,6 +143,7 @@ parameter_types! {
pub const SS58Prefix: u8 = 42;
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Runtime {
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
Expand Down
3 changes: 2 additions & 1 deletion cumulus/parachains/runtimes/testing/penpal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub mod xcm_config;
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use frame_support::{
construct_runtime,
construct_runtime, derive_impl,
dispatch::DispatchClass,
genesis_builder_helper::{build_config, create_default_config},
pallet_prelude::Weight,
Expand Down Expand Up @@ -323,6 +323,7 @@ parameter_types! {

// Configure FRAME pallets to include in runtime.

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Runtime {
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use sp_version::RuntimeVersion;

// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime,
construct_runtime, derive_impl,
dispatch::DispatchClass,
genesis_builder_helper::{build_config, create_default_config},
match_types, parameter_types,
Expand Down Expand Up @@ -184,6 +184,7 @@ parameter_types! {
pub const SS58Prefix: u8 = 42;
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Runtime {
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
Expand Down
4 changes: 3 additions & 1 deletion polkadot/runtime/common/src/assigned_slots/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ mod tests {

use crate::{assigned_slots, mock::TestRegistrar, slots};
use ::test_helpers::{dummy_head_data, dummy_validation_code};
use frame_support::{assert_noop, assert_ok, parameter_types};
use frame_support::{assert_noop, assert_ok, derive_impl, parameter_types};
use frame_system::EnsureRoot;
use pallet_balances;
use primitives::BlockNumber;
Expand Down Expand Up @@ -679,6 +679,8 @@ mod tests {
parameter_types! {
pub const BlockHashCount: u32 = 250;
}

#[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 = ();
Expand Down
5 changes: 4 additions & 1 deletion polkadot/runtime/common/src/auctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,8 @@ mod tests {
use crate::{auctions, mock::TestRegistrar};
use ::test_helpers::{dummy_hash, dummy_head_data, dummy_validation_code};
use frame_support::{
assert_noop, assert_ok, assert_storage_noop, ord_parameter_types, parameter_types,
assert_noop, assert_ok, assert_storage_noop, derive_impl, ord_parameter_types,
parameter_types,
traits::{ConstU32, EitherOfDiverse, OnFinalize, OnInitialize},
};
use frame_system::{EnsureRoot, EnsureSignedBy};
Expand Down Expand Up @@ -705,6 +706,8 @@ mod tests {
parameter_types! {
pub const BlockHashCount: u32 = 250;
}

#[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 = ();
Expand Down
4 changes: 3 additions & 1 deletion polkadot/runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ mod tests {
use crate::claims;
use claims::Call as ClaimsCall;
use frame_support::{
assert_err, assert_noop, assert_ok,
assert_err, assert_noop, assert_ok, derive_impl,
dispatch::{GetDispatchInfo, Pays},
ord_parameter_types, parameter_types,
traits::{ConstU32, ExistenceRequirement, WithdrawReasons},
Expand Down Expand Up @@ -739,6 +739,8 @@ mod tests {
parameter_types! {
pub const BlockHashCount: u32 = 250;
}

#[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 = ();
Expand Down
3 changes: 2 additions & 1 deletion polkadot/runtime/common/src/crowdloan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ mod tests {
use super::*;

use frame_support::{
assert_noop, assert_ok, parameter_types,
assert_noop, assert_ok, derive_impl, parameter_types,
traits::{ConstU32, OnFinalize, OnInitialize},
};
use primitives::Id as ParaId;
Expand Down Expand Up @@ -900,6 +900,7 @@ mod tests {

type BlockNumber = u64;

#[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 = ();
Expand Down
2 changes: 2 additions & 0 deletions polkadot/runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ pub mod benchmarks {
mod tests {
use super::*;
use frame_support::{
derive_impl,
dispatch::DispatchClass,
parameter_types,
traits::{
Expand Down Expand Up @@ -237,6 +238,7 @@ mod tests {
pub const AvailableBlockRatio: Perbill = Perbill::one();
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
Expand Down
3 changes: 2 additions & 1 deletion polkadot/runtime/common/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
traits::{AuctionStatus, Auctioneer, Leaser, Registrar as RegistrarT},
};
use frame_support::{
assert_noop, assert_ok, parameter_types,
assert_noop, assert_ok, derive_impl, parameter_types,
traits::{ConstU32, Currency, OnFinalize, OnInitialize},
weights::Weight,
PalletId,
Expand Down Expand Up @@ -114,6 +114,7 @@ parameter_types! {
);
}

#[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 = BlockWeights;
Expand Down
3 changes: 2 additions & 1 deletion polkadot/runtime/common/src/paras_registrar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ mod tests {
mock::conclude_pvf_checking, paras_registrar, traits::Registrar as RegistrarTrait,
};
use frame_support::{
assert_noop, assert_ok,
assert_noop, assert_ok, derive_impl,
error::BadOrigin,
parameter_types,
traits::{ConstU32, OnFinalize, OnInitialize},
Expand Down Expand Up @@ -751,6 +751,7 @@ mod tests {
limits::BlockLength::max_with_normal_ratio(4 * 1024 * 1024, NORMAL_RATIO);
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
Expand Down
4 changes: 3 additions & 1 deletion polkadot/runtime/common/src/purchase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ mod tests {
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use crate::purchase;
use frame_support::{
assert_noop, assert_ok, ord_parameter_types, parameter_types,
assert_noop, assert_ok, derive_impl, ord_parameter_types, parameter_types,
traits::{Currency, WithdrawReasons},
};
use sp_runtime::{
Expand All @@ -511,6 +511,8 @@ mod tests {
parameter_types! {
pub const BlockHashCount: u32 = 250;
}

#[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 = ();
Expand Down
4 changes: 3 additions & 1 deletion polkadot/runtime/common/src/slots/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ mod tests {

use crate::{mock::TestRegistrar, slots};
use ::test_helpers::{dummy_head_data, dummy_validation_code};
use frame_support::{assert_noop, assert_ok, parameter_types};
use frame_support::{assert_noop, assert_ok, derive_impl, parameter_types};
use frame_system::EnsureRoot;
use pallet_balances;
use primitives::BlockNumber;
Expand All @@ -529,6 +529,8 @@ mod tests {
parameter_types! {
pub const BlockHashCount: u32 = 250;
}

#[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 = ();
Expand Down
3 changes: 2 additions & 1 deletion polkadot/runtime/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
};

use frame_support::{
assert_ok, parameter_types,
assert_ok, derive_impl, parameter_types,
traits::{
Currency, ProcessMessage, ProcessMessageError, ValidatorSet, ValidatorSetWithIdentification,
},
Expand Down Expand Up @@ -94,6 +94,7 @@ parameter_types! {

pub type AccountId = u64;

#[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 = BlockWeights;
Expand Down
2 changes: 2 additions & 0 deletions polkadot/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ parameter_types! {
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, u64::MAX));
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = Everything;
type BlockWeights = ();
Expand Down
1 change: 1 addition & 0 deletions polkadot/xcm/pallet-xcm-benchmarks/src/generic/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ parameter_types! {
frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, u64::MAX));
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = Everything;
type BlockWeights = ();
Expand Down
3 changes: 2 additions & 1 deletion polkadot/xcm/pallet-xcm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use codec::Encode;
use frame_support::{
construct_runtime, match_types, parameter_types,
construct_runtime, derive_impl, match_types, parameter_types,
traits::{
AsEnsureOriginWithArg, ConstU128, ConstU32, Contains, Equals, Everything, EverythingBut,
Nothing,
Expand Down Expand Up @@ -239,6 +239,7 @@ parameter_types! {
pub const BlockHashCount: u64 = 250;
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
Expand Down
2 changes: 1 addition & 1 deletion polkadot/xcm/procedural/tests/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
fn ui() {
// Only run the ui tests when `RUN_UI_TESTS` is set.
if std::env::var("RUN_UI_TESTS").is_err() {
return;
return
}

// As trybuild is using `cargo check`, we don't need the real WASM binaries.
Expand Down
3 changes: 2 additions & 1 deletion polkadot/xcm/xcm-builder/tests/mock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use frame_support::{
construct_runtime, parameter_types,
construct_runtime, derive_impl, parameter_types,
traits::{ConstU32, Everything, Nothing},
weights::Weight,
};
Expand Down Expand Up @@ -76,6 +76,7 @@ parameter_types! {
pub const BlockHashCount: u64 = 250;
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
Expand Down
3 changes: 2 additions & 1 deletion polkadot/xcm/xcm-simulator/example/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use codec::{Decode, Encode};
use core::marker::PhantomData;
use frame_support::{
construct_runtime, parameter_types,
construct_runtime, derive_impl, parameter_types,
traits::{ContainsPair, EnsureOrigin, EnsureOriginWithArg, Everything, EverythingBut, Nothing},
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
};
Expand Down Expand Up @@ -63,6 +63,7 @@ parameter_types! {
pub const BlockHashCount: u64 = 250;
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
Expand Down
3 changes: 2 additions & 1 deletion polkadot/xcm/xcm-simulator/example/src/relay_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Relay chain runtime mock.

use frame_support::{
construct_runtime, parameter_types,
construct_runtime, derive_impl, parameter_types,
traits::{AsEnsureOriginWithArg, Everything, Nothing, ProcessMessage, ProcessMessageError},
weights::{Weight, WeightMeter},
};
Expand Down Expand Up @@ -49,6 +49,7 @@ parameter_types! {
pub const BlockHashCount: u64 = 250;
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
Expand Down
Loading