Skip to content

Commit

Permalink
Fix WeakBoundedVec and MaxValidatorsCount
Browse files Browse the repository at this point in the history
  • Loading branch information
re-gius committed Dec 3, 2024
1 parent 40ccdec commit c3365a6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
1 change: 0 additions & 1 deletion substrate/frame/beefy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

use codec::{Decode, Encode};
use scale_info::TypeInfo;
use std::vec;

use frame_election_provider_support::{
bounds::{ElectionBounds, ElectionBoundsBuilder},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
));
});

Expand Down
4 changes: 3 additions & 1 deletion substrate/frame/root-offences/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Test>;
Expand Down
20 changes: 13 additions & 7 deletions substrate/frame/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2329,7 +2329,8 @@ fn reward_validator_slashing_validator_does_not_overflow() {
let exposure = Exposure::<AccountId, Balance> { total: stake, own: stake, others: vec![] };
let mut reward_map = BoundedBTreeMap::new();
assert_ok!(reward_map.try_insert(11, 1));
let reward = EraRewardPoints::<AccountId, MaxWinners> { total: 1, individual: reward_map };
let reward =
EraRewardPoints::<AccountId, MaxValidatorsCount> { total: 1, individual: reward_map };

// Check reward
ErasRewardPoints::<Test>::insert(0, reward);
Expand Down Expand Up @@ -6608,7 +6609,7 @@ fn should_retain_era_info_only_upto_history_depth() {
for page in 0..3 {
ErasStakersPaged::<Test>::insert(
(era, &validator_stash, page),
ExposurePage { page_total: 100, others: BoundedVec::new() },
ExposurePage { page_total: 100, others: WeakBoundedVec::new() },
);
}
}
Expand Down Expand Up @@ -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::<AccountId, MaxWinners> { total: 1, individual: reward_map };
let reward =
EraRewardPoints::<AccountId, MaxValidatorsCount> { total: 1, individual: reward_map };
ErasRewardPoints::<Test>::insert(0, reward);

// build exposure
Expand Down Expand Up @@ -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,
Expand All @@ -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() {
Expand Down Expand Up @@ -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::<mock::AccountId, MaxWinners> { total: 1, individual: reward_map };
let reward_points = EraRewardPoints::<mock::AccountId, MaxValidatorsCount> {
total: 1,
individual: reward_map,
};
ErasRewardPoints::<Test>::insert(era, reward_points);

// when
Expand Down

0 comments on commit c3365a6

Please sign in to comment.