diff --git a/substrate/frame/staking/src/slashing.rs b/substrate/frame/staking/src/slashing.rs index eb2c02184e96..cf764d1cc10a 100644 --- a/substrate/frame/staking/src/slashing.rs +++ b/substrate/frame/staking/src/slashing.rs @@ -330,7 +330,7 @@ fn add_offending_validator(params: &SlashParams) { // Add the validator to `DisabledValidators` and disable it. Do nothing if it is // already disabled. if let Err(index) = disabled.binary_search_by_key(&offender, |index| *index) { - disabled.try_insert(index, offender); + debug_assert!(disabled.try_insert(index, offender).is_ok()); T::SessionInterface::disable_validator(offender); } } diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index d158b4f18851..42391859c52a 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -8353,11 +8353,11 @@ mod getters { pallet::pallet::{Invulnerables, MinimumValidatorCount, ValidatorCount}, slashing, tests::{Staking, Test}, - ActiveEra, ActiveEraInfo, BalanceOf, CanceledSlashPayout, ClaimedRewards, CurrentEra, - CurrentPlannedSession, EraRewardPoints, ErasRewardPoints, ErasStakersClipped, - ErasStartSessionIndex, ErasTotalStake, ErasValidatorPrefs, ErasValidatorReward, ForceEra, - Forcing, Nominations, Nominators, Perbill, SlashRewardFraction, SlashingSpans, - ValidatorPrefs, Validators, + ActiveEra, ActiveEraInfo, BalanceOf, BoundedBTreeMap, BoundedVec, CanceledSlashPayout, + ClaimedRewards, CurrentEra, CurrentPlannedSession, EraRewardPoints, ErasRewardPoints, + ErasStakersClipped, ErasStartSessionIndex, ErasTotalStake, ErasValidatorPrefs, + ErasValidatorReward, ForceEra, Forcing, Nominations, Nominators, Perbill, + SlashRewardFraction, SlashingSpans, ValidatorPrefs, Validators, }; use sp_staking::{EraIndex, Exposure, IndividualExposure, Page, SessionIndex}; @@ -8573,10 +8573,13 @@ mod getters { sp_io::TestExternalities::default().execute_with(|| { // given let era: EraIndex = 12; - let reward_points = EraRewardPoints:: { - total: 1, - individual: vec![(11, 1)].into_iter().collect(), - }; + let mut reward_map = BoundedBTreeMap::new(); + assert_ok!(reward_map.try_insert(11, 1)); + let reward_points = + EraRewardPoints::::MaxActiveValidators> { + total: 1, + individual: reward_map, + }; ErasRewardPoints::::insert(era, reward_points); // when