Skip to content

Commit

Permalink
frame: use derive-impl for beefy and mmr pallets (paritytech#1867)
Browse files Browse the repository at this point in the history
  • Loading branch information
acatangiu authored Oct 13, 2023
1 parent 8320600 commit 82bfe28
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 84 deletions.
30 changes: 4 additions & 26 deletions substrate/frame/beefy-mmr/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ use std::vec;

use codec::Encode;
use frame_support::{
construct_runtime, parameter_types,
traits::{ConstU16, ConstU32, ConstU64},
construct_runtime, derive_impl, parameter_types,
traits::{ConstU32, ConstU64},
};
use sp_consensus_beefy::mmr::MmrLeafVersion;
use sp_core::H256;
use sp_io::TestExternalities;
use sp_runtime::{
app_crypto::ecdsa::Public,
impl_opaque_keys,
traits::{BlakeTwo256, ConvertInto, IdentityLookup, Keccak256, OpaqueKeys},
traits::{ConvertInto, Keccak256, OpaqueKeys},
BuildStorage,
};
use sp_state_machine::BasicExternalities;
Expand Down Expand Up @@ -58,30 +57,9 @@ 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 Hash = H256;
type RuntimeCall = RuntimeCall;
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 = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
}

impl pallet_session::Config for Test {
Expand Down
36 changes: 6 additions & 30 deletions substrate/frame/beefy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,15 @@ use frame_election_provider_support::{
onchain, SequentialPhragmen,
};
use frame_support::{
construct_runtime, parameter_types,
traits::{ConstU16, ConstU32, ConstU64, KeyOwnerProofSystem, OnFinalize, OnInitialize},
construct_runtime, derive_impl, parameter_types,
traits::{ConstU32, ConstU64, KeyOwnerProofSystem, OnFinalize, OnInitialize},
};
use pallet_session::historical as pallet_session_historical;
use sp_core::{crypto::KeyTypeId, ConstU128, H256};
use sp_core::{crypto::KeyTypeId, ConstU128};
use sp_io::TestExternalities;
use sp_runtime::{
app_crypto::ecdsa::Public,
curve::PiecewiseLinear,
impl_opaque_keys,
testing::TestXt,
traits::{BlakeTwo256, IdentityLookup, OpaqueKeys},
BuildStorage, Perbill,
app_crypto::ecdsa::Public, curve::PiecewiseLinear, impl_opaque_keys, testing::TestXt,
traits::OpaqueKeys, BuildStorage, Perbill,
};
use sp_staking::{EraIndex, SessionIndex};
use sp_state_machine::BasicExternalities;
Expand Down Expand Up @@ -69,30 +65,10 @@ 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 Hash = H256;
type RuntimeCall = RuntimeCall;
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 = pallet_balances::AccountData<u128>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
}

impl<C> frame_system::offchain::SendTransactionTypes<C> for Test
Expand Down
31 changes: 3 additions & 28 deletions substrate/frame/merkle-mountain-range/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ use crate as pallet_mmr;
use crate::*;

use codec::{Decode, Encode};
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64},
};
use sp_core::H256;
use frame_support::{derive_impl, parameter_types};
use sp_mmr_primitives::{Compact, LeafDataProvider};
use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Keccak256};
use sp_runtime::traits::Keccak256;

type Block = frame_system::mocking::MockBlock<Test>;

Expand All @@ -37,30 +33,9 @@ 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 RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = sp_core::sr25519::Public;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
type BlockWeights = ();
type BlockLength = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
}

impl Config for Test {
Expand Down

0 comments on commit 82bfe28

Please sign in to comment.