Improved election pallet testing#12327
Improved election pallet testing#12327paritytech-processbot[bot] merged 22 commits intoparitytech:masterfrom
Conversation
|
@kianenigma PTAL. |
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
kianenigma
left a comment
There was a problem hiding this comment.
Looks mostly good, some small changes needed.
kianenigma
left a comment
There was a problem hiding this comment.
Would like to see events in other tests as well, namely at least one that finished with compute: Signed (signed.rs)
| assert_eq!(MultiPhase::round(), 1); | ||
|
|
||
| roll_to(25); | ||
| roll_to_unsigned(); |
There was a problem hiding this comment.
Referring to line 1877.
I think if we are using this pattern then we should not use the exact block numbers explicitly in the code anymore.
What I mean is, the test should read something like this
roll_to_signed();
some_assertions();
roll_by(9); // instead of roll_to(24), go forward by 9 blocks
assertions_phase_still_signed();
roll_to_unsigned();
some_assertions();
My reasoning for this is, if we still have to keep track of block numbers, it defeats the purpose of using the pattern roll_to_event()
Since we are actively moving forward till a certain phase is reached, we probably don't need this assertions at block 24 anyway. If there is a logical assertion needed here, may be it could be done a bit differently. For example, block_unsigned_phase - block_signed_phase == 10
There was a problem hiding this comment.
The goal is to have as much "separation of concerns" as possible. There is one tests somewhere in there that checks roll_to(x) manually (called phase_rotation_works). All other tests should spend the minimum amount of mental effort to deal with phase related stuff, so I would stick to roll_to_signed and roll_to_unsigned for the sake of simplicity.
There was a problem hiding this comment.
I am agreeing with the pattern. I agree we can keep manual roll over for this test. There are still few more roll_to() checks that I think we can get rid of.
|
/tip medium |
|
@kianenigma A medium tip was successfully submitted for Szegoo (126X27SbhrV19mBFawys3ovkyBS87SGfYwtwa8J2FjHrtbmA on polkadot). https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.polkadot.io#/treasury/tips |
|
bot rebase |
|
Rebased |
|
bot merge |
* master: (42 commits) Adapt `pallet-contracts` to WeightV2 (#12421) Improved election pallet testing (#12327) Bump prost to 0.11+ (#12419) Use saturating add for alliance::disband witness data (#12418) [Fix] Rename VoterBagsList -> VoterList to match pdot (#12416) client/beefy: small code improvements (#12414) BEEFY: Simplify hashing for pallet-beefy-mmr (#12393) Add @koute to `docs/CODEOWNERS` and update stale paths (#12408) docs/CODEOWNERS: add @acatangiu as MMR owner (#12406) Remove unnecessary Clone trait bounds on CountedStorageMap (#12402) Fix `Weight::is_zero` (#12396) Beefy on-demand justifications as a custom RequestResponse protocol (#12124) Remove contracts RPCs (#12358) pallet-mmr: generate historical proofs (#12324) unsafe_pruning flag removed (#12385) Carry over where clauses defined in Config to Call and Hook (#12388) Properly set the max proof size weight on defaults and tests (#12383) BEEFY: impl TypeInfo for SignedCommitment (#12382) bounding staking: `BoundedElectionProvider` trait (#12362) New Pallet: Root offences (#11943) ...
* Improved election pallet testing * fmt * remove comment * more checks * fixes in logic * roll_to_signed * switch to roll_to_signed * Update frame/election-provider-multi-phase/src/mock.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * remove useless checks * remove warning * add checks to signed.rs * add some checks to unsigned.rs * fmt * use roll_to_signed and roll_to_unsigned * remove nonsense * remove even more nonsense * fix * fix * remove useless checks Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: parity-processbot <>

Closes: #12184
roll_to(25)withroll_to_unsignedroll_to(15)withroll_to_signedNOTE: I did go through the event assertions to see if the emitted events are correct and it seems like they are to me.
Polkadot address: 126X27SbhrV19mBFawys3ovkyBS87SGfYwtwa8J2FjHrtbmA