Skip to content

Commit

Permalink
Remove Staked storage item on rust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
librelois committed Mar 1, 2024
1 parent 43e87c3 commit ef7fdda
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
4 changes: 1 addition & 3 deletions pallets/parachain-staking/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use crate::{
AwardedPts, BalanceOf, BottomDelegations, Call, CandidateBondLessRequest, Config,
DelegationAction, EnableMarkingOffline, Pallet, ParachainBondConfig, ParachainBondInfo, Points,
Range, RewardPayment, Round, ScheduledRequest, Staked, TopDelegations,
Range, RewardPayment, Round, ScheduledRequest, TopDelegations,
};
use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite};
use frame_support::traits::{Currency, Get, OnFinalize, OnInitialize};
Expand Down Expand Up @@ -1552,11 +1552,9 @@ benchmarks! {
let payout_round = round.current - reward_delay;
// may need:
// <Points<T>>
// <Staked<T>>
// <ParachainBondInfo<T>>
// ensure parachain bond account exists so that deposit_into_existing succeeds
<Points<T>>::insert(payout_round, 100);
<Staked<T>>::insert(payout_round, min_candidate_stk::<T>());

// set an account in the bond config so that we will measure the payout to it
let account = create_funded_user::<T>(
Expand Down
22 changes: 2 additions & 20 deletions pallets/parachain-staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6448,19 +6448,11 @@ fn deferred_payment_storage_items_are_cleaned_up() {
<Points<Test>>::contains_key(1),
"Points should be populated during current round"
);
assert!(
<Staked<Test>>::contains_key(1),
"Staked should be populated when round changes"
);

assert!(
!<Points<Test>>::contains_key(2),
"Points should not be populated until author noted"
);
assert!(
<Staked<Test>>::contains_key(2),
"Staked should be populated when round changes"
);

// first payout occurs in round 3
roll_to_round_begin(3);
Expand Down Expand Up @@ -6500,24 +6492,17 @@ fn deferred_payment_storage_items_are_cleaned_up() {
"DelayedPayouts should be populated after RewardPaymentDelay"
);
assert!(<Points<Test>>::contains_key(1));
assert!(
!<Staked<Test>>::contains_key(1),
"Staked should be cleaned up after round change"
);

assert!(!<DelayedPayouts<Test>>::contains_key(2));
assert!(
!<Points<Test>>::contains_key(2),
"We never rewarded points for round 2"
);
assert!(<Staked<Test>>::contains_key(2));

assert!(!<DelayedPayouts<Test>>::contains_key(3));
assert!(
!<Points<Test>>::contains_key(3),
"We never awarded points for round 3"
);
assert!(<Staked<Test>>::contains_key(3));

// collator 1 has been paid in this last block and associated storage cleaned up
assert!(!<AtStake<Test>>::contains_key(1, 1));
Expand Down Expand Up @@ -6557,7 +6542,6 @@ fn deferred_payment_storage_items_are_cleaned_up() {
// collators have both been paid and storage fully cleaned up for round 1
assert!(!<AtStake<Test>>::contains_key(1, 2));
assert!(!<AwardedPts<Test>>::contains_key(1, 2));
assert!(!<Staked<Test>>::contains_key(1));
assert!(!<Points<Test>>::contains_key(1)); // points should be cleaned up
assert!(!<DelayedPayouts<Test>>::contains_key(1));

Expand Down Expand Up @@ -6592,7 +6576,6 @@ fn deferred_payment_and_at_stake_storage_items_cleaned_up_for_candidates_not_pro
assert!(<AwardedPts<Test>>::contains_key(1, 1));
assert!(<AwardedPts<Test>>::contains_key(1, 2));
assert!(!<AwardedPts<Test>>::contains_key(1, 3));
assert!(<Staked<Test>>::contains_key(1));
assert!(<Points<Test>>::contains_key(1));
roll_to_round_begin(3);
assert!(<DelayedPayouts<Test>>::contains_key(1));
Expand All @@ -6605,7 +6588,6 @@ fn deferred_payment_and_at_stake_storage_items_cleaned_up_for_candidates_not_pro
assert!(!<AwardedPts<Test>>::contains_key(1, 1));
assert!(!<AwardedPts<Test>>::contains_key(1, 2));
assert!(!<AwardedPts<Test>>::contains_key(1, 3));
assert!(!<Staked<Test>>::contains_key(1));
assert!(!<Points<Test>>::contains_key(1));
assert!(!<DelayedPayouts<Test>>::contains_key(1));
});
Expand Down Expand Up @@ -8726,8 +8708,8 @@ fn test_on_initialize_weights() {
.ref_time();
// SlotProvider read
expected_weight += RocksDbWeight::get().reads_writes(1, 0).ref_time();
// Round and Staked writes, done in on-round-change code block inside on_initialize()
expected_weight += RocksDbWeight::get().reads_writes(0, 2).ref_time();
// Round write, done in on-round-change code block inside on_initialize()
expected_weight += RocksDbWeight::get().reads_writes(0, 1).ref_time();
// more reads/writes manually accounted for for on_finalize
expected_weight += RocksDbWeight::get().reads_writes(3, 2).ref_time();

Expand Down

0 comments on commit ef7fdda

Please sign in to comment.