mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 00:47:55 +00:00
Used CountedStorageMap in pallet-staking (#10233)
* Removed counters and used CountedStorageMap instead. * Little refactoring * Update frame/staking/src/migrations.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Removed redundant code to update counter for validator & nominator. * Removed redundant code to update counter for validator & nominator. * Removed unreachable code to inject the hashed prefix for nominator & validator. * Removed redundant check for nominator & validator count. * Generated `fn prefix_hash` for `CountedStorageMap`. * Applied changes from `cargo fmt` * Possible correct implementation of migration code * Implemented fn module_prefix, storage_prefix and prefix_hash. * Removed counted_map.rs * Renamed `fn storage_prefix` to `storage_counter_prefix`. * Update frame/support/src/storage/types/counted_map.rs * Update frame/bags-list/remote-tests/src/snapshot.rs * Update frame/support/src/storage/types/counted_map.rs * Fixed errors. Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -4300,8 +4300,8 @@ fn chill_other_works() {
|
||||
.min_nominator_bond(1_000)
|
||||
.min_validator_bond(1_500)
|
||||
.build_and_execute(|| {
|
||||
let initial_validators = CounterForValidators::<Test>::get();
|
||||
let initial_nominators = CounterForNominators::<Test>::get();
|
||||
let initial_validators = Validators::<Test>::count();
|
||||
let initial_nominators = Nominators::<Test>::count();
|
||||
for i in 0..15 {
|
||||
let a = 4 * i;
|
||||
let b = 4 * i + 1;
|
||||
@@ -4424,8 +4424,8 @@ fn chill_other_works() {
|
||||
));
|
||||
|
||||
// 16 people total because tests start with 2 active one
|
||||
assert_eq!(CounterForNominators::<Test>::get(), 15 + initial_nominators);
|
||||
assert_eq!(CounterForValidators::<Test>::get(), 15 + initial_validators);
|
||||
assert_eq!(Nominators::<Test>::count(), 15 + initial_nominators);
|
||||
assert_eq!(Validators::<Test>::count(), 15 + initial_validators);
|
||||
|
||||
// Users can now be chilled down to 7 people, so we try to remove 9 of them (starting
|
||||
// with 16)
|
||||
@@ -4437,13 +4437,13 @@ fn chill_other_works() {
|
||||
}
|
||||
|
||||
// chill a nominator. Limit is not reached, not chill-able
|
||||
assert_eq!(CounterForNominators::<Test>::get(), 7);
|
||||
assert_eq!(Nominators::<Test>::count(), 7);
|
||||
assert_noop!(
|
||||
Staking::chill_other(Origin::signed(1337), 1),
|
||||
Error::<Test>::CannotChillOther
|
||||
);
|
||||
// chill a validator. Limit is reached, chill-able.
|
||||
assert_eq!(CounterForValidators::<Test>::get(), 9);
|
||||
assert_eq!(Validators::<Test>::count(), 9);
|
||||
assert_ok!(Staking::chill_other(Origin::signed(1337), 3));
|
||||
})
|
||||
}
|
||||
@@ -4451,9 +4451,9 @@ fn chill_other_works() {
|
||||
#[test]
|
||||
fn capped_stakers_works() {
|
||||
ExtBuilder::default().build_and_execute(|| {
|
||||
let validator_count = CounterForValidators::<Test>::get();
|
||||
let validator_count = Validators::<Test>::count();
|
||||
assert_eq!(validator_count, 3);
|
||||
let nominator_count = CounterForNominators::<Test>::get();
|
||||
let nominator_count = Nominators::<Test>::count();
|
||||
assert_eq!(nominator_count, 1);
|
||||
|
||||
// Change the maximums
|
||||
|
||||
Reference in New Issue
Block a user