Skip to content

Commit

Permalink
small fixes - BoundedBTreeMap
Browse files Browse the repository at this point in the history
  • Loading branch information
re-gius committed Nov 15, 2024
1 parent eb93a70 commit 58cf45d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion substrate/frame/staking/src/slashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ fn add_offending_validator<T: Config>(params: &SlashParams<T>) {
// 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);
}
}
Expand Down
21 changes: 12 additions & 9 deletions substrate/frame/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -8573,10 +8573,13 @@ mod getters {
sp_io::TestExternalities::default().execute_with(|| {
// given
let era: EraIndex = 12;
let reward_points = EraRewardPoints::<mock::AccountId> {
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::<mock::AccountId, <Test as crate::Config>::MaxActiveValidators> {
total: 1,
individual: reward_map,
};
ErasRewardPoints::<Test>::insert(era, reward_points);

// when
Expand Down

0 comments on commit 58cf45d

Please sign in to comment.