From c3365a6f1fc7f8ce97d57977436a26c766176ac6 Mon Sep 17 00:00:00 2001 From: giuseppere Date: Tue, 3 Dec 2024 18:36:16 +0100 Subject: [PATCH] Fix `WeakBoundedVec` and `MaxValidatorsCount` --- substrate/frame/beefy/src/mock.rs | 1 - .../test-delegate-stake/src/lib.rs | 1 - .../test-delegate-stake/src/mock.rs | 1 - substrate/frame/root-offences/src/mock.rs | 4 +++- substrate/frame/staking/src/tests.rs | 20 ++++++++++++------- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index f21c585ecce1..4fa0fc83d079 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -17,7 +17,6 @@ use codec::{Decode, Encode}; use scale_info::TypeInfo; -use std::vec; use frame_election_provider_support::{ bounds::{ElectionBounds, ElectionBoundsBuilder}, diff --git a/substrate/frame/nomination-pools/test-delegate-stake/src/lib.rs b/substrate/frame/nomination-pools/test-delegate-stake/src/lib.rs index cc6335959ab7..3b42e982bb51 100644 --- a/substrate/frame/nomination-pools/test-delegate-stake/src/lib.rs +++ b/substrate/frame/nomination-pools/test-delegate-stake/src/lib.rs @@ -256,7 +256,6 @@ fn pool_chill_e2e() { pallet_staking::ConfigOp::Noop, pallet_staking::ConfigOp::Noop, pallet_staking::ConfigOp::Noop, - pallet_staking::ConfigOp::Noop, )); // members can unbond as long as total stake of the pool is above min nominator bond diff --git a/substrate/frame/nomination-pools/test-delegate-stake/src/mock.rs b/substrate/frame/nomination-pools/test-delegate-stake/src/mock.rs index d1bc4ef8ff28..18033c6a54eb 100644 --- a/substrate/frame/nomination-pools/test-delegate-stake/src/mock.rs +++ b/substrate/frame/nomination-pools/test-delegate-stake/src/mock.rs @@ -329,7 +329,6 @@ pub fn new_test_ext() -> sp_io::TestExternalities { pallet_staking::ConfigOp::Noop, pallet_staking::ConfigOp::Noop, pallet_staking::ConfigOp::Noop, - pallet_staking::ConfigOp::Noop, )); }); diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index 30edd4ba1b4e..f300fe6f45fb 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -28,7 +28,9 @@ use frame_support::{ traits::{ConstU32, ConstU64, Hooks, OneSessionHandler}, }; use pallet_staking::StakerStatus; -use sp_runtime::{curve::PiecewiseLinear, testing::UintAuthorityId, traits::Zero, BuildStorage}; +use sp_runtime::{ + curve::PiecewiseLinear, testing::UintAuthorityId, traits::Zero, BoundedVec, BuildStorage, +}; use sp_staking::{EraIndex, SessionIndex}; type Block = frame_system::mocking::MockBlock; diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 61a80460f493..94c52f231137 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -2329,7 +2329,8 @@ fn reward_validator_slashing_validator_does_not_overflow() { let exposure = Exposure:: { total: stake, own: stake, others: vec![] }; let mut reward_map = BoundedBTreeMap::new(); assert_ok!(reward_map.try_insert(11, 1)); - let reward = EraRewardPoints:: { total: 1, individual: reward_map }; + let reward = + EraRewardPoints:: { total: 1, individual: reward_map }; // Check reward ErasRewardPoints::::insert(0, reward); @@ -6608,7 +6609,7 @@ fn should_retain_era_info_only_upto_history_depth() { for page in 0..3 { ErasStakersPaged::::insert( (era, &validator_stash, page), - ExposurePage { page_total: 100, others: BoundedVec::new() }, + ExposurePage { page_total: 100, others: WeakBoundedVec::new() }, ); } } @@ -6656,7 +6657,8 @@ fn test_runtime_api_pending_rewards() { assert_ok!(reward_map.try_insert(validator_two, 1)); assert_ok!(reward_map.try_insert(validator_three, 1)); // Add reward points - let reward = EraRewardPoints:: { total: 1, individual: reward_map }; + let reward = + EraRewardPoints:: { total: 1, individual: reward_map }; ErasRewardPoints::::insert(0, reward); // build exposure @@ -8497,7 +8499,9 @@ mod migration_tests { mod getters { use crate::{ mock::{self}, - pallet::pallet::{Invulnerables, MinimumValidatorCount, ValidatorCount}, + pallet::pallet::{ + Invulnerables, MaxValidatorsCount, MinimumValidatorCount, ValidatorCount, + }, slashing, tests::{MaxWinners, Staking, Test, WeakBoundedVec}, ActiveEra, ActiveEraInfo, BalanceOf, BoundedBTreeMap, BoundedVec, CanceledSlashPayout, @@ -8506,7 +8510,7 @@ mod getters { Forcing, Nominations, Nominators, Perbill, SlashRewardFraction, SlashingSpans, ValidatorPrefs, Validators, }; - use sp_staking::{EraIndex, Page, SessionIndex}; + use sp_staking::{EraIndex, SessionIndex}; #[test] fn get_validator_count_returns_value_from_storage() { @@ -8701,8 +8705,10 @@ mod getters { let era: EraIndex = 12; let mut reward_map = BoundedBTreeMap::new(); frame_support::assert_ok!(reward_map.try_insert(11, 1)); - let reward_points = - EraRewardPoints:: { total: 1, individual: reward_map }; + let reward_points = EraRewardPoints:: { + total: 1, + individual: reward_map, + }; ErasRewardPoints::::insert(era, reward_points); // when