Replace parameter_types with ConstU32 &c. (#10402)

* remove parameter types and use const type

* remove parameter types and use const type

* Delete {

* Delete count,

* refractor for beefy, benchmarking, child bounties, and collective pallets

* refractor for pallet contracts

* refractor for elections

* refractor for more pallets

* fix CI issues

* fix CI issues

* fix CI issues

* fix CI issues

* remove warning to fix CI issue

* remove warning to fix CI issue
refractor for pallet preimage

* remove warning to fix CI issue
refractor for pallet proxy

* remove warning to fix CI issue
refractor for pallet recovery
refractor for pallet randomness-collective-flip

* remove warning to fix CI issue
refractor for pallet scored-pool
refractor for pallet scheduler
refractor for pallet session

* remove warning to fix CI issue
refractor for pallet society, support, system, timestamp, tips

* remove warning to fix CI issue
refractor for pallet transaction_payment, transaction_storage, treasury, uniques, utility

* remove warning to fix CI issue

* cargo +nightly fmt

* CI fix

* more param refractor on beefy-mmr

* refractor for beefy

* Update frame/babe/src/mock.rs

* Update frame/babe/src/mock.rs

* Update frame/bounties/src/tests.rs

* Update frame/tips/src/tests.rs

* Delete mock.rs

* Update frame/examples/basic/src/tests.rs

* Apply suggestions from code review

* Update frame/im-online/src/mock.rs

* Update frame/im-online/src/mock.rs

* Update frame/offences/benchmarking/src/mock.rs

* Update frame/session/benchmarking/src/mock.rs

* Update frame/support/test/tests/pallet_compatibility.rs

* Update frame/support/test/tests/pallet_compatibility_instance.rs

* Update frame/treasury/src/tests.rs

* Update test-utils/runtime/src/lib.rs

* some cleanup

* fmt

* remove unused

Co-authored-by: Damilare <dakinlose@teamapt.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
dharjeezy
2021-12-16 04:06:11 +01:00
committed by GitHub
parent cf1eb73046
commit 1b0be8ae06
76 changed files with 629 additions and 966 deletions
@@ -1,5 +1,5 @@
use crate as pallet_template;
use frame_support::parameter_types;
use frame_support::traits::{ConstU16, ConstU64};
use frame_system as system;
use sp_core::H256;
use sp_runtime::{
@@ -22,11 +22,6 @@ frame_support::construct_runtime!(
}
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const SS58Prefix: u8 = 42;
}
impl system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
@@ -42,14 +37,14 @@ impl system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
+6 -16
View File
@@ -26,7 +26,7 @@ use sp_version::RuntimeVersion;
// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, parameter_types,
traits::{ConstU32, KeyOwnerProofSystem, Randomness, StorageInfo},
traits::{ConstU128, ConstU32, ConstU8, KeyOwnerProofSystem, Randomness, StorageInfo},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
IdentityFee, Weight,
@@ -196,14 +196,10 @@ impl frame_system::Config for Runtime {
impl pallet_randomness_collective_flip::Config for Runtime {}
parameter_types! {
pub const MaxAuthorities: u32 = 32;
}
impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId;
type DisabledValidators = ();
type MaxAuthorities = MaxAuthorities;
type MaxAuthorities = ConstU32<32>;
}
impl pallet_grandpa::Config for Runtime {
@@ -223,7 +219,7 @@ impl pallet_grandpa::Config for Runtime {
type HandleEquivocation = ();
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
type MaxAuthorities = ConstU32<32>;
}
parameter_types! {
@@ -238,13 +234,8 @@ impl pallet_timestamp::Config for Runtime {
type WeightInfo = ();
}
parameter_types! {
pub const ExistentialDeposit: u128 = 500;
pub const MaxLocks: u32 = 50;
}
impl pallet_balances::Config for Runtime {
type MaxLocks = MaxLocks;
type MaxLocks = ConstU32<50>;
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
/// The type for recording an account's balance.
@@ -252,20 +243,19 @@ impl pallet_balances::Config for Runtime {
/// The ubiquitous event type.
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU128<500>;
type AccountStore = System;
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
}
parameter_types! {
pub const TransactionByteFee: Balance = 1;
pub OperationalFeeMultiplier: u8 = 5;
}
impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
type TransactionByteFee = TransactionByteFee;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = IdentityFee<Balance>;
type FeeMultiplierUpdate = ();
}
+14 -24
View File
@@ -26,8 +26,8 @@ use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{
construct_runtime, parameter_types,
traits::{
ConstU128, ConstU32, Currency, EnsureOneOf, EqualPrivilegeOnly, Everything, Imbalance,
InstanceFilter, KeyOwnerProofSystem, LockIdentifier, Nothing, OnUnbalanced,
ConstU128, ConstU16, ConstU32, Currency, EnsureOneOf, EqualPrivilegeOnly, Everything,
Imbalance, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, Nothing, OnUnbalanced,
U128CurrencyToVote,
},
weights::{
@@ -191,7 +191,6 @@ parameter_types! {
})
.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
.build_or_panic();
pub const SS58Prefix: u16 = 42;
}
const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct());
@@ -218,7 +217,7 @@ impl frame_system::Config for Runtime {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = frame_system::weights::SubstrateWeight<Runtime>;
type SS58Prefix = SS58Prefix;
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
@@ -237,7 +236,6 @@ parameter_types! {
pub const DepositBase: Balance = deposit(1, 88);
// Additional storage item size of 32 bytes.
pub const DepositFactor: Balance = deposit(0, 32);
pub const MaxSignatories: u16 = 100;
}
impl pallet_multisig::Config for Runtime {
@@ -246,7 +244,7 @@ impl pallet_multisig::Config for Runtime {
type Currency = Balances;
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type MaxSignatories = ConstU16<100>;
type WeightInfo = pallet_multisig::weights::SubstrateWeight<Runtime>;
}
@@ -255,10 +253,8 @@ parameter_types! {
pub const ProxyDepositBase: Balance = deposit(1, 8);
// Additional storage item size of 33 bytes.
pub const ProxyDepositFactor: Balance = deposit(0, 33);
pub const MaxProxies: u16 = 32;
pub const AnnouncementDepositBase: Balance = deposit(1, 8);
pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
pub const MaxPending: u16 = 32;
}
/// The type used to represent the kinds of proxying allowed.
@@ -325,9 +321,9 @@ impl pallet_proxy::Config for Runtime {
type ProxyType = ProxyType;
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;
type MaxProxies = MaxProxies;
type MaxProxies = ConstU32<32>;
type WeightInfo = pallet_proxy::weights::SubstrateWeight<Runtime>;
type MaxPending = MaxPending;
type MaxPending = ConstU32<32>;
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
@@ -336,7 +332,6 @@ impl pallet_proxy::Config for Runtime {
parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
RuntimeBlockWeights::get().max_block;
pub const MaxScheduledPerBlock: u32 = 50;
// Retry a scheduled item every 10 blocks (1 minute) until the preimage exists.
pub const NoPreimagePostponement: Option<u32> = Some(10);
}
@@ -348,7 +343,7 @@ impl pallet_scheduler::Config for Runtime {
type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type MaxScheduledPerBlock = ConstU32<50>;
type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
type OriginPrivilegeCmp = EqualPrivilegeOnly;
type PreimageProvider = Preimage;
@@ -581,7 +576,6 @@ parameter_types! {
pub const UnsignedPhase: u32 = EPOCH_DURATION_IN_BLOCKS / 4;
// signed config
pub const SignedMaxSubmissions: u32 = 10;
pub const SignedRewardBase: Balance = 1 * DOLLARS;
pub const SignedDepositBase: Balance = 1 * DOLLARS;
pub const SignedDepositByte: Balance = 1 * CENTS;
@@ -599,11 +593,6 @@ parameter_types! {
*RuntimeBlockLength::get()
.max
.get(DispatchClass::Normal);
// BagsList allows a practically unbounded count of nominators to participate in NPoS elections.
// To ensure we respect memory limits when using the BagsList this must be set to a number of
// voters we know can fit into a single vec allocation.
pub const VoterSnapshotPerBlock: u32 = 10_000;
}
sp_npos_elections::generate_solution_type!(
@@ -668,7 +657,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type MinerMaxWeight = MinerMaxWeight;
type MinerMaxLength = MinerMaxLength;
type MinerTxPriority = MultiPhaseUnsignedPriority;
type SignedMaxSubmissions = SignedMaxSubmissions;
type SignedMaxSubmissions = ConstU32<10>;
type SignedRewardBase = SignedRewardBase;
type SignedDepositBase = SignedDepositBase;
type SignedDepositByte = SignedDepositByte;
@@ -687,7 +676,10 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight<Self>;
type ForceOrigin = EnsureRootOrHalfCouncil;
type BenchmarkingConfig = ElectionProviderBenchmarkConfig;
type VoterSnapshotPerBlock = VoterSnapshotPerBlock;
// BagsList allows a practically unbounded count of nominators to participate in NPoS elections.
// To ensure we respect memory limits when using the BagsList this must be set to a number of
// voters we know can fit into a single vec allocation.
type VoterSnapshotPerBlock = ConstU32<10_000>;
}
parameter_types! {
@@ -705,11 +697,9 @@ parameter_types! {
pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
pub const FastTrackVotingPeriod: BlockNumber = 3 * 24 * 60 * MINUTES;
pub const InstantAllowed: bool = true;
pub const MinimumDeposit: Balance = 100 * DOLLARS;
pub const EnactmentPeriod: BlockNumber = 30 * 24 * 60 * MINUTES;
pub const CooloffPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
pub const MaxVotes: u32 = 100;
pub const MaxProposals: u32 = 100;
}
@@ -738,7 +728,7 @@ impl pallet_democracy::Config for Runtime {
pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>;
type InstantOrigin =
pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>;
type InstantAllowed = InstantAllowed;
type InstantAllowed = frame_support::traits::ConstBool<true>;
type FastTrackVotingPeriod = FastTrackVotingPeriod;
// To cancel a proposal which has been passed, 2/3 of the council must agree to it.
type CancellationOrigin =
@@ -759,7 +749,7 @@ impl pallet_democracy::Config for Runtime {
type Slash = Treasury;
type Scheduler = Scheduler;
type PalletsOrigin = OriginCaller;
type MaxVotes = MaxVotes;
type MaxVotes = frame_support::traits::ConstU32<100>;
type WeightInfo = pallet_democracy::weights::SubstrateWeight<Runtime>;
type MaxProposals = MaxProposals;
}
+9 -12
View File
@@ -3,7 +3,10 @@
use super::*;
use crate as pallet_atomic_swap;
use frame_support::parameter_types;
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64},
};
use sp_core::H256;
use sp_runtime::{
testing::Header,
@@ -26,7 +29,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -45,7 +47,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -56,9 +58,7 @@ impl frame_system::Config for Test {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
}
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
@@ -66,18 +66,15 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const ProofLimit: u32 = 1024;
pub const ExpireDuration: u64 = 100;
}
impl Config for Test {
type Event = Event;
type SwapAction = BalanceSwapAction<u64, Balances>;
type ProofLimit = ProofLimit;
type ProofLimit = ConstU32<1024>;
}
const A: u64 = 1;
+4 -10
View File
@@ -22,7 +22,7 @@
use crate as pallet_aura;
use frame_support::{
parameter_types,
traits::{DisabledValidators, GenesisBuild},
traits::{ConstU32, ConstU64, DisabledValidators, GenesisBuild},
};
use sp_consensus_aura::{ed25519::AuthorityId, AuthorityIndex};
use sp_core::H256;
@@ -48,10 +48,8 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
pub const MinimumPeriod: u64 = 1;
}
impl frame_system::Config for Test {
@@ -69,7 +67,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -84,14 +82,10 @@ impl frame_system::Config for Test {
impl pallet_timestamp::Config for Test {
type Moment = u64;
type OnTimestampSet = Aura;
type MinimumPeriod = MinimumPeriod;
type MinimumPeriod = ConstU64<1>;
type WeightInfo = ();
}
parameter_types! {
pub const MaxAuthorities: u32 = 10;
}
thread_local! {
static DISABLED_VALIDATORS: RefCell<Vec<AuthorityIndex>> = RefCell::new(Default::default());
}
@@ -118,7 +112,7 @@ impl DisabledValidators for MockDisabledValidators {
impl pallet_aura::Config for Test {
type AuthorityId = AuthorityId;
type DisabledValidators = MockDisabledValidators;
type MaxAuthorities = MaxAuthorities;
type MaxAuthorities = ConstU32<10>;
}
pub fn new_test_ext(authorities: Vec<u64>) -> sp_io::TestExternalities {
@@ -173,7 +173,10 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
mod tests {
use super::*;
use crate as pallet_authority_discovery;
use frame_support::{parameter_types, traits::GenesisBuild};
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64, GenesisBuild},
};
use sp_application_crypto::Pair;
use sp_authority_discovery::AuthorityPair;
use sp_core::{crypto::key_types, H256};
@@ -201,11 +204,10 @@ mod tests {
parameter_types! {
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(33);
pub const MaxAuthorities: u32 = 100;
}
impl Config for Test {
type MaxAuthorities = MaxAuthorities;
type MaxAuthorities = ConstU32<100>;
}
impl pallet_session::Config for Test {
@@ -230,8 +232,6 @@ mod tests {
parameter_types! {
pub const Period: BlockNumber = 1;
pub const Offset: BlockNumber = 0;
pub const UncleGenerations: u64 = 0;
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -251,7 +251,7 @@ mod tests {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -260,7 +260,7 @@ mod tests {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
pub struct TestSessionHandler;
+8 -9
View File
@@ -405,7 +405,11 @@ impl<T: Config> Pallet<T> {
mod tests {
use super::*;
use crate as pallet_authorship;
use frame_support::{parameter_types, ConsensusEngineId};
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64},
ConsensusEngineId,
};
use sp_core::H256;
use sp_runtime::{
generic::DigestItem,
@@ -428,7 +432,6 @@ mod tests {
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -448,7 +451,7 @@ mod tests {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -457,16 +460,12 @@ mod tests {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const UncleGenerations: u64 = 5;
type MaxConsumers = ConstU32<16>;
}
impl pallet::Config for Test {
type FindAuthor = AuthorGiven;
type UncleGenerations = UncleGenerations;
type UncleGenerations = ConstU64<5>;
type FilterUncle = SealVerify<VerifyBlock>;
type EventHandler = ();
}
+8 -27
View File
@@ -22,7 +22,7 @@ use codec::Encode;
use frame_election_provider_support::onchain;
use frame_support::{
parameter_types,
traits::{GenesisBuild, KeyOwnerProofSystem, OnInitialize},
traits::{ConstU128, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem, OnInitialize},
};
use frame_system::InitKind;
use pallet_session::historical as pallet_session_historical;
@@ -67,7 +67,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -88,7 +87,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u128>;
type OnNewAccount = ();
@@ -130,32 +129,20 @@ impl pallet_session::historical::Config for Test {
type FullIdentificationOf = pallet_staking::ExposureOf<Self>;
}
parameter_types! {
pub const UncleGenerations: u64 = 0;
}
impl pallet_authorship::Config for Test {
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
type UncleGenerations = UncleGenerations;
type UncleGenerations = ConstU64<0>;
type FilterUncle = ();
type EventHandler = ();
}
parameter_types! {
pub const MinimumPeriod: u64 = 1;
}
impl pallet_timestamp::Config for Test {
type Moment = u64;
type OnTimestampSet = Babe;
type MinimumPeriod = MinimumPeriod;
type MinimumPeriod = ConstU64<1>;
type WeightInfo = ();
}
parameter_types! {
pub const ExistentialDeposit: u128 = 1;
}
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
@@ -163,7 +150,7 @@ impl pallet_balances::Config for Test {
type Balance = u128;
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU128<1>;
type AccountStore = System;
type WeightInfo = ();
}
@@ -183,11 +170,7 @@ parameter_types! {
pub const SessionsPerEra: SessionIndex = 3;
pub const BondingDuration: EraIndex = 3;
pub const SlashDeferDuration: EraIndex = 0;
pub const AttestationPeriod: u64 = 100;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
pub const ElectionLookahead: u64 = 0;
pub const StakingUnsignedPriority: u64 = u64::MAX / 2;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16);
}
@@ -211,7 +194,7 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type UnixTime = pallet_timestamp::Pallet<Test>;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type MaxNominatorRewardedPerValidator = ConstU32<64>;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
type ElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
@@ -229,15 +212,13 @@ impl pallet_offences::Config for Test {
parameter_types! {
pub const EpochDuration: u64 = 3;
pub const ExpectedBlockTime: u64 = 1;
pub const ReportLongevity: u64 =
BondingDuration::get() as u64 * SessionsPerEra::get() as u64 * EpochDuration::get();
pub const MaxAuthorities: u32 = 10;
}
impl Config for Test {
type EpochDuration = EpochDuration;
type ExpectedBlockTime = ExpectedBlockTime;
type ExpectedBlockTime = ConstU64<1>;
type EpochChangeTrigger = crate::ExternalTrigger;
type DisabledValidators = Session;
@@ -255,7 +236,7 @@ impl Config for Test {
super::EquivocationHandler<Self::KeyOwnerIdentification, Offences, ReportLongevity>;
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
type MaxAuthorities = ConstU32<10>;
}
pub fn go_to_block(n: u64, s: u64) {
@@ -22,6 +22,7 @@
use crate::{self as pallet_balances, decl_tests, Config, Pallet};
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64, ConstU8},
weights::{DispatchInfo, IdentityFee, Weight},
};
use pallet_transaction_payment::CurrencyAdapter;
@@ -44,7 +45,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
pub static ExistentialDeposit: u64 = 0;
@@ -64,7 +64,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = super::AccountData<u64>;
@@ -75,22 +75,15 @@ impl frame_system::Config for Test {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const TransactionByteFee: u64 = 1;
pub const OperationalFeeMultiplier: u8 = 5;
}
impl pallet_transaction_payment::Config for Test {
type OnChargeTransaction = CurrencyAdapter<Pallet<Test>, ()>;
type TransactionByteFee = TransactionByteFee;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type TransactionByteFee = ConstU64<1>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = IdentityFee<u64>;
type FeeMultiplierUpdate = ();
}
parameter_types! {
pub const MaxReserves: u32 = 2;
}
impl Config for Test {
type Balance = u64;
type DustRemoval = ();
@@ -98,7 +91,7 @@ impl Config for Test {
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = frame_system::Pallet<Test>;
type MaxLocks = ();
type MaxReserves = MaxReserves;
type MaxReserves = ConstU32<2>;
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
}
+8 -15
View File
@@ -22,7 +22,7 @@
use crate::{self as pallet_balances, decl_tests, Config, Pallet};
use frame_support::{
parameter_types,
traits::StorageMapShim,
traits::{ConstU32, ConstU64, ConstU8, StorageMapShim},
weights::{DispatchInfo, IdentityFee, Weight},
};
use pallet_transaction_payment::CurrencyAdapter;
@@ -46,7 +46,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
pub static ExistentialDeposit: u64 = 0;
@@ -66,7 +65,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -77,21 +76,15 @@ impl frame_system::Config for Test {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const TransactionByteFee: u64 = 1;
pub const OperationalFeeMultiplier: u8 = 5;
}
impl pallet_transaction_payment::Config for Test {
type OnChargeTransaction = CurrencyAdapter<Pallet<Test>, ()>;
type TransactionByteFee = TransactionByteFee;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type TransactionByteFee = ConstU64<1>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = IdentityFee<u64>;
type FeeMultiplierUpdate = ();
}
parameter_types! {
pub const MaxLocks: u32 = 50;
pub const MaxReserves: u32 = 2;
}
impl Config for Test {
type Balance = u64;
type DustRemoval = ();
@@ -99,8 +92,8 @@ impl Config for Test {
type ExistentialDeposit = ExistentialDeposit;
type AccountStore =
StorageMapShim<super::Account<Test>, system::Provider<Test>, u64, super::AccountData<u64>>;
type MaxLocks = MaxLocks;
type MaxReserves = MaxReserves;
type MaxLocks = ConstU32<50>;
type MaxReserves = ConstU32<2>;
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
}
@@ -20,7 +20,11 @@
#![cfg(test)]
use crate::{self as pallet_balances, Config, Pallet};
use frame_support::{parameter_types, traits::StorageMapShim, weights::IdentityFee};
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64, ConstU8, StorageMapShim},
weights::IdentityFee,
};
use pallet_transaction_payment::CurrencyAdapter;
use sp_core::H256;
use sp_io;
@@ -48,7 +52,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
pub static ExistentialDeposit: u64 = 0;
@@ -68,7 +71,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -79,14 +82,11 @@ impl frame_system::Config for Test {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const TransactionByteFee: u64 = 1;
pub const OperationalFeeMultiplier: u8 = 5;
}
impl pallet_transaction_payment::Config for Test {
type OnChargeTransaction = CurrencyAdapter<Pallet<Test>, ()>;
type TransactionByteFee = TransactionByteFee;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type TransactionByteFee = ConstU64<1>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = IdentityFee<u64>;
type FeeMultiplierUpdate = ();
}
@@ -97,10 +97,7 @@ impl OnUnbalanced<NegativeImbalance<Test>> for OnDustRemoval {
assert_ok!(Balances::resolve_into_existing(&1, amount));
}
}
parameter_types! {
pub const MaxLocks: u32 = 50;
pub const MaxReserves: u32 = 2;
}
impl Config for Test {
type Balance = u64;
type DustRemoval = OnDustRemoval;
@@ -108,8 +105,8 @@ impl Config for Test {
type ExistentialDeposit = ExistentialDeposit;
type AccountStore =
StorageMapShim<super::Account<Test>, system::Provider<Test>, u64, super::AccountData<u64>>;
type MaxLocks = MaxLocks;
type MaxReserves = MaxReserves;
type MaxLocks = ConstU32<50>;
type MaxReserves = ConstU32<2>;
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
}
+8 -16
View File
@@ -19,7 +19,9 @@ use std::vec;
use beefy_primitives::mmr::MmrLeafVersion;
use frame_support::{
construct_runtime, parameter_types, sp_io::TestExternalities, traits::GenesisBuild,
construct_runtime, parameter_types,
sp_io::TestExternalities,
traits::{ConstU16, ConstU32, ConstU64, GenesisBuild},
BasicExternalities,
};
use sp_core::{Hasher, H256};
@@ -57,11 +59,6 @@ construct_runtime!(
}
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const SS58Prefix: u8 = 42;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
@@ -77,29 +74,24 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const Period: u64 = 1;
pub const Offset: u64 = 0;
type MaxConsumers = ConstU32<16>;
}
impl pallet_session::Config for Test {
type Event = Event;
type ValidatorId = u64;
type ValidatorIdOf = ConvertInto;
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
type ShouldEndSession = pallet_session::PeriodicSessions<ConstU64<1>, ConstU64<0>>;
type NextSessionRotation = pallet_session::PeriodicSessions<ConstU64<1>, ConstU64<0>>;
type SessionManager = MockSessionManager;
type SessionHandler = <MockSessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = MockSessionKeys;
+8 -13
View File
@@ -18,7 +18,9 @@
use std::vec;
use frame_support::{
construct_runtime, parameter_types, sp_io::TestExternalities, traits::GenesisBuild,
construct_runtime, parameter_types,
sp_io::TestExternalities,
traits::{ConstU16, ConstU32, ConstU64, GenesisBuild},
BasicExternalities,
};
use sp_core::H256;
@@ -55,11 +57,6 @@ construct_runtime!(
}
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const SS58Prefix: u8 = 42;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
@@ -75,16 +72,16 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet_beefy::Config for Test {
@@ -92,8 +89,6 @@ impl pallet_beefy::Config for Test {
}
parameter_types! {
pub const Period: u64 = 1;
pub const Offset: u64 = 0;
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(33);
}
@@ -101,8 +96,8 @@ impl pallet_session::Config for Test {
type Event = Event;
type ValidatorId = u64;
type ValidatorIdOf = ConvertInto;
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
type ShouldEndSession = pallet_session::PeriodicSessions<ConstU64<1>, ConstU64<0>>;
type NextSessionRotation = pallet_session::PeriodicSessions<ConstU64<1>, ConstU64<0>>;
type SessionManager = MockSessionManager;
type SessionHandler = <MockSessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = MockSessionKeys;
+3 -5
View File
@@ -20,7 +20,7 @@
#![cfg(test)]
use super::*;
use frame_support::parameter_types;
use frame_support::{parameter_types, traits::ConstU32};
use sp_runtime::{
testing::{Header, H256},
traits::{BlakeTwo256, IdentityLookup},
@@ -112,14 +112,12 @@ impl frame_system::Config for Test {
}
parameter_types! {
pub const LowerBound: u32 = 1;
pub const UpperBound: u32 = 100;
pub const MaybeItem: Option<u32> = None;
}
impl pallet_test::Config for Test {
type LowerBound = LowerBound;
type UpperBound = UpperBound;
type LowerBound = ConstU32<1>;
type UpperBound = ConstU32<100>;
type MaybeItem = MaybeItem;
}
@@ -20,7 +20,7 @@
#![cfg(test)]
use super::*;
use frame_support::parameter_types;
use frame_support::traits::ConstU32;
use sp_runtime::{
testing::{Header, H256},
traits::{BlakeTwo256, IdentityLookup},
@@ -113,15 +113,10 @@ impl frame_system::Config for Test {
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const LowerBound: u32 = 1;
pub const UpperBound: u32 = 100;
}
impl pallet_test::Config for Test {
type Event = Event;
type LowerBound = LowerBound;
type UpperBound = UpperBound;
type LowerBound = ConstU32<1>;
type UpperBound = ConstU32<100>;
}
impl pallet_test::OtherConfig for Test {
+18 -28
View File
@@ -24,8 +24,11 @@ use crate as pallet_bounties;
use std::cell::RefCell;
use frame_support::{
assert_noop, assert_ok, pallet_prelude::GenesisBuild, parameter_types, traits::OnInitialize,
weights::Weight, PalletId,
assert_noop, assert_ok,
pallet_prelude::GenesisBuild,
parameter_types,
traits::{ConstU32, ConstU64, OnInitialize},
PalletId,
};
use sp_core::H256;
@@ -54,9 +57,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: Weight = 1024;
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
@@ -75,7 +75,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -86,9 +86,7 @@ impl frame_system::Config for Test {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
}
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
@@ -96,7 +94,7 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
@@ -105,13 +103,10 @@ thread_local! {
}
parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: u64 = 1;
pub const SpendPeriod: u64 = 2;
pub const Burn: Permill = Permill::from_percent(50);
pub const DataDepositPerByte: u64 = 1;
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
pub const MaxApprovals: u32 = 100;
}
// impl pallet_treasury::Config for Test {
impl pallet_treasury::Config for Test {
type PalletId = TreasuryPalletId;
@@ -121,31 +116,26 @@ impl pallet_treasury::Config for Test {
type Event = Event;
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type ProposalBondMinimum = ConstU64<1>;
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
type WeightInfo = ();
type SpendFunds = Bounties;
type MaxApprovals = MaxApprovals;
type MaxApprovals = ConstU32<100>;
}
parameter_types! {
pub const BountyDepositBase: u64 = 80;
pub const BountyDepositPayoutDelay: u64 = 3;
pub const BountyUpdatePeriod: u32 = 20;
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
pub const BountyValueMinimum: u64 = 1;
pub const MaximumReasonLength: u32 = 16384;
}
impl Config for Test {
type Event = Event;
type BountyDepositBase = BountyDepositBase;
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
type BountyUpdatePeriod = BountyUpdatePeriod;
type BountyDepositBase = ConstU64<80>;
type BountyDepositPayoutDelay = ConstU64<3>;
type BountyUpdatePeriod = ConstU64<20>;
type BountyCuratorDeposit = BountyCuratorDeposit;
type BountyValueMinimum = BountyValueMinimum;
type DataDepositPerByte = DataDepositPerByte;
type MaximumReasonLength = MaximumReasonLength;
type BountyValueMinimum = ConstU64<1>;
type DataDepositPerByte = ConstU64<1>;
type MaximumReasonLength = ConstU32<16384>;
type WeightInfo = ();
type ChildBountyManager = ();
}
+21 -31
View File
@@ -24,8 +24,12 @@ use crate as pallet_child_bounties;
use std::cell::RefCell;
use frame_support::{
assert_noop, assert_ok, pallet_prelude::GenesisBuild, parameter_types, traits::OnInitialize,
weights::Weight, PalletId,
assert_noop, assert_ok,
pallet_prelude::GenesisBuild,
parameter_types,
traits::{ConstU32, ConstU64, OnInitialize},
weights::Weight,
PalletId,
};
use sp_core::H256;
@@ -56,7 +60,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: Weight = 1024;
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
@@ -77,7 +80,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -86,11 +89,9 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
@@ -98,7 +99,7 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
@@ -107,12 +108,8 @@ thread_local! {
}
parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: u64 = 1;
pub const SpendPeriod: u64 = 2;
pub const Burn: Permill = Permill::from_percent(50);
pub const DataDepositPerByte: u64 = 1;
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
pub const MaxApprovals: u32 = 100;
}
impl pallet_treasury::Config for Test {
@@ -123,43 +120,36 @@ impl pallet_treasury::Config for Test {
type Event = Event;
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type ProposalBondMinimum = ConstU64<1>;
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = ();
type WeightInfo = ();
type SpendFunds = Bounties;
type MaxApprovals = MaxApprovals;
type MaxApprovals = ConstU32<100>;
}
parameter_types! {
pub const BountyDepositBase: u64 = 80;
pub const BountyDepositPayoutDelay: u64 = 3;
pub const BountyUpdatePeriod: u32 = 10;
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
pub const BountyValueMinimum: u64 = 5;
pub const MaximumReasonLength: u32 = 300;
}
impl pallet_bounties::Config for Test {
type Event = Event;
type BountyDepositBase = BountyDepositBase;
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
type BountyUpdatePeriod = BountyUpdatePeriod;
type BountyDepositBase = ConstU64<80>;
type BountyDepositPayoutDelay = ConstU64<3>;
type BountyUpdatePeriod = ConstU64<10>;
type BountyCuratorDeposit = BountyCuratorDeposit;
type BountyValueMinimum = BountyValueMinimum;
type DataDepositPerByte = DataDepositPerByte;
type MaximumReasonLength = MaximumReasonLength;
type BountyValueMinimum = ConstU64<5>;
type DataDepositPerByte = ConstU64<1>;
type MaximumReasonLength = ConstU32<300>;
type WeightInfo = ();
type ChildBountyManager = ChildBounties;
}
parameter_types! {
pub const MaxActiveChildBountyCount: u32 = 2;
pub const ChildBountyValueMinimum: u64 = 1;
pub const ChildBountyCuratorDepositBase: Permill = Permill::from_percent(10);
}
impl pallet_child_bounties::Config for Test {
type Event = Event;
type MaxActiveChildBountyCount = MaxActiveChildBountyCount;
type ChildBountyValueMinimum = ChildBountyValueMinimum;
type MaxActiveChildBountyCount = ConstU32<2>;
type ChildBountyValueMinimum = ConstU64<1>;
type ChildBountyCuratorDepositBase = ChildBountyCuratorDepositBase;
type WeightInfo = ();
}
+11 -8
View File
@@ -18,7 +18,10 @@
use super::{Event as CollectiveEvent, *};
use crate as pallet_collective;
use frame_support::{
assert_noop, assert_ok, parameter_types, traits::GenesisBuild, weights::Pays, Hashable,
assert_noop, assert_ok, parameter_types,
traits::{ConstU32, ConstU64, GenesisBuild},
weights::Pays,
Hashable,
};
use frame_system::{EventRecord, Phase};
use sp_core::{
@@ -83,11 +86,11 @@ mod mock_democracy {
}
}
pub type MaxMembers = ConstU32<100>;
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MotionDuration: u64 = 3;
pub const MaxProposals: u32 = 100;
pub const MaxMembers: u32 = 100;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -106,7 +109,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -115,13 +118,13 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl Config<Instance1> for Test {
type Origin = Origin;
type Proposal = Call;
type Event = Event;
type MotionDuration = MotionDuration;
type MotionDuration = ConstU64<3>;
type MaxProposals = MaxProposals;
type MaxMembers = MaxMembers;
type DefaultVote = PrimeDefaultVote;
@@ -131,7 +134,7 @@ impl Config<Instance2> for Test {
type Origin = Origin;
type Proposal = Call;
type Event = Event;
type MotionDuration = MotionDuration;
type MotionDuration = ConstU64<3>;
type MaxProposals = MaxProposals;
type MaxMembers = MaxMembers;
type DefaultVote = MoreThanMajorityThenPrimeDefaultVote;
@@ -145,7 +148,7 @@ impl Config for Test {
type Origin = Origin;
type Proposal = Call;
type Event = Event;
type MotionDuration = MotionDuration;
type MotionDuration = ConstU64<3>;
type MaxProposals = MaxProposals;
type MaxMembers = MaxMembers;
type DefaultVote = PrimeDefaultVote;
+7 -9
View File
@@ -33,7 +33,9 @@ use frame_support::{
dispatch::DispatchErrorWithPostInfo,
parameter_types,
storage::child,
traits::{BalanceStatus, Contains, Currency, OnInitialize, ReservableCurrency},
traits::{
BalanceStatus, ConstU32, ConstU64, Contains, Currency, OnInitialize, ReservableCurrency,
},
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, PostDispatchInfo, Weight},
};
use frame_system::{self as system, EventRecord, Phase};
@@ -177,7 +179,6 @@ impl ChainExtension<Test> for TestExtension {
}
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(2 * WEIGHT_PER_SECOND);
pub static ExistentialDeposit: u64 = 1;
@@ -197,7 +198,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -220,13 +221,11 @@ impl pallet_balances::Config for Test {
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const MinimumPeriod: u64 = 1;
}
impl pallet_timestamp::Config for Test {
type Moment = u64;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
type MinimumPeriod = ConstU64<1>;
type WeightInfo = ();
}
impl pallet_utility::Config for Test {
@@ -237,7 +236,6 @@ impl pallet_utility::Config for Test {
}
parameter_types! {
pub const MaxValueSize: u32 = 16_384;
pub const DeletionQueueDepth: u32 = 1024;
pub const DeletionWeightLimit: Weight = 500_000_000_000;
pub const MaxCodeSize: u32 = 2 * 1024;
pub MySchedule: Schedule<Test> = <Schedule<Test>>::default();
@@ -282,7 +280,7 @@ impl Config for Test {
type WeightPrice = Self;
type WeightInfo = ();
type ChainExtension = TestExtension;
type DeletionQueueDepth = DeletionQueueDepth;
type DeletionQueueDepth = ConstU32<1024>;
type DeletionWeightLimit = DeletionWeightLimit;
type Schedule = MySchedule;
type DepositPerByte = DepositPerByte;
+16 -29
View File
@@ -22,7 +22,9 @@ use crate as pallet_democracy;
use codec::Encode;
use frame_support::{
assert_noop, assert_ok, ord_parameter_types, parameter_types,
traits::{Contains, EqualPrivilegeOnly, GenesisBuild, OnInitialize, SortedMembers},
traits::{
ConstU32, ConstU64, Contains, EqualPrivilegeOnly, GenesisBuild, OnInitialize, SortedMembers,
},
weights::Weight,
};
use frame_system::{EnsureRoot, EnsureSignedBy};
@@ -50,8 +52,6 @@ const NAY: Vote = Vote { aye: false, conviction: Conviction::None };
const BIG_AYE: Vote = Vote { aye: true, conviction: Conviction::Locked1x };
const BIG_NAY: Vote = Vote { aye: false, conviction: Conviction::Locked1x };
const MAX_PROPOSALS: u32 = 100;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
@@ -77,7 +77,6 @@ impl Contains<Call> for BaseFilter {
}
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1_000_000);
}
@@ -96,7 +95,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -123,31 +122,19 @@ impl pallet_scheduler::Config for Test {
type PreimageProvider = ();
type NoPreimagePostponement = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
pub const MaxLocks: u32 = 10;
}
impl pallet_balances::Config for Test {
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type MaxLocks = MaxLocks;
type MaxLocks = ConstU32<10>;
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const LaunchPeriod: u64 = 2;
pub const VotingPeriod: u64 = 2;
pub const FastTrackVotingPeriod: u64 = 2;
pub const MinimumDeposit: u64 = 1;
pub const EnactmentPeriod: u64 = 2;
pub const VoteLockingPeriod: u64 = 3;
pub const CooloffPeriod: u64 = 2;
pub const MaxVotes: u32 = 100;
pub const MaxProposals: u32 = MAX_PROPOSALS;
pub static PreimageByteDeposit: u64 = 0;
pub static InstantAllowed: bool = false;
}
@@ -172,12 +159,12 @@ impl Config for Test {
type Proposal = Call;
type Event = Event;
type Currency = pallet_balances::Pallet<Self>;
type EnactmentPeriod = EnactmentPeriod;
type LaunchPeriod = LaunchPeriod;
type VotingPeriod = VotingPeriod;
type VoteLockingPeriod = VoteLockingPeriod;
type FastTrackVotingPeriod = FastTrackVotingPeriod;
type MinimumDeposit = MinimumDeposit;
type EnactmentPeriod = ConstU64<2>;
type LaunchPeriod = ConstU64<2>;
type VotingPeriod = ConstU64<2>;
type VoteLockingPeriod = ConstU64<3>;
type FastTrackVotingPeriod = ConstU64<2>;
type MinimumDeposit = ConstU64<1>;
type ExternalOrigin = EnsureSignedBy<Two, u64>;
type ExternalMajorityOrigin = EnsureSignedBy<Three, u64>;
type ExternalDefaultOrigin = EnsureSignedBy<One, u64>;
@@ -186,17 +173,17 @@ impl Config for Test {
type BlacklistOrigin = EnsureRoot<u64>;
type CancelProposalOrigin = EnsureRoot<u64>;
type VetoOrigin = EnsureSignedBy<OneToFive, u64>;
type CooloffPeriod = CooloffPeriod;
type CooloffPeriod = ConstU64<2>;
type PreimageByteDeposit = PreimageByteDeposit;
type Slash = ();
type InstantOrigin = EnsureSignedBy<Six, u64>;
type InstantAllowed = InstantAllowed;
type Scheduler = Scheduler;
type MaxVotes = MaxVotes;
type MaxVotes = ConstU32<100>;
type OperationalPreimageOrigin = EnsureSignedBy<Six, u64>;
type PalletsOrigin = OriginCaller;
type WeightInfo = ();
type MaxProposals = MaxProposals;
type MaxProposals = ConstU32<100>;
}
pub fn new_test_ext() -> sp_io::TestExternalities {
@@ -21,7 +21,11 @@ use frame_election_provider_support::{
data_provider, onchain, ElectionDataProvider, SequentialPhragmen,
};
pub use frame_support::{assert_noop, assert_ok};
use frame_support::{parameter_types, traits::Hooks, weights::Weight};
use frame_support::{
parameter_types,
traits::{ConstU32, Hooks},
weights::Weight,
};
use multi_phase::unsigned::{IndexAssignmentOf, Voter};
use parking_lot::RwLock;
use sp_core::{
@@ -218,7 +222,7 @@ impl frame_system::Config for Runtime {
type OnKilledAccount = ();
type SystemWeightInfo = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
+7 -10
View File
@@ -1121,8 +1121,10 @@ mod tests {
use super::*;
use crate as elections_phragmen;
use frame_support::{
assert_noop, assert_ok, dispatch::DispatchResultWithPostInfo, parameter_types,
traits::OnInitialize,
assert_noop, assert_ok,
dispatch::DispatchResultWithPostInfo,
parameter_types,
traits::{ConstU32, ConstU64, OnInitialize},
};
use frame_system::ensure_signed;
use sp_core::H256;
@@ -1134,7 +1136,6 @@ mod tests {
use substrate_test_utils::assert_eq_uvec;
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -1154,7 +1155,7 @@ mod tests {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -1163,18 +1164,14 @@ mod tests {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = frame_system::Pallet<Test>;
type MaxLocks = ();
type MaxReserves = ();
+5 -11
View File
@@ -20,7 +20,7 @@
use crate::*;
use frame_support::{
assert_ok, parameter_types,
traits::OnInitialize,
traits::{ConstU64, OnInitialize},
weights::{DispatchInfo, GetDispatchInfo},
};
use sp_core::H256;
@@ -51,7 +51,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -70,7 +69,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -81,9 +80,7 @@ impl frame_system::Config for Test {
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
}
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
@@ -91,16 +88,13 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const MagicNumber: u64 = 1_000_000_000;
}
impl Config for Test {
type MagicNumber = MagicNumber;
type MagicNumber = ConstU64<1_000_000_000>;
type Event = Event;
type WeightInfo = ();
}
@@ -18,7 +18,10 @@
use crate as example_offchain_worker;
use crate::*;
use codec::Decode;
use frame_support::{assert_ok, parameter_types};
use frame_support::{
assert_ok, parameter_types,
traits::{ConstU32, ConstU64},
};
use sp_core::{
offchain::{testing, OffchainWorkerExt, TransactionPoolExt},
sr25519::Signature,
@@ -49,7 +52,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -68,7 +70,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -77,7 +79,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
type Extrinsic = TestXt<Call, ()>;
@@ -111,8 +113,6 @@ where
}
parameter_types! {
pub const GracePeriod: u64 = 5;
pub const UnsignedInterval: u64 = 128;
pub const UnsignedPriority: u64 = 1 << 20;
}
@@ -120,8 +120,8 @@ impl Config for Test {
type Event = Event;
type AuthorityId = crypto::TestAuthId;
type Call = Call;
type GracePeriod = GracePeriod;
type UnsignedInterval = UnsignedInterval;
type GracePeriod = ConstU64<5>;
type UnsignedInterval = ConstU64<128>;
type UnsignedPriority = UnsignedPriority;
}
@@ -40,7 +40,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
@@ -57,7 +56,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = frame_support::traits::ConstU64<250>;
type DbWeight = ();
type BlockWeights = ();
type BlockLength = ();
@@ -71,12 +70,6 @@ impl frame_system::Config for Test {
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const GracePeriod: u64 = 5;
pub const UnsignedInterval: u64 = 128;
pub const UnsignedPriority: u64 = 1 << 20;
}
impl Config for Test {
type Call = Call;
}
+7 -6
View File
@@ -578,7 +578,10 @@ mod tests {
use frame_support::{
assert_err, parameter_types,
traits::{Currency, LockIdentifier, LockableCurrency, WithdrawReasons},
traits::{
ConstU32, ConstU64, ConstU8, Currency, LockIdentifier, LockableCurrency,
WithdrawReasons,
},
weights::{IdentityFee, RuntimeDbWeight, Weight, WeightToFeePolynomial},
};
use frame_system::{Call as SystemCall, ChainContext, LastRuntimeUpgradeInfo};
@@ -731,7 +734,6 @@ mod tests {
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::builder()
.base_block(10)
@@ -758,7 +760,7 @@ mod tests {
type Lookup = IdentityLookup<u64>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = RuntimeVersion;
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
@@ -767,7 +769,7 @@ mod tests {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
type Balance = u64;
@@ -788,12 +790,11 @@ mod tests {
parameter_types! {
pub const TransactionByteFee: Balance = 0;
pub const OperationalFeeMultiplier: u8 = 5;
}
impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
type TransactionByteFee = TransactionByteFee;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = IdentityFee<Balance>;
type FeeMultiplierUpdate = ();
}
+11 -27
View File
@@ -21,7 +21,7 @@ use crate as pallet_gilt;
use frame_support::{
ord_parameter_types, parameter_types,
traits::{Currency, GenesisBuild, OnFinalize, OnInitialize},
traits::{ConstU16, ConstU32, ConstU64, Currency, GenesisBuild, OnFinalize, OnInitialize},
};
use sp_core::H256;
use sp_runtime::{
@@ -45,11 +45,6 @@ frame_support::construct_runtime!(
}
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const SS58Prefix: u8 = 42;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
@@ -64,7 +59,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
@@ -72,20 +67,16 @@ impl frame_system::Config for Test {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
}
impl pallet_balances::Config for Test {
type Balance = u64;
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = frame_support::traits::ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
type MaxLocks = ();
@@ -95,13 +86,6 @@ impl pallet_balances::Config for Test {
parameter_types! {
pub IgnoredIssuance: u64 = Balances::total_balance(&0); // Account zero is ignored.
pub const QueueCount: u32 = 3;
pub const MaxQueueLen: u32 = 3;
pub const FifoQueueLen: u32 = 1;
pub const Period: u64 = 3;
pub const MinFreeze: u64 = 2;
pub const IntakePeriod: u64 = 2;
pub const MaxIntakeBids: u32 = 2;
}
ord_parameter_types! {
pub const One: u64 = 1;
@@ -115,13 +99,13 @@ impl pallet_gilt::Config for Test {
type Deficit = ();
type Surplus = ();
type IgnoredIssuance = IgnoredIssuance;
type QueueCount = QueueCount;
type MaxQueueLen = MaxQueueLen;
type FifoQueueLen = FifoQueueLen;
type Period = Period;
type MinFreeze = MinFreeze;
type IntakePeriod = IntakePeriod;
type MaxIntakeBids = MaxIntakeBids;
type QueueCount = ConstU32<3>;
type MaxQueueLen = ConstU32<3>;
type FifoQueueLen = ConstU32<1>;
type Period = ConstU64<3>;
type MinFreeze = ConstU64<2>;
type IntakePeriod = ConstU64<2>;
type MaxIntakeBids = ConstU32<2>;
type WeightInfo = ();
}
+11 -24
View File
@@ -25,7 +25,9 @@ use codec::Encode;
use frame_election_provider_support::onchain;
use frame_support::{
parameter_types,
traits::{GenesisBuild, KeyOwnerProofSystem, OnFinalize, OnInitialize},
traits::{
ConstU128, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem, OnFinalize, OnInitialize,
},
};
use pallet_session::historical as pallet_session_historical;
use pallet_staking::EraIndex;
@@ -69,7 +71,6 @@ impl_opaque_keys! {
}
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -89,7 +90,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u128>;
@@ -119,8 +120,8 @@ impl pallet_session::Config for Test {
type Event = Event;
type ValidatorId = u64;
type ValidatorIdOf = pallet_staking::StashOf<Self>;
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
type ShouldEndSession = pallet_session::PeriodicSessions<ConstU64<1>, ConstU64<0>>;
type NextSessionRotation = pallet_session::PeriodicSessions<ConstU64<1>, ConstU64<0>>;
type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, Staking>;
type SessionHandler = <TestSessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = TestSessionKeys;
@@ -132,21 +133,13 @@ impl pallet_session::historical::Config for Test {
type FullIdentificationOf = pallet_staking::ExposureOf<Self>;
}
parameter_types! {
pub const UncleGenerations: u64 = 0;
}
impl pallet_authorship::Config for Test {
type FindAuthor = ();
type UncleGenerations = UncleGenerations;
type UncleGenerations = ConstU64<0>;
type FilterUncle = ();
type EventHandler = ();
}
parameter_types! {
pub const ExistentialDeposit: u128 = 1;
}
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
@@ -154,19 +147,15 @@ impl pallet_balances::Config for Test {
type Balance = u128;
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU128<1>;
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const MinimumPeriod: u64 = 3;
}
impl pallet_timestamp::Config for Test {
type Moment = u64;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
type MinimumPeriod = ConstU64<3>;
type WeightInfo = ();
}
@@ -187,7 +176,6 @@ parameter_types! {
pub const SlashDeferDuration: EraIndex = 0;
pub const AttestationPeriod: u64 = 100;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
pub const ElectionLookahead: u64 = 0;
pub const StakingUnsignedPriority: u64 = u64::MAX / 2;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
@@ -213,7 +201,7 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type UnixTime = pallet_timestamp::Pallet<Test>;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type MaxNominatorRewardedPerValidator = ConstU32<64>;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
type ElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
@@ -232,7 +220,6 @@ impl pallet_offences::Config for Test {
parameter_types! {
pub const ReportLongevity: u64 =
BondingDuration::get() as u64 * SessionsPerEra::get() as u64 * Period::get();
pub const MaxAuthorities: u32 = 100;
}
impl Config for Test {
@@ -253,7 +240,7 @@ impl Config for Test {
super::EquivocationHandler<Self::KeyOwnerIdentification, Offences, ReportLongevity>;
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
type MaxAuthorities = ConstU32<100>;
}
pub fn grandpa_log(log: ConsensusLog<u64>) -> DigestItem {
+13 -16
View File
@@ -22,7 +22,9 @@ use crate as pallet_identity;
use codec::{Decode, Encode};
use frame_support::{
assert_noop, assert_ok, ord_parameter_types, parameter_types, traits::EnsureOneOf, BoundedVec,
assert_noop, assert_ok, ord_parameter_types, parameter_types,
traits::{ConstU32, ConstU64, EnsureOneOf},
BoundedVec,
};
use frame_system::{EnsureRoot, EnsureSignedBy};
use sp_core::H256;
@@ -47,7 +49,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -65,7 +66,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
@@ -75,30 +76,26 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
}
parameter_types! {
pub const BasicDeposit: u64 = 10;
pub const FieldDeposit: u64 = 10;
pub const SubAccountDeposit: u64 = 10;
pub const MaxSubAccounts: u32 = 2;
pub const MaxAdditionalFields: u32 = 2;
pub const MaxRegistrars: u32 = 20;
}
ord_parameter_types! {
pub const One: u64 = 1;
pub const Two: u64 = 2;
@@ -109,10 +106,10 @@ impl pallet_identity::Config for Test {
type Event = Event;
type Currency = Balances;
type Slashed = ();
type BasicDeposit = BasicDeposit;
type FieldDeposit = FieldDeposit;
type SubAccountDeposit = SubAccountDeposit;
type MaxSubAccounts = MaxSubAccounts;
type BasicDeposit = ConstU64<10>;
type FieldDeposit = ConstU64<10>;
type SubAccountDeposit = ConstU64<10>;
type MaxSubAccounts = ConstU32<2>;
type MaxAdditionalFields = MaxAdditionalFields;
type MaxRegistrars = MaxRegistrars;
type RegistrarOrigin = EnsureOneOrRoot;
+11 -15
View File
@@ -21,7 +21,11 @@
use std::cell::RefCell;
use frame_support::{parameter_types, weights::Weight};
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64},
weights::Weight,
};
use pallet_session::historical as pallet_session_historical;
use sp_core::H256;
use sp_runtime::{
@@ -118,7 +122,6 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
}
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -138,7 +141,7 @@ impl frame_system::Config for Runtime {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -147,7 +150,7 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
parameter_types! {
@@ -173,13 +176,9 @@ impl pallet_session::historical::Config for Runtime {
type FullIdentificationOf = ConvertInto;
}
parameter_types! {
pub const UncleGenerations: u32 = 5;
}
impl pallet_authorship::Config for Runtime {
type FindAuthor = ();
type UncleGenerations = UncleGenerations;
type UncleGenerations = ConstU64<5>;
type FilterUncle = ();
type EventHandler = ImOnline;
}
@@ -221,9 +220,6 @@ impl frame_support::traits::EstimateNextSessionRotation<u64> for TestNextSession
parameter_types! {
pub const UnsignedPriority: u64 = 1 << 20;
pub const MaxKeys: u32 = 10_000;
pub const MaxPeerInHeartbeats: u32 = 10_000;
pub const MaxPeerDataEncodingSize: u32 = 1_000;
}
impl Config for Runtime {
@@ -234,9 +230,9 @@ impl Config for Runtime {
type ReportUnresponsiveness = OffenceHandler;
type UnsignedPriority = UnsignedPriority;
type WeightInfo = ();
type MaxKeys = MaxKeys;
type MaxPeerInHeartbeats = MaxPeerInHeartbeats;
type MaxPeerDataEncodingSize = MaxPeerDataEncodingSize;
type MaxKeys = ConstU32<10_000>;
type MaxPeerInHeartbeats = ConstU32<10_000>;
type MaxPeerDataEncodingSize = ConstU32<1_000>;
}
impl<LocalCall> frame_system::offchain::SendTransactionTypes<LocalCall> for Runtime
+8 -14
View File
@@ -20,7 +20,10 @@
#![cfg(test)]
use crate::{self as pallet_indices, Config};
use frame_support::parameter_types;
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64},
};
use sp_core::H256;
use sp_runtime::testing::Header;
@@ -40,7 +43,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -60,7 +62,7 @@ impl frame_system::Config for Test {
type Lookup = Indices;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -69,11 +71,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
@@ -83,19 +81,15 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const Deposit: u64 = 1;
}
impl Config for Test {
type AccountIndex = u64;
type Currency = Balances;
type Deposit = Deposit;
type Deposit = ConstU64<1>;
type Event = Event;
type WeightInfo = ();
}
+6 -15
View File
@@ -22,7 +22,7 @@ use crate as pallet_lottery;
use frame_support::{
parameter_types,
traits::{OnFinalize, OnInitialize},
traits::{ConstU32, ConstU64, OnFinalize, OnInitialize},
};
use frame_support_test::TestRandomness;
use frame_system::EnsureRoot;
@@ -49,9 +49,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: u32 = 1024;
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
@@ -70,7 +67,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -79,11 +76,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
@@ -93,15 +86,13 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const LotteryPalletId: PalletId = PalletId(*b"py/lotto");
pub const MaxCalls: u32 = 2;
pub const MaxGenerateRandom: u32 = 10;
}
impl Config for Test {
@@ -111,9 +102,9 @@ impl Config for Test {
type Randomness = TestRandomness<Self>;
type Event = Event;
type ManagerOrigin = EnsureRoot<u64>;
type MaxCalls = MaxCalls;
type MaxCalls = ConstU32<2>;
type ValidateCall = Lottery;
type MaxGenerateRandom = MaxGenerateRandom;
type MaxGenerateRandom = ConstU32<10>;
type WeightInfo = ();
}
+5 -6
View File
@@ -509,7 +509,8 @@ mod tests {
};
use frame_support::{
assert_noop, assert_ok, ord_parameter_types, parameter_types, traits::GenesisBuild,
assert_noop, assert_ok, ord_parameter_types, parameter_types,
traits::{ConstU32, ConstU64, GenesisBuild},
};
use frame_system::EnsureSignedBy;
@@ -528,8 +529,6 @@ mod tests {
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaxMembers: u32 = 10;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
pub static Members: Vec<u64> = vec![];
@@ -551,7 +550,7 @@ mod tests {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -560,7 +559,7 @@ mod tests {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
ord_parameter_types! {
pub const One: u64 = 1;
@@ -607,7 +606,7 @@ mod tests {
type PrimeOrigin = EnsureSignedBy<Five, u64>;
type MembershipInitialized = TestChangeMembers;
type MembershipChanged = TestChangeMembers;
type MaxMembers = MaxMembers;
type MaxMembers = ConstU32<10>;
type WeightInfo = ();
}
@@ -19,7 +19,7 @@ use crate as pallet_mmr;
use crate::*;
use codec::{Decode, Encode};
use frame_support::parameter_types;
use frame_support::traits::{ConstU32, ConstU64};
use pallet_mmr_primitives::{Compact, LeafDataProvider};
use sp_core::H256;
use sp_runtime::{
@@ -42,9 +42,6 @@ frame_support::construct_runtime!(
}
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type Origin = Origin;
@@ -57,7 +54,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
type BlockWeights = ();
type BlockLength = ();
@@ -69,7 +66,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl Config for Test {
+12 -16
View File
@@ -22,7 +22,10 @@
use super::*;
use crate as pallet_multisig;
use frame_support::{assert_noop, assert_ok, parameter_types, traits::Contains};
use frame_support::{
assert_noop, assert_ok, parameter_types,
traits::{ConstU16, ConstU32, ConstU64, Contains},
};
use sp_core::H256;
use sp_runtime::{
testing::Header,
@@ -46,7 +49,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -65,7 +67,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -74,11 +76,9 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
@@ -86,15 +86,11 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const DepositBase: u64 = 1;
pub const DepositFactor: u64 = 1;
pub const MaxSignatories: u16 = 3;
}
pub struct TestBaseCallFilter;
impl Contains<Call> for TestBaseCallFilter {
fn contains(c: &Call) -> bool {
@@ -110,9 +106,9 @@ impl Config for Test {
type Event = Event;
type Call = Call;
type Currency = Balances;
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type DepositBase = ConstU64<1>;
type DepositFactor = ConstU64<1>;
type MaxSignatories = ConstU16<3>;
type WeightInfo = ();
}
+12 -16
View File
@@ -245,7 +245,10 @@ mod tests {
use super::*;
use crate as pallet_nicks;
use frame_support::{assert_noop, assert_ok, ord_parameter_types, parameter_types};
use frame_support::{
assert_noop, assert_ok, ord_parameter_types, parameter_types,
traits::{ConstU32, ConstU64},
};
use frame_system::EnsureSignedBy;
use sp_core::H256;
use sp_runtime::{
@@ -269,7 +272,6 @@ mod tests {
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -288,7 +290,7 @@ mod tests {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -297,11 +299,9 @@ mod tests {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
@@ -309,26 +309,22 @@ mod tests {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const ReservationFee: u64 = 2;
pub const MinLength: u32 = 3;
pub const MaxLength: u32 = 16;
}
ord_parameter_types! {
pub const One: u64 = 1;
}
impl Config for Test {
type Event = Event;
type Currency = Balances;
type ReservationFee = ReservationFee;
type ReservationFee = ConstU64<2>;
type Slashed = ();
type ForceOrigin = EnsureSignedBy<One, u64>;
type MinLength = MinLength;
type MaxLength = MaxLength;
type MinLength = ConstU32<3>;
type MaxLength = ConstU32<16>;
}
fn new_test_ext() -> sp_io::TestExternalities {
+9 -12
View File
@@ -20,7 +20,10 @@
use super::*;
use crate as pallet_node_authorization;
use frame_support::{ord_parameter_types, parameter_types, traits::GenesisBuild};
use frame_support::{
ord_parameter_types,
traits::{ConstU32, ConstU64, GenesisBuild},
};
use frame_system::EnsureSignedBy;
use sp_core::H256;
use sp_runtime::{
@@ -44,9 +47,6 @@ frame_support::construct_runtime!(
}
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type DbWeight = ();
@@ -62,7 +62,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -71,7 +71,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
ord_parameter_types! {
@@ -80,14 +80,11 @@ ord_parameter_types! {
pub const Three: u64 = 3;
pub const Four: u64 = 4;
}
parameter_types! {
pub const MaxWellKnownNodes: u32 = 4;
pub const MaxPeerIdLength: u32 = 2;
}
impl Config for Test {
type Event = Event;
type MaxWellKnownNodes = MaxWellKnownNodes;
type MaxPeerIdLength = MaxPeerIdLength;
type MaxWellKnownNodes = ConstU32<4>;
type MaxPeerIdLength = ConstU32<2>;
type AddOrigin = EnsureSignedBy<One, u64>;
type RemoveOrigin = EnsureSignedBy<Two, u64>;
type SwapOrigin = EnsureSignedBy<Three, u64>;
@@ -21,7 +21,11 @@
use super::*;
use frame_election_provider_support::onchain;
use frame_support::{parameter_types, weights::constants::WEIGHT_PER_SECOND};
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64},
weights::constants::WEIGHT_PER_SECOND,
};
use frame_system as system;
use pallet_session::historical as pallet_session_historical;
use sp_runtime::{
@@ -80,13 +84,10 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
}
parameter_types! {
pub const MinimumPeriod: u64 = 5;
}
impl pallet_timestamp::Config for Test {
type Moment = u64;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
type MinimumPeriod = ConstU64<5>;
type WeightInfo = ();
}
impl pallet_session::historical::Config for Test {
@@ -145,10 +146,6 @@ pallet_staking_reward_curve::build! {
}
parameter_types! {
pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
pub const MaxKeys: u32 = 10_000;
pub const MaxPeerInHeartbeats: u32 = 10_000;
pub const MaxPeerDataEncodingSize: u32 = 1_000;
}
pub type Extrinsic = sp_runtime::testing::TestXt<Call, ()>;
@@ -174,7 +171,7 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type NextNewSession = Session;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type MaxNominatorRewardedPerValidator = ConstU32<64>;
type OffendingValidatorsThreshold = ();
type ElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
type GenesisElectionProvider = Self::ElectionProvider;
@@ -191,9 +188,9 @@ impl pallet_im_online::Config for Test {
type ReportUnresponsiveness = Offences;
type UnsignedPriority = ();
type WeightInfo = ();
type MaxKeys = MaxKeys;
type MaxPeerInHeartbeats = MaxPeerInHeartbeats;
type MaxPeerDataEncodingSize = MaxPeerDataEncodingSize;
type MaxKeys = ConstU32<10_000>;
type MaxPeerInHeartbeats = ConstU32<10_000>;
type MaxPeerDataEncodingSize = ConstU32<1_000>;
}
impl pallet_offences::Config for Test {
+3 -3
View File
@@ -24,6 +24,7 @@ use crate::Config;
use codec::Encode;
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64},
weights::{
constants::{RocksDbWeight, WEIGHT_PER_SECOND},
Weight,
@@ -84,7 +85,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(2 * WEIGHT_PER_SECOND);
}
@@ -103,7 +103,7 @@ impl frame_system::Config for Runtime {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -112,7 +112,7 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl Config for Runtime {
+10 -17
View File
@@ -21,7 +21,9 @@ use super::*;
use crate as pallet_preimage;
use frame_support::{
ord_parameter_types, parameter_types, traits::Everything, weights::constants::RocksDbWeight,
ord_parameter_types, parameter_types,
traits::{ConstU32, ConstU64, Everything},
weights::constants::RocksDbWeight,
};
use frame_system::EnsureSignedBy;
use sp_core::H256;
@@ -47,7 +49,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(2_000_000_000_000);
}
@@ -66,7 +67,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -75,32 +76,24 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 5;
pub const MaxReserves: u32 = 50;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<5>;
type AccountStore = System;
type WeightInfo = ();
type MaxLocks = ();
type MaxReserves = MaxReserves;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
}
parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
pub const MaxScheduledPerBlock: u32 = 10;
pub const MaxSize: u32 = 1024;
pub const BaseDeposit: u64 = 2;
pub const ByteDeposit: u64 = 1;
}
ord_parameter_types! {
@@ -112,9 +105,9 @@ impl Config for Test {
type Event = Event;
type Currency = Balances;
type ManagerOrigin = EnsureSignedBy<One, u64>;
type MaxSize = MaxSize;
type BaseDeposit = BaseDeposit;
type ByteDeposit = ByteDeposit;
type MaxSize = ConstU32<1024>;
type BaseDeposit = ConstU64<2>;
type ByteDeposit = ConstU64<1>;
}
pub fn new_test_ext() -> sp_io::TestExternalities {
+15 -22
View File
@@ -24,7 +24,10 @@ use super::*;
use crate as proxy;
use codec::{Decode, Encode};
use frame_support::{
assert_noop, assert_ok, dispatch::DispatchError, parameter_types, traits::Contains,
assert_noop, assert_ok,
dispatch::DispatchError,
parameter_types,
traits::{ConstU32, ConstU64, Contains},
RuntimeDebug,
};
use sp_core::H256;
@@ -50,7 +53,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -69,7 +71,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -78,11 +80,9 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
@@ -90,7 +90,7 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
@@ -100,14 +100,7 @@ impl pallet_utility::Config for Test {
type PalletsOrigin = OriginCaller;
type WeightInfo = ();
}
parameter_types! {
pub const ProxyDepositBase: u64 = 1;
pub const ProxyDepositFactor: u64 = 1;
pub const MaxProxies: u16 = 4;
pub const MaxPending: u32 = 2;
pub const AnnouncementDepositBase: u64 = 1;
pub const AnnouncementDepositFactor: u64 = 1;
}
#[derive(
Copy,
Clone,
@@ -161,14 +154,14 @@ impl Config for Test {
type Call = Call;
type Currency = Balances;
type ProxyType = ProxyType;
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;
type MaxProxies = MaxProxies;
type ProxyDepositBase = ConstU64<1>;
type ProxyDepositFactor = ConstU64<1>;
type MaxProxies = ConstU32<4>;
type WeightInfo = ();
type CallHasher = BlakeTwo256;
type MaxPending = MaxPending;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
type MaxPending = ConstU32<2>;
type AnnouncementDepositBase = ConstU64<1>;
type AnnouncementDepositFactor = ConstU64<1>;
}
use super::{Call as ProxyCall, Event as ProxyEvent};
@@ -169,7 +169,7 @@ mod tests {
use frame_support::{
parameter_types,
traits::{OnInitialize, Randomness},
traits::{ConstU32, ConstU64, OnInitialize, Randomness},
};
use frame_system::limits;
@@ -188,7 +188,6 @@ mod tests {
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: limits::BlockWeights = limits::BlockWeights
::simple_max(1024);
pub BlockLength: limits::BlockLength = limits::BlockLength
@@ -210,7 +209,7 @@ mod tests {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -219,7 +218,7 @@ mod tests {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet_randomness_collective_flip::Config for Test {}
+4 -6
View File
@@ -22,7 +22,7 @@ use super::*;
use crate as recovery;
use frame_support::{
parameter_types,
traits::{OnFinalize, OnInitialize},
traits::{ConstU16, ConstU32, ConstU64, OnFinalize, OnInitialize},
};
use sp_core::H256;
use sp_runtime::{
@@ -46,7 +46,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -66,7 +65,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u128>;
@@ -75,7 +74,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
parameter_types! {
@@ -97,7 +96,6 @@ impl pallet_balances::Config for Test {
parameter_types! {
pub const ConfigDepositBase: u64 = 10;
pub const FriendDepositFactor: u64 = 1;
pub const MaxFriends: u16 = 3;
pub const RecoveryDeposit: u64 = 10;
}
@@ -107,7 +105,7 @@ impl Config for Test {
type Currency = Balances;
type ConfigDepositBase = ConfigDepositBase;
type FriendDepositFactor = FriendDepositFactor;
type MaxFriends = MaxFriends;
type MaxFriends = ConstU16<3>;
type RecoveryDeposit = RecoveryDeposit;
}
+7 -8
View File
@@ -22,7 +22,9 @@ use super::*;
use crate as scheduler;
use frame_support::{
ord_parameter_types, parameter_types,
traits::{Contains, EnsureOneOf, EqualPrivilegeOnly, OnFinalize, OnInitialize},
traits::{
ConstU32, ConstU64, Contains, EnsureOneOf, EqualPrivilegeOnly, OnFinalize, OnInitialize,
},
weights::constants::RocksDbWeight,
};
use frame_system::{EnsureRoot, EnsureSignedBy};
@@ -116,7 +118,6 @@ impl Contains<Call> for BaseFilter {
}
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(2_000_000_000_000);
}
@@ -135,7 +136,7 @@ impl system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -144,15 +145,13 @@ impl system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl logger::Config for Test {
type Event = Event;
}
parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
pub const MaxScheduledPerBlock: u32 = 10;
pub const MaxSize: u32 = 1024;
pub const NoPreimagePostponement: Option<u64> = Some(2);
}
ord_parameter_types! {
@@ -164,7 +163,7 @@ impl pallet_preimage::Config for Test {
type WeightInfo = ();
type Currency = ();
type ManagerOrigin = EnsureRoot<u64>;
type MaxSize = MaxSize;
type MaxSize = ConstU32<1024>;
type BaseDeposit = ();
type ByteDeposit = ();
}
@@ -176,7 +175,7 @@ impl Config for Test {
type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureOneOf<EnsureRoot<u64>, EnsureSignedBy<One, u64>>;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type MaxScheduledPerBlock = ConstU32<10>;
type WeightInfo = ();
type OriginPrivilegeCmp = EqualPrivilegeOnly;
type PreimageProvider = Preimage;
+8 -8
View File
@@ -20,7 +20,10 @@
use super::*;
use crate as pallet_scored_pool;
use frame_support::{ord_parameter_types, parameter_types, traits::GenesisBuild};
use frame_support::{
ord_parameter_types, parameter_types,
traits::{ConstU32, ConstU64, GenesisBuild},
};
use frame_system::EnsureSignedBy;
use sp_core::H256;
use sp_runtime::{
@@ -46,9 +49,6 @@ frame_support::construct_runtime!(
parameter_types! {
pub const CandidateDeposit: u64 = 25;
pub const Period: u64 = 4;
pub const BlockHashCount: u64 = 250;
pub const ExistentialDeposit: u64 = 1;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -72,7 +72,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -81,7 +81,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
@@ -91,7 +91,7 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
@@ -130,7 +130,7 @@ impl Config for Test {
type MembershipChanged = TestChangeMembers;
type Currency = Balances;
type CandidateDeposit = CandidateDeposit;
type Period = Period;
type Period = ConstU64<4>;
type Score = u64;
type ScoreOrigin = EnsureSignedBy<ScoreOrigin, u64>;
}
@@ -20,7 +20,10 @@
#![cfg(test)]
use frame_election_provider_support::onchain;
use frame_support::parameter_types;
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64},
};
use sp_runtime::traits::IdentityLookup;
type AccountId = u64;
@@ -68,7 +71,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: Balance = 10;
@@ -85,13 +88,10 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
}
parameter_types! {
pub const MinimumPeriod: u64 = 5;
}
impl pallet_timestamp::Config for Test {
type Moment = u64;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
type MinimumPeriod = ConstU64<5>;
type WeightInfo = ();
}
impl pallet_session::historical::Config for Test {
@@ -144,8 +144,6 @@ pallet_staking_reward_curve::build! {
}
parameter_types! {
pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
pub const UnsignedPriority: u64 = 1 << 20;
}
pub type Extrinsic = sp_runtime::testing::TestXt<Call, ()>;
@@ -179,7 +177,7 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type NextNewSession = Session;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type MaxNominatorRewardedPerValidator = ConstU32<64>;
type OffendingValidatorsThreshold = ();
type ElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
type GenesisElectionProvider = Self::ElectionProvider;
+8 -6
View File
@@ -32,7 +32,11 @@ use sp_runtime::{
};
use sp_staking::SessionIndex;
use frame_support::{parameter_types, traits::GenesisBuild, BasicExternalities};
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64, GenesisBuild},
BasicExternalities,
};
impl_opaque_keys! {
pub struct MockSessionKeys {
@@ -234,8 +238,6 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
}
parameter_types! {
pub const MinimumPeriod: u64 = 5;
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -255,7 +257,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -264,13 +266,13 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet_timestamp::Config for Test {
type Moment = u64;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
type MinimumPeriod = ConstU64<5>;
type WeightInfo = ();
}
+5 -7
View File
@@ -29,7 +29,10 @@ use codec::Decode;
use sp_core::crypto::key_types::DUMMY;
use sp_runtime::testing::UintAuthorityId;
use frame_support::{assert_noop, assert_ok, traits::OnInitialize};
use frame_support::{
assert_noop, assert_ok,
traits::{ConstU64, OnInitialize},
};
fn initialize_block(block: u64) {
SESSION_CHANGED.with(|l| *l.borrow_mut() = false);
@@ -291,12 +294,7 @@ fn session_changed_flag_works() {
#[test]
fn periodic_session_works() {
frame_support::parameter_types! {
const Period: u64 = 10;
const Offset: u64 = 3;
}
type P = PeriodicSessions<Period, Offset>;
type P = PeriodicSessions<ConstU64<10>, ConstU64<3>>;
// make sure that offset phase behaves correctly
for i in 0u64..3 {
+15 -22
View File
@@ -20,7 +20,10 @@
use super::*;
use crate as pallet_society;
use frame_support::{ord_parameter_types, parameter_types};
use frame_support::{
ord_parameter_types, parameter_types,
traits::{ConstU32, ConstU64},
};
use frame_support_test::TestRandomness;
use frame_system::EnsureSignedBy;
use sp_core::H256;
@@ -45,16 +48,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const CandidateDeposit: u64 = 25;
pub const WrongSideDeduction: u64 = 2;
pub const MaxStrikes: u32 = 2;
pub const RotationPeriod: u64 = 4;
pub const PeriodSpend: u64 = 1000;
pub const MaxLockDuration: u64 = 100;
pub const ChallengePeriod: u64 = 8;
pub const BlockHashCount: u64 = 250;
pub const ExistentialDeposit: u64 = 1;
pub const MaxCandidateIntake: u32 = 10;
pub const SocietyPalletId: PalletId = PalletId(*b"py/socie");
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
@@ -80,7 +73,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type OnNewAccount = ();
@@ -89,7 +82,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
@@ -99,7 +92,7 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
@@ -108,17 +101,17 @@ impl Config for Test {
type Event = Event;
type Currency = pallet_balances::Pallet<Self>;
type Randomness = TestRandomness<Self>;
type CandidateDeposit = CandidateDeposit;
type WrongSideDeduction = WrongSideDeduction;
type MaxStrikes = MaxStrikes;
type PeriodSpend = PeriodSpend;
type CandidateDeposit = ConstU64<25>;
type WrongSideDeduction = ConstU64<2>;
type MaxStrikes = ConstU32<2>;
type PeriodSpend = ConstU64<1000>;
type MembershipChanged = ();
type RotationPeriod = RotationPeriod;
type MaxLockDuration = MaxLockDuration;
type RotationPeriod = ConstU64<4>;
type MaxLockDuration = ConstU64<100>;
type FounderSetOrigin = EnsureSignedBy<FounderSetAccount, u128>;
type SuspensionJudgementOrigin = EnsureSignedBy<SuspensionJudgementSetAccount, u128>;
type ChallengePeriod = ChallengePeriod;
type MaxCandidateIntake = MaxCandidateIntake;
type ChallengePeriod = ConstU64<8>;
type MaxCandidateIntake = ConstU32<10>;
type PalletId = SocietyPalletId;
}
+2 -2
View File
@@ -947,7 +947,7 @@ mod tests {
let (validator_stash, nominators) = create_validator_with_nominators::<Test>(
n,
<Test as Config>::MaxNominatorRewardedPerValidator::get() as u32,
<Test as Config>::MaxNominatorRewardedPerValidator::get(),
false,
RewardDestination::Staked,
)
@@ -972,7 +972,7 @@ mod tests {
let (validator_stash, _nominators) = create_validator_with_nominators::<Test>(
n,
<Test as Config>::MaxNominatorRewardedPerValidator::get() as u32,
<Test as Config>::MaxNominatorRewardedPerValidator::get(),
false,
RewardDestination::Staked,
)
+10 -15
View File
@@ -22,7 +22,8 @@ use frame_election_provider_support::{onchain, SortedListProvider};
use frame_support::{
assert_ok, parameter_types,
traits::{
Currency, FindAuthor, GenesisBuild, Get, Hooks, Imbalance, OnUnbalanced, OneSessionHandler,
ConstU32, ConstU64, Currency, FindAuthor, GenesisBuild, Get, Hooks, Imbalance,
OnUnbalanced, OneSessionHandler,
},
weights::constants::RocksDbWeight,
};
@@ -113,12 +114,10 @@ impl FindAuthor<AccountId> for Author11 {
}
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(
frame_support::weights::constants::WEIGHT_PER_SECOND * 2
);
pub const MaxLocks: u32 = 1024;
pub static SessionsPerEra: SessionIndex = 3;
pub static ExistentialDeposit: Balance = 1;
pub static SlashDeferDuration: EraIndex = 0;
@@ -141,7 +140,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = frame_support::traits::ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
@@ -153,7 +152,7 @@ impl frame_system::Config for Test {
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
impl pallet_balances::Config for Test {
type MaxLocks = MaxLocks;
type MaxLocks = frame_support::traits::ConstU32<1024>;
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type Balance = Balance;
@@ -163,9 +162,7 @@ impl pallet_balances::Config for Test {
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const UncleGenerations: u64 = 0;
}
sp_runtime::impl_opaque_keys! {
pub struct SessionKeys {
pub other: OtherSessionHandler,
@@ -189,19 +186,18 @@ impl pallet_session::historical::Config for Test {
}
impl pallet_authorship::Config for Test {
type FindAuthor = Author11;
type UncleGenerations = UncleGenerations;
type UncleGenerations = ConstU64<0>;
type FilterUncle = ();
type EventHandler = Pallet<Test>;
}
parameter_types! {
pub const MinimumPeriod: u64 = 5;
}
impl pallet_timestamp::Config for Test {
type Moment = u64;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
type MinimumPeriod = ConstU64<5>;
type WeightInfo = ();
}
pallet_staking_reward_curve::build! {
const I_NPOS: PiecewiseLinear<'static> = curve!(
min_inflation: 0_025_000,
@@ -215,7 +211,6 @@ pallet_staking_reward_curve::build! {
parameter_types! {
pub const BondingDuration: EraIndex = 3;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &I_NPOS;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(75);
}
@@ -269,7 +264,7 @@ impl crate::pallet::pallet::Config for Test {
type SessionInterface = Self;
type EraPayout = ConvertCurve<RewardCurve>;
type NextNewSession = Session;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type MaxNominatorRewardedPerValidator = ConstU32<64>;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type ElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
type GenesisElectionProvider = Self::ElectionProvider;
+3 -4
View File
@@ -21,7 +21,7 @@ use super::*;
use crate as sudo;
use frame_support::{
parameter_types,
traits::{Contains, GenesisBuild},
traits::{ConstU32, ConstU64, Contains, GenesisBuild},
};
use frame_system::limits;
use sp_core::H256;
@@ -109,7 +109,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: limits::BlockWeights = limits::BlockWeights::simple_max(1024);
}
@@ -135,7 +134,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -144,7 +143,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
// Implement the logger module's `Config` on the Test runtime.
@@ -306,18 +306,14 @@ impl<K, V, S> codec::EncodeLike<BTreeMap<K, V>> for BoundedBTreeMap<K, V, S> whe
pub mod test {
use super::*;
use crate::Twox128;
use frame_support::traits::ConstU32;
use sp_io::TestExternalities;
crate::parameter_types! {
pub const Seven: u32 = 7;
pub const Four: u32 = 4;
}
crate::generate_storage_alias! { Prefix, Foo => Value<BoundedBTreeMap<u32, (), Seven>> }
crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedBTreeMap<u32, (), Seven>> }
crate::generate_storage_alias! { Prefix, Foo => Value<BoundedBTreeMap<u32, (), ConstU32<7>>> }
crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedBTreeMap<u32, (), ConstU32<7>>> }
crate::generate_storage_alias! {
Prefix,
FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedBTreeMap<u32, (), Seven>>
FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedBTreeMap<u32, (), ConstU32<7>>>
}
fn map_from_keys<K>(keys: &[K]) -> BTreeMap<K, ()>
@@ -338,13 +334,13 @@ pub mod test {
#[test]
fn decode_len_works() {
TestExternalities::default().execute_with(|| {
let bounded = boundedmap_from_keys::<u32, Seven>(&[1, 2, 3]);
let bounded = boundedmap_from_keys::<u32, ConstU32<7>>(&[1, 2, 3]);
Foo::put(bounded);
assert_eq!(Foo::decode_len().unwrap(), 3);
});
TestExternalities::default().execute_with(|| {
let bounded = boundedmap_from_keys::<u32, Seven>(&[1, 2, 3]);
let bounded = boundedmap_from_keys::<u32, ConstU32<7>>(&[1, 2, 3]);
FooMap::insert(1, bounded);
assert_eq!(FooMap::decode_len(1).unwrap(), 3);
assert!(FooMap::decode_len(0).is_none());
@@ -352,7 +348,7 @@ pub mod test {
});
TestExternalities::default().execute_with(|| {
let bounded = boundedmap_from_keys::<u32, Seven>(&[1, 2, 3]);
let bounded = boundedmap_from_keys::<u32, ConstU32<7>>(&[1, 2, 3]);
FooDoubleMap::insert(1, 1, bounded);
assert_eq!(FooDoubleMap::decode_len(1, 1).unwrap(), 3);
assert!(FooDoubleMap::decode_len(2, 1).is_none());
@@ -363,7 +359,7 @@ pub mod test {
#[test]
fn try_insert_works() {
let mut bounded = boundedmap_from_keys::<u32, Four>(&[1, 2, 3]);
let mut bounded = boundedmap_from_keys::<u32, ConstU32<4>>(&[1, 2, 3]);
bounded.try_insert(0, ()).unwrap();
assert_eq!(*bounded, map_from_keys(&[1, 0, 2, 3]));
@@ -373,7 +369,7 @@ pub mod test {
#[test]
fn deref_coercion_works() {
let bounded = boundedmap_from_keys::<u32, Seven>(&[1, 2, 3]);
let bounded = boundedmap_from_keys::<u32, ConstU32<7>>(&[1, 2, 3]);
// these methods come from deref-ed vec.
assert_eq!(bounded.len(), 3);
assert!(bounded.iter().next().is_some());
@@ -382,7 +378,7 @@ pub mod test {
#[test]
fn try_mutate_works() {
let bounded = boundedmap_from_keys::<u32, Seven>(&[1, 2, 3, 4, 5, 6]);
let bounded = boundedmap_from_keys::<u32, ConstU32<7>>(&[1, 2, 3, 4, 5, 6]);
let bounded = bounded
.try_mutate(|v| {
v.insert(7, ());
@@ -398,7 +394,7 @@ pub mod test {
#[test]
fn btree_map_eq_works() {
let bounded = boundedmap_from_keys::<u32, Seven>(&[1, 2, 3, 4, 5, 6]);
let bounded = boundedmap_from_keys::<u32, ConstU32<7>>(&[1, 2, 3, 4, 5, 6]);
assert_eq!(bounded, map_from_keys(&[1, 2, 3, 4, 5, 6]));
}
@@ -406,7 +402,7 @@ pub mod test {
fn too_big_fail_to_decode() {
let v: Vec<(u32, u32)> = vec![(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)];
assert_eq!(
BoundedBTreeMap::<u32, u32, Four>::decode(&mut &v.encode()[..]),
BoundedBTreeMap::<u32, u32, ConstU32<4>>::decode(&mut &v.encode()[..]),
Err("BoundedBTreeMap exceeds its limit".into()),
);
}
@@ -436,7 +432,7 @@ pub mod test {
}
}
let mut map = BoundedBTreeMap::<Unequal, u32, Four>::new();
let mut map = BoundedBTreeMap::<Unequal, u32, ConstU32<4>>::new();
// when the set is full
@@ -287,19 +287,15 @@ impl<T, S> codec::EncodeLike<BTreeSet<T>> for BoundedBTreeSet<T, S> where BTreeS
pub mod test {
use super::*;
use crate::Twox128;
use frame_support::traits::ConstU32;
use sp_io::TestExternalities;
use sp_std::convert::TryInto;
crate::parameter_types! {
pub const Seven: u32 = 7;
pub const Four: u32 = 4;
}
crate::generate_storage_alias! { Prefix, Foo => Value<BoundedBTreeSet<u32, Seven>> }
crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedBTreeSet<u32, Seven>> }
crate::generate_storage_alias! { Prefix, Foo => Value<BoundedBTreeSet<u32, ConstU32<7>>> }
crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedBTreeSet<u32, ConstU32<7>>> }
crate::generate_storage_alias! {
Prefix,
FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedBTreeSet<u32, Seven>>
FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedBTreeSet<u32, ConstU32<7>>>
}
fn map_from_keys<T>(keys: &[T]) -> BTreeSet<T>
@@ -320,13 +316,13 @@ pub mod test {
#[test]
fn decode_len_works() {
TestExternalities::default().execute_with(|| {
let bounded = boundedmap_from_keys::<u32, Seven>(&[1, 2, 3]);
let bounded = boundedmap_from_keys::<u32, ConstU32<7>>(&[1, 2, 3]);
Foo::put(bounded);
assert_eq!(Foo::decode_len().unwrap(), 3);
});
TestExternalities::default().execute_with(|| {
let bounded = boundedmap_from_keys::<u32, Seven>(&[1, 2, 3]);
let bounded = boundedmap_from_keys::<u32, ConstU32<7>>(&[1, 2, 3]);
FooMap::insert(1, bounded);
assert_eq!(FooMap::decode_len(1).unwrap(), 3);
assert!(FooMap::decode_len(0).is_none());
@@ -334,7 +330,7 @@ pub mod test {
});
TestExternalities::default().execute_with(|| {
let bounded = boundedmap_from_keys::<u32, Seven>(&[1, 2, 3]);
let bounded = boundedmap_from_keys::<u32, ConstU32<7>>(&[1, 2, 3]);
FooDoubleMap::insert(1, 1, bounded);
assert_eq!(FooDoubleMap::decode_len(1, 1).unwrap(), 3);
assert!(FooDoubleMap::decode_len(2, 1).is_none());
@@ -345,7 +341,7 @@ pub mod test {
#[test]
fn try_insert_works() {
let mut bounded = boundedmap_from_keys::<u32, Four>(&[1, 2, 3]);
let mut bounded = boundedmap_from_keys::<u32, ConstU32<4>>(&[1, 2, 3]);
bounded.try_insert(0).unwrap();
assert_eq!(*bounded, map_from_keys(&[1, 0, 2, 3]));
@@ -355,7 +351,7 @@ pub mod test {
#[test]
fn deref_coercion_works() {
let bounded = boundedmap_from_keys::<u32, Seven>(&[1, 2, 3]);
let bounded = boundedmap_from_keys::<u32, ConstU32<7>>(&[1, 2, 3]);
// these methods come from deref-ed vec.
assert_eq!(bounded.len(), 3);
assert!(bounded.iter().next().is_some());
@@ -364,7 +360,7 @@ pub mod test {
#[test]
fn try_mutate_works() {
let bounded = boundedmap_from_keys::<u32, Seven>(&[1, 2, 3, 4, 5, 6]);
let bounded = boundedmap_from_keys::<u32, ConstU32<7>>(&[1, 2, 3, 4, 5, 6]);
let bounded = bounded
.try_mutate(|v| {
v.insert(7);
@@ -380,7 +376,7 @@ pub mod test {
#[test]
fn btree_map_eq_works() {
let bounded = boundedmap_from_keys::<u32, Seven>(&[1, 2, 3, 4, 5, 6]);
let bounded = boundedmap_from_keys::<u32, ConstU32<7>>(&[1, 2, 3, 4, 5, 6]);
assert_eq!(bounded, map_from_keys(&[1, 2, 3, 4, 5, 6]));
}
@@ -388,7 +384,7 @@ pub mod test {
fn too_big_fail_to_decode() {
let v: Vec<u32> = vec![1, 2, 3, 4, 5];
assert_eq!(
BoundedBTreeSet::<u32, Four>::decode(&mut &v.encode()[..]),
BoundedBTreeSet::<u32, ConstU32<4>>::decode(&mut &v.encode()[..]),
Err("BoundedBTreeSet exceeds its limit".into()),
);
}
@@ -418,7 +414,7 @@ pub mod test {
}
}
let mut set = BoundedBTreeSet::<Unequal, Four>::new();
let mut set = BoundedBTreeSet::<Unequal, ConstU32<4>>::new();
// when the set is full
@@ -348,35 +348,31 @@ where
pub mod test {
use super::*;
use crate::Twox128;
use frame_support::traits::ConstU32;
use sp_io::TestExternalities;
crate::parameter_types! {
pub const Seven: u32 = 7;
pub const Four: u32 = 4;
}
crate::generate_storage_alias! { Prefix, Foo => Value<BoundedVec<u32, Seven>> }
crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedVec<u32, Seven>> }
crate::generate_storage_alias! { Prefix, Foo => Value<BoundedVec<u32, ConstU32<7>>> }
crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedVec<u32, ConstU32<7>>> }
crate::generate_storage_alias! {
Prefix,
FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedVec<u32, Seven>>
FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedVec<u32, ConstU32<7>>>
}
#[test]
fn try_append_is_correct() {
assert_eq!(BoundedVec::<u32, Seven>::bound(), 7);
assert_eq!(BoundedVec::<u32, ConstU32<7>>::bound(), 7);
}
#[test]
fn decode_len_works() {
TestExternalities::default().execute_with(|| {
let bounded: BoundedVec<u32, Seven> = vec![1, 2, 3].try_into().unwrap();
let bounded: BoundedVec<u32, ConstU32<7>> = vec![1, 2, 3].try_into().unwrap();
Foo::put(bounded);
assert_eq!(Foo::decode_len().unwrap(), 3);
});
TestExternalities::default().execute_with(|| {
let bounded: BoundedVec<u32, Seven> = vec![1, 2, 3].try_into().unwrap();
let bounded: BoundedVec<u32, ConstU32<7>> = vec![1, 2, 3].try_into().unwrap();
FooMap::insert(1, bounded);
assert_eq!(FooMap::decode_len(1).unwrap(), 3);
assert!(FooMap::decode_len(0).is_none());
@@ -384,7 +380,7 @@ pub mod test {
});
TestExternalities::default().execute_with(|| {
let bounded: BoundedVec<u32, Seven> = vec![1, 2, 3].try_into().unwrap();
let bounded: BoundedVec<u32, ConstU32<7>> = vec![1, 2, 3].try_into().unwrap();
FooDoubleMap::insert(1, 1, bounded);
assert_eq!(FooDoubleMap::decode_len(1, 1).unwrap(), 3);
assert!(FooDoubleMap::decode_len(2, 1).is_none());
@@ -395,7 +391,7 @@ pub mod test {
#[test]
fn try_insert_works() {
let mut bounded: BoundedVec<u32, Four> = vec![1, 2, 3].try_into().unwrap();
let mut bounded: BoundedVec<u32, ConstU32<4>> = vec![1, 2, 3].try_into().unwrap();
bounded.try_insert(1, 0).unwrap();
assert_eq!(*bounded, vec![1, 0, 2, 3]);
@@ -406,13 +402,13 @@ pub mod test {
#[test]
#[should_panic(expected = "insertion index (is 9) should be <= len (is 3)")]
fn try_inert_panics_if_oob() {
let mut bounded: BoundedVec<u32, Four> = vec![1, 2, 3].try_into().unwrap();
let mut bounded: BoundedVec<u32, ConstU32<4>> = vec![1, 2, 3].try_into().unwrap();
bounded.try_insert(9, 0).unwrap();
}
#[test]
fn try_push_works() {
let mut bounded: BoundedVec<u32, Four> = vec![1, 2, 3].try_into().unwrap();
let mut bounded: BoundedVec<u32, ConstU32<4>> = vec![1, 2, 3].try_into().unwrap();
bounded.try_push(0).unwrap();
assert_eq!(*bounded, vec![1, 2, 3, 0]);
@@ -421,7 +417,7 @@ pub mod test {
#[test]
fn deref_coercion_works() {
let bounded: BoundedVec<u32, Seven> = vec![1, 2, 3].try_into().unwrap();
let bounded: BoundedVec<u32, ConstU32<7>> = vec![1, 2, 3].try_into().unwrap();
// these methods come from deref-ed vec.
assert_eq!(bounded.len(), 3);
assert!(bounded.iter().next().is_some());
@@ -430,7 +426,7 @@ pub mod test {
#[test]
fn try_mutate_works() {
let bounded: BoundedVec<u32, Seven> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap();
let bounded: BoundedVec<u32, ConstU32<7>> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap();
let bounded = bounded.try_mutate(|v| v.push(7)).unwrap();
assert_eq!(bounded.len(), 7);
assert!(bounded.try_mutate(|v| v.push(8)).is_none());
@@ -438,13 +434,13 @@ pub mod test {
#[test]
fn slice_indexing_works() {
let bounded: BoundedVec<u32, Seven> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap();
let bounded: BoundedVec<u32, ConstU32<7>> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap();
assert_eq!(&bounded[0..=2], &[1, 2, 3]);
}
#[test]
fn vec_eq_works() {
let bounded: BoundedVec<u32, Seven> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap();
let bounded: BoundedVec<u32, ConstU32<7>> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap();
assert_eq!(bounded, vec![1, 2, 3, 4, 5, 6]);
}
@@ -452,7 +448,7 @@ pub mod test {
fn too_big_vec_fail_to_decode() {
let v: Vec<u32> = vec![1, 2, 3, 4, 5];
assert_eq!(
BoundedVec::<u32, Four>::decode(&mut &v.encode()[..]),
BoundedVec::<u32, ConstU32<4>>::decode(&mut &v.encode()[..]),
Err("BoundedVec exceeds its limit".into()),
);
}
+11 -15
View File
@@ -1404,6 +1404,7 @@ mod test {
use super::*;
use crate::{assert_ok, hash::Identity, Twox128};
use bounded_vec::BoundedVec;
use frame_support::traits::ConstU32;
use generator::StorageValue as _;
use sp_core::hashing::twox_128;
use sp_io::TestExternalities;
@@ -1714,22 +1715,17 @@ mod test {
});
}
crate::parameter_types! {
pub const Seven: u32 = 7;
pub const Four: u32 = 4;
}
crate::generate_storage_alias! { Prefix, Foo => Value<WeakBoundedVec<u32, Seven>> }
crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedVec<u32, Seven>> }
crate::generate_storage_alias! { Prefix, Foo => Value<WeakBoundedVec<u32, ConstU32<7>>> }
crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedVec<u32, ConstU32<7>>> }
crate::generate_storage_alias! {
Prefix,
FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedVec<u32, Seven>>
FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedVec<u32, ConstU32<7>>>
}
#[test]
fn try_append_works() {
TestExternalities::default().execute_with(|| {
let bounded: WeakBoundedVec<u32, Seven> = vec![1, 2, 3].try_into().unwrap();
let bounded: WeakBoundedVec<u32, ConstU32<7>> = vec![1, 2, 3].try_into().unwrap();
Foo::put(bounded);
assert_ok!(Foo::try_append(4));
assert_ok!(Foo::try_append(5));
@@ -1740,7 +1736,7 @@ mod test {
});
TestExternalities::default().execute_with(|| {
let bounded: BoundedVec<u32, Seven> = vec![1, 2, 3].try_into().unwrap();
let bounded: BoundedVec<u32, ConstU32<7>> = vec![1, 2, 3].try_into().unwrap();
FooMap::insert(1, bounded);
assert_ok!(FooMap::try_append(1, 4));
@@ -1755,17 +1751,17 @@ mod test {
assert_ok!(FooMap::try_append(2, 4));
assert_eq!(
FooMap::get(2).unwrap(),
BoundedVec::<u32, Seven>::try_from(vec![4]).unwrap(),
BoundedVec::<u32, ConstU32<7>>::try_from(vec![4]).unwrap(),
);
assert_ok!(FooMap::try_append(2, 5));
assert_eq!(
FooMap::get(2).unwrap(),
BoundedVec::<u32, Seven>::try_from(vec![4, 5]).unwrap(),
BoundedVec::<u32, ConstU32<7>>::try_from(vec![4, 5]).unwrap(),
);
});
TestExternalities::default().execute_with(|| {
let bounded: BoundedVec<u32, Seven> = vec![1, 2, 3].try_into().unwrap();
let bounded: BoundedVec<u32, ConstU32<7>> = vec![1, 2, 3].try_into().unwrap();
FooDoubleMap::insert(1, 1, bounded);
assert_ok!(FooDoubleMap::try_append(1, 1, 4));
@@ -1780,12 +1776,12 @@ mod test {
assert_ok!(FooDoubleMap::try_append(2, 1, 4));
assert_eq!(
FooDoubleMap::get(2, 1).unwrap(),
BoundedVec::<u32, Seven>::try_from(vec![4]).unwrap(),
BoundedVec::<u32, ConstU32<7>>::try_from(vec![4]).unwrap(),
);
assert_ok!(FooDoubleMap::try_append(2, 1, 5));
assert_eq!(
FooDoubleMap::get(2, 1).unwrap(),
BoundedVec::<u32, Seven>::try_from(vec![4, 5]).unwrap(),
BoundedVec::<u32, ConstU32<7>>::try_from(vec![4, 5]).unwrap(),
);
});
}
@@ -318,36 +318,32 @@ where
pub mod test {
use super::*;
use crate::Twox128;
use frame_support::traits::ConstU32;
use sp_io::TestExternalities;
use sp_std::convert::TryInto;
crate::parameter_types! {
pub const Seven: u32 = 7;
pub const Four: u32 = 4;
}
crate::generate_storage_alias! { Prefix, Foo => Value<WeakBoundedVec<u32, Seven>> }
crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), WeakBoundedVec<u32, Seven>> }
crate::generate_storage_alias! { Prefix, Foo => Value<WeakBoundedVec<u32, ConstU32<7>>> }
crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), WeakBoundedVec<u32, ConstU32<7>>> }
crate::generate_storage_alias! {
Prefix,
FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), WeakBoundedVec<u32, Seven>>
FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), WeakBoundedVec<u32, ConstU32<7>>>
}
#[test]
fn try_append_is_correct() {
assert_eq!(WeakBoundedVec::<u32, Seven>::bound(), 7);
assert_eq!(WeakBoundedVec::<u32, ConstU32<7>>::bound(), 7);
}
#[test]
fn decode_len_works() {
TestExternalities::default().execute_with(|| {
let bounded: WeakBoundedVec<u32, Seven> = vec![1, 2, 3].try_into().unwrap();
let bounded: WeakBoundedVec<u32, ConstU32<7>> = vec![1, 2, 3].try_into().unwrap();
Foo::put(bounded);
assert_eq!(Foo::decode_len().unwrap(), 3);
});
TestExternalities::default().execute_with(|| {
let bounded: WeakBoundedVec<u32, Seven> = vec![1, 2, 3].try_into().unwrap();
let bounded: WeakBoundedVec<u32, ConstU32<7>> = vec![1, 2, 3].try_into().unwrap();
FooMap::insert(1, bounded);
assert_eq!(FooMap::decode_len(1).unwrap(), 3);
assert!(FooMap::decode_len(0).is_none());
@@ -355,7 +351,7 @@ pub mod test {
});
TestExternalities::default().execute_with(|| {
let bounded: WeakBoundedVec<u32, Seven> = vec![1, 2, 3].try_into().unwrap();
let bounded: WeakBoundedVec<u32, ConstU32<7>> = vec![1, 2, 3].try_into().unwrap();
FooDoubleMap::insert(1, 1, bounded);
assert_eq!(FooDoubleMap::decode_len(1, 1).unwrap(), 3);
assert!(FooDoubleMap::decode_len(2, 1).is_none());
@@ -366,7 +362,7 @@ pub mod test {
#[test]
fn try_insert_works() {
let mut bounded: WeakBoundedVec<u32, Four> = vec![1, 2, 3].try_into().unwrap();
let mut bounded: WeakBoundedVec<u32, ConstU32<4>> = vec![1, 2, 3].try_into().unwrap();
bounded.try_insert(1, 0).unwrap();
assert_eq!(*bounded, vec![1, 0, 2, 3]);
@@ -377,13 +373,13 @@ pub mod test {
#[test]
#[should_panic(expected = "insertion index (is 9) should be <= len (is 3)")]
fn try_inert_panics_if_oob() {
let mut bounded: WeakBoundedVec<u32, Four> = vec![1, 2, 3].try_into().unwrap();
let mut bounded: WeakBoundedVec<u32, ConstU32<4>> = vec![1, 2, 3].try_into().unwrap();
bounded.try_insert(9, 0).unwrap();
}
#[test]
fn try_push_works() {
let mut bounded: WeakBoundedVec<u32, Four> = vec![1, 2, 3].try_into().unwrap();
let mut bounded: WeakBoundedVec<u32, ConstU32<4>> = vec![1, 2, 3].try_into().unwrap();
bounded.try_push(0).unwrap();
assert_eq!(*bounded, vec![1, 2, 3, 0]);
@@ -392,7 +388,7 @@ pub mod test {
#[test]
fn deref_coercion_works() {
let bounded: WeakBoundedVec<u32, Seven> = vec![1, 2, 3].try_into().unwrap();
let bounded: WeakBoundedVec<u32, ConstU32<7>> = vec![1, 2, 3].try_into().unwrap();
// these methods come from deref-ed vec.
assert_eq!(bounded.len(), 3);
assert!(bounded.iter().next().is_some());
@@ -401,7 +397,7 @@ pub mod test {
#[test]
fn try_mutate_works() {
let bounded: WeakBoundedVec<u32, Seven> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap();
let bounded: WeakBoundedVec<u32, ConstU32<7>> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap();
let bounded = bounded.try_mutate(|v| v.push(7)).unwrap();
assert_eq!(bounded.len(), 7);
assert!(bounded.try_mutate(|v| v.push(8)).is_none());
@@ -409,20 +405,20 @@ pub mod test {
#[test]
fn slice_indexing_works() {
let bounded: WeakBoundedVec<u32, Seven> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap();
let bounded: WeakBoundedVec<u32, ConstU32<7>> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap();
assert_eq!(&bounded[0..=2], &[1, 2, 3]);
}
#[test]
fn vec_eq_works() {
let bounded: WeakBoundedVec<u32, Seven> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap();
let bounded: WeakBoundedVec<u32, ConstU32<7>> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap();
assert_eq!(bounded, vec![1, 2, 3, 4, 5, 6]);
}
#[test]
fn too_big_succeed_to_decode() {
let v: Vec<u32> = vec![1, 2, 3, 4, 5];
let w = WeakBoundedVec::<u32, Four>::decode(&mut &v.encode()[..]).unwrap();
let w = WeakBoundedVec::<u32, ConstU32<4>>::decode(&mut &v.encode()[..]).unwrap();
assert_eq!(v, *w);
}
}
@@ -22,7 +22,10 @@
//! This crate tests that `construct_runtime!` expands the pallet parts
//! correctly even when frame-support is renamed in Cargo.toml
use frame_support::{construct_runtime, parameter_types};
use frame_support::{
construct_runtime, parameter_types,
traits::{ConstU16, ConstU32},
};
use sp_core::{sr25519, H256};
use sp_runtime::{
create_runtime_str, generic,
@@ -48,7 +51,6 @@ pub type Index = u64;
parameter_types! {
pub const BlockHashCount: BlockNumber = 2400;
pub const Version: RuntimeVersion = VERSION;
pub const SS58Prefix: u8 = 0;
}
impl frame_system::Config for Runtime {
@@ -73,9 +75,9 @@ impl frame_system::Config for Runtime {
type OnNewAccount = ();
type OnKilledAccount = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
type SS58Prefix = ConstU16<0>;
}
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
@@ -24,8 +24,7 @@ use frame_support::{
PalletStorageMetadata, StorageEntryMetadata, StorageEntryModifier, StorageEntryType,
StorageHasher,
},
parameter_types,
traits::Get,
traits::{ConstU32, Get},
Parameter, StorageDoubleMap, StorageMap, StorageValue,
};
use scale_info::TypeInfo;
@@ -229,20 +228,16 @@ mod module3 {
}
}
parameter_types! {
pub const SomeValue: u32 = 100;
}
impl module1::Config<module1::Instance1> for Runtime {
type Event = Event;
type Origin = Origin;
type SomeParameter = SomeValue;
type SomeParameter = ConstU32<100>;
type GenericType = u32;
}
impl module1::Config<module1::Instance2> for Runtime {
type Event = Event;
type Origin = Origin;
type SomeParameter = SomeValue;
type SomeParameter = ConstU32<100>;
type GenericType = u32;
}
impl module2::Config for Runtime {
+6 -9
View File
@@ -19,8 +19,8 @@ use frame_support::{
dispatch::{Parameter, UnfilteredDispatchable},
storage::unhashed,
traits::{
GetCallName, GetStorageVersion, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade,
PalletInfoAccess, StorageVersion,
ConstU32, GetCallName, GetStorageVersion, OnFinalize, OnGenesis, OnInitialize,
OnRuntimeUpgrade, PalletInfoAccess, StorageVersion,
},
weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays, RuntimeDbWeight},
};
@@ -536,10 +536,7 @@ pub mod pallet4 {
}
frame_support::parameter_types!(
pub const MyGetParam: u32 = 10;
pub const MyGetParam2: u32 = 11;
pub const MyGetParam3: u32 = 12;
pub const BlockHashCount: u32 = 250;
);
impl frame_system::Config for Runtime {
@@ -554,7 +551,7 @@ impl frame_system::Config for Runtime {
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU32<250>;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
@@ -566,12 +563,12 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet::Config for Runtime {
type Event = Event;
type MyGetParam = MyGetParam;
type MyGetParam2 = MyGetParam2;
type MyGetParam = ConstU32<10>;
type MyGetParam2 = ConstU32<11>;
type MyGetParam3 = MyGetParam3;
type Balance = u64;
}
@@ -15,6 +15,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use frame_support::traits::{ConstU32, ConstU64};
pub trait SomeAssociation {
type A: frame_support::dispatch::Parameter + Default;
}
@@ -217,11 +219,6 @@ pub mod pallet {
}
}
frame_support::parameter_types!(
pub const SomeConst: u64 = 10;
pub const BlockHashCount: u32 = 250;
);
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type Origin = Origin;
@@ -234,7 +231,7 @@ impl frame_system::Config for Runtime {
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU32<250>;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
@@ -246,16 +243,16 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet::Config for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
impl pallet_old::Config for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
@@ -15,6 +15,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use frame_support::traits::{ConstU32, ConstU64};
mod pallet_old {
use frame_support::{
decl_error, decl_event, decl_module, decl_storage, traits::Get, weights::Weight, Parameter,
@@ -197,11 +199,6 @@ pub mod pallet {
}
}
frame_support::parameter_types!(
pub const SomeConst: u64 = 10;
pub const BlockHashCount: u32 = 250;
);
impl frame_system::Config for Runtime {
type BlockWeights = ();
type BlockLength = ();
@@ -217,7 +214,7 @@ impl frame_system::Config for Runtime {
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU32<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -226,36 +223,36 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet::Config for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
impl pallet::Config<pallet::Instance2> for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
impl pallet::Config<pallet::Instance3> for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
impl pallet_old::Config for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
impl pallet_old::Config<pallet_old::Instance2> for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
impl pallet_old::Config<pallet_old::Instance3> for Runtime {
type Event = Event;
type SomeConst = SomeConst;
type SomeConst = ConstU64<10>;
type Balance = u64;
}
@@ -18,7 +18,7 @@
use frame_support::{
dispatch::UnfilteredDispatchable,
storage::unhashed,
traits::{GetCallName, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade},
traits::{ConstU32, GetCallName, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade},
weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays},
};
use sp_io::{
@@ -245,11 +245,6 @@ pub mod pallet2 {
}
}
frame_support::parameter_types!(
pub const MyGetParam: u32 = 10;
pub const BlockHashCount: u32 = 250;
);
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type Origin = Origin;
@@ -262,7 +257,7 @@ impl frame_system::Config for Runtime {
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU32<250>;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
@@ -274,16 +269,16 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet::Config for Runtime {
type Event = Event;
type MyGetParam = MyGetParam;
type MyGetParam = ConstU32<10>;
type Balance = u64;
}
impl pallet::Config<pallet::Instance1> for Runtime {
type Event = Event;
type MyGetParam = MyGetParam;
type MyGetParam = ConstU32<10>;
type Balance = u64;
}
impl pallet2::Config for Runtime {
@@ -97,7 +97,7 @@ impl<T: Trait> frame_support::inherent::ProvideInherent for Module<T> {
mod tests {
use crate as pallet_test;
use frame_support::parameter_types;
use frame_support::traits::ConstU64;
type SignedExtra = (
frame_system::CheckEra<Runtime>,
@@ -124,10 +124,6 @@ mod tests {
}
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
}
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type Origin = Origin;
@@ -140,7 +136,7 @@ mod tests {
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
type Header = TestHeader;
type Event = ();
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
type BlockWeights = ();
type BlockLength = ();
+3 -3
View File
@@ -16,6 +16,7 @@
// limitations under the License.
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use frame_support::traits::{ConstU32, ConstU64};
use sp_core::H256;
use sp_runtime::{
testing::Header,
@@ -58,7 +59,6 @@ frame_support::construct_runtime!(
);
frame_support::parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::with_sensible_defaults(
4 * 1024 * 1024, Perbill::from_percent(75),
@@ -83,7 +83,7 @@ impl frame_system::Config for Runtime {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -92,7 +92,7 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl module::Config for Runtime {
+6 -4
View File
@@ -16,7 +16,10 @@
// limitations under the License.
use crate::{self as frame_system, *};
use frame_support::parameter_types;
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64},
};
use sp_core::H256;
use sp_runtime::{
testing::Header,
@@ -42,7 +45,6 @@ const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
const MAX_BLOCK_WEIGHT: Weight = 1024;
parameter_types! {
pub const BlockHashCount: u64 = 10;
pub Version: RuntimeVersion = RuntimeVersion {
spec_name: sp_version::create_runtime_str!("test"),
impl_name: sp_version::create_runtime_str!("system-test"),
@@ -101,7 +103,7 @@ impl Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<10>;
type DbWeight = DbWeight;
type Version = Version;
type PalletInfo = PalletInfo;
@@ -111,7 +113,7 @@ impl Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
pub type SysEvent = frame_system::Event<Test>;
+8 -8
View File
@@ -316,7 +316,10 @@ mod tests {
use super::*;
use crate as pallet_timestamp;
use frame_support::{assert_ok, parameter_types};
use frame_support::{
assert_ok, parameter_types,
traits::{ConstU32, ConstU64},
};
use sp_core::H256;
use sp_io::TestExternalities;
use sp_runtime::{
@@ -344,7 +347,6 @@ mod tests {
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -363,7 +365,7 @@ mod tests {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
@@ -372,15 +374,13 @@ mod tests {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const MinimumPeriod: u64 = 5;
type MaxConsumers = ConstU32<16>;
}
impl Config for Test {
type Moment = u64;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
type MinimumPeriod = ConstU64<5>;
type WeightInfo = ();
}
+17 -25
View File
@@ -30,8 +30,12 @@ use sp_runtime::{
use sp_storage::Storage;
use frame_support::{
assert_noop, assert_ok, pallet_prelude::GenesisBuild, parameter_types,
storage::StoragePrefixedMap, traits::SortedMembers, weights::Weight, PalletId,
assert_noop, assert_ok,
pallet_prelude::GenesisBuild,
parameter_types,
storage::StoragePrefixedMap,
traits::{ConstU32, ConstU64, SortedMembers},
PalletId,
};
use super::*;
@@ -54,9 +58,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: Weight = 1024;
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
impl frame_system::Config for Test {
@@ -74,7 +75,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -83,11 +84,9 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
@@ -95,7 +94,7 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
@@ -126,13 +125,8 @@ impl ContainsLengthBound for TenToFourteen {
}
parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: u64 = 1;
pub const SpendPeriod: u64 = 2;
pub const Burn: Permill = Permill::from_percent(50);
pub const DataDepositPerByte: u64 = 1;
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
pub const MaximumReasonLength: u32 = 16384;
pub const MaxApprovals: u32 = 100;
}
impl pallet_treasury::Config for Test {
type PalletId = TreasuryPalletId;
@@ -142,26 +136,24 @@ impl pallet_treasury::Config for Test {
type Event = Event;
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type ProposalBondMinimum = ConstU64<1>;
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
type WeightInfo = ();
type SpendFunds = ();
type MaxApprovals = MaxApprovals;
type MaxApprovals = ConstU32<100>;
}
parameter_types! {
pub const TipCountdown: u64 = 1;
pub const TipFindersFee: Percent = Percent::from_percent(20);
pub const TipReportDepositBase: u64 = 1;
}
impl Config for Test {
type MaximumReasonLength = MaximumReasonLength;
type MaximumReasonLength = ConstU32<16384>;
type Tippers = TenToFourteen;
type TipCountdown = TipCountdown;
type TipCountdown = ConstU64<1>;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type DataDepositPerByte = DataDepositPerByte;
type TipReportDepositBase = ConstU64<1>;
type DataDepositPerByte = ConstU64<1>;
type Event = Event;
type WeightInfo = ();
}
@@ -20,7 +20,7 @@ use frame_support::{
assert_ok,
pallet_prelude::*,
parameter_types,
traits::{fungibles::Mutate, FindAuthor},
traits::{fungibles::Mutate, ConstU32, ConstU64, ConstU8, FindAuthor},
weights::{
DispatchClass, DispatchInfo, PostDispatchInfo, Weight, WeightToFeeCoefficient,
WeightToFeeCoefficients, WeightToFeePolynomial,
@@ -83,7 +83,6 @@ impl Get<frame_system::limits::BlockWeights> for BlockWeights {
}
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub static TransactionByteFee: u64 = 1;
pub static WeightToFee: u64 = 1;
}
@@ -103,7 +102,7 @@ impl frame_system::Config for Runtime {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -112,23 +111,22 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 10;
pub const MaxReserves: u32 = 50;
}
impl pallet_balances::Config for Runtime {
type Balance = Balance;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<10>;
type AccountStore = System;
type MaxLocks = ();
type WeightInfo = ();
type MaxReserves = MaxReserves;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
}
@@ -145,22 +143,12 @@ impl WeightToFeePolynomial for WeightToFee {
}
}
parameter_types! {
pub const OperationalFeeMultiplier: u8 = 5;
}
impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = WeightToFee;
type FeeMultiplierUpdate = ();
type OperationalFeeMultiplier = OperationalFeeMultiplier;
}
parameter_types! {
pub const AssetDeposit: u64 = 2;
pub const MetadataDeposit: u64 = 0;
pub const StringLimit: u32 = 20;
type OperationalFeeMultiplier = ConstU8<5>;
}
impl pallet_assets::Config for Runtime {
@@ -169,12 +157,12 @@ impl pallet_assets::Config for Runtime {
type AssetId = u32;
type Currency = Balances;
type ForceOrigin = EnsureRoot<AccountId>;
type AssetDeposit = AssetDeposit;
type AssetAccountDeposit = frame_support::traits::ConstU64<2>;
type MetadataDepositBase = MetadataDeposit;
type MetadataDepositPerByte = MetadataDeposit;
type ApprovalDeposit = MetadataDeposit;
type StringLimit = StringLimit;
type AssetDeposit = ConstU64<2>;
type AssetAccountDeposit = ConstU64<2>;
type MetadataDepositBase = ConstU64<0>;
type MetadataDepositPerByte = ConstU64<0>;
type ApprovalDeposit = ConstU64<0>;
type StringLimit = ConstU32<20>;
type Freezer = ();
type Extra = ();
type WeightInfo = ();
@@ -789,7 +789,7 @@ mod tests {
use frame_support::{
assert_noop, assert_ok, parameter_types,
traits::{Currency, Imbalance, OnUnbalanced},
traits::{ConstU32, ConstU64, Currency, Imbalance, OnUnbalanced},
weights::{
DispatchClass, DispatchInfo, GetDispatchInfo, PostDispatchInfo, Weight,
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
@@ -836,7 +836,6 @@ mod tests {
}
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub static TransactionByteFee: u64 = 1;
pub static WeightToFee: u64 = 1;
pub static OperationalFeeMultiplier: u8 = 5;
@@ -857,7 +856,7 @@ mod tests {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -866,18 +865,14 @@ mod tests {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Runtime {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type MaxLocks = ();
type MaxReserves = ();
@@ -19,10 +19,7 @@
use crate as pallet_transaction_storage;
use crate::TransactionStorageProof;
use frame_support::{
parameter_types,
traits::{OnFinalize, OnInitialize},
};
use frame_support::traits::{ConstU16, ConstU32, ConstU64, OnFinalize, OnInitialize};
use sp_core::H256;
use sp_runtime::{
testing::Header,
@@ -48,11 +45,6 @@ frame_support::construct_runtime!(
}
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const SS58Prefix: u8 = 42;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
@@ -67,7 +59,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
@@ -75,20 +67,16 @@ impl frame_system::Config for Test {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = SS58Prefix;
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
type Balance = u64;
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
type MaxLocks = ();
+9 -12
View File
@@ -28,7 +28,10 @@ use sp_runtime::{
};
use frame_support::{
assert_noop, assert_ok, pallet_prelude::GenesisBuild, parameter_types, traits::OnInitialize,
assert_noop, assert_ok,
pallet_prelude::GenesisBuild,
parameter_types,
traits::{ConstU32, ConstU64, OnInitialize},
PalletId,
};
@@ -51,7 +54,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -70,7 +72,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -79,10 +81,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
type MaxLocks = ();
@@ -91,7 +90,7 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
@@ -100,8 +99,6 @@ thread_local! {
}
parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: u64 = 1;
pub const SpendPeriod: u64 = 2;
pub const Burn: Permill = Permill::from_percent(50);
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
pub const BountyUpdatePeriod: u32 = 20;
@@ -117,8 +114,8 @@ impl Config for Test {
type Event = Event;
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type ProposalBondMinimum = ConstU64<1>;
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
type WeightInfo = ();
+16 -32
View File
@@ -20,7 +20,10 @@
use super::*;
use crate as pallet_uniques;
use frame_support::{construct_runtime, parameter_types};
use frame_support::{
construct_runtime,
traits::{ConstU32, ConstU64},
};
use sp_core::H256;
use sp_runtime::{
testing::Header,
@@ -42,9 +45,6 @@ construct_runtime!(
}
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
@@ -59,7 +59,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
@@ -69,51 +69,35 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
pub const MaxReserves: u32 = 50;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
type Balance = u64;
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
type MaxLocks = ();
type MaxReserves = MaxReserves;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
}
parameter_types! {
pub const ClassDeposit: u64 = 2;
pub const InstanceDeposit: u64 = 1;
pub const KeyLimit: u32 = 50;
pub const ValueLimit: u32 = 50;
pub const StringLimit: u32 = 50;
pub const MetadataDepositBase: u64 = 1;
pub const AttributeDepositBase: u64 = 1;
pub const MetadataDepositPerByte: u64 = 1;
}
impl Config for Test {
type Event = Event;
type ClassId = u32;
type InstanceId = u32;
type Currency = Balances;
type ForceOrigin = frame_system::EnsureRoot<u64>;
type ClassDeposit = ClassDeposit;
type InstanceDeposit = InstanceDeposit;
type MetadataDepositBase = MetadataDepositBase;
type AttributeDepositBase = AttributeDepositBase;
type DepositPerByte = MetadataDepositPerByte;
type StringLimit = StringLimit;
type KeyLimit = KeyLimit;
type ValueLimit = ValueLimit;
type ClassDeposit = ConstU64<2>;
type InstanceDeposit = ConstU64<1>;
type MetadataDepositBase = ConstU64<1>;
type AttributeDepositBase = ConstU64<1>;
type DepositPerByte = ConstU64<1>;
type StringLimit = ConstU32<50>;
type KeyLimit = ConstU32<50>;
type ValueLimit = ConstU32<50>;
type WeightInfo = ();
}
+5 -8
View File
@@ -26,7 +26,7 @@ use frame_support::{
assert_err_ignore_postinfo, assert_noop, assert_ok,
dispatch::{DispatchError, DispatchErrorWithPostInfo, Dispatchable},
parameter_types, storage,
traits::Contains,
traits::{ConstU32, ConstU64, Contains},
weights::{Pays, Weight},
};
use sp_core::H256;
@@ -99,7 +99,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(Weight::max_value());
}
@@ -118,7 +117,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
@@ -127,11 +126,9 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
type MaxConsumers = ConstU32<16>;
}
impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
@@ -139,7 +136,7 @@ impl pallet_balances::Config for Test {
type Balance = u64;
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
}
+7 -7
View File
@@ -15,7 +15,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use frame_support::parameter_types;
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64},
};
use sp_core::H256;
use sp_runtime::{
testing::Header,
@@ -41,7 +44,6 @@ frame_support::construct_runtime!(
);
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
}
@@ -49,7 +51,7 @@ impl frame_system::Config for Test {
type AccountData = pallet_balances::AccountData<u64>;
type AccountId = u64;
type BaseCallFilter = frame_support::traits::Everything;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type BlockLength = ();
type BlockNumber = u64;
type BlockWeights = ();
@@ -71,16 +73,14 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type Version = ();
}
parameter_types! {
pub const MaxLocks: u32 = 10;
}
impl pallet_balances::Config for Test {
type AccountStore = System;
type Balance = u64;
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type MaxLocks = MaxLocks;
type MaxLocks = ConstU32<10>;
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
+5 -8
View File
@@ -38,7 +38,7 @@ use trie_db::{Trie, TrieMut};
use cfg_if::cfg_if;
use frame_support::{
parameter_types,
traits::{CrateVersion, KeyOwnerProofSystem},
traits::{ConstU32, ConstU64, CrateVersion, KeyOwnerProofSystem},
weights::RuntimeDbWeight,
};
use frame_system::limits::{BlockLength, BlockWeights};
@@ -556,7 +556,6 @@ impl frame_support::traits::PalletInfo for Runtime {
parameter_types! {
pub const BlockHashCount: BlockNumber = 2400;
pub const MinimumPeriod: u64 = 5;
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 100,
write: 1000,
@@ -591,26 +590,24 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
impl pallet_timestamp::Config for Runtime {
/// A timestamp: milliseconds since the unix epoch.
type Moment = u64;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
type MinimumPeriod = ConstU64<5>;
type WeightInfo = ();
}
parameter_types! {
pub const EpochDuration: u64 = 6;
pub const ExpectedBlockTime: u64 = 10_000;
pub const MaxAuthorities: u32 = 10;
}
impl pallet_babe::Config for Runtime {
type EpochDuration = EpochDuration;
type ExpectedBlockTime = ExpectedBlockTime;
type ExpectedBlockTime = ConstU64<10_000>;
// there is no actual runtime in this test-runtime, so testing crates
// are manually adding the digests. normally in this situation you'd use
// pallet_babe::SameAuthoritiesForever.
@@ -630,7 +627,7 @@ impl pallet_babe::Config for Runtime {
type HandleEquivocation = ();
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
type MaxAuthorities = ConstU32<10>;
}
/// Adds one to the given input and returns the final result.