This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Clean Staking <-> Session tests and Use a Realistic Scenario #5244
Copy link
Copy link
Closed
Labels
I5-testsTests need fixing, improving or augmenting.Tests need fixing, improving or augmenting.Z1-easyCan be fixed primarily by duplicating and adapting code by an intermediate coderCan be fixed primarily by duplicating and adapting code by an intermediate coder
Description
Currently, almost all staking tests use this function
substrate/frame/staking/src/mock.rs
Lines 671 to 679 in 918e58e
| pub fn start_session(session_index: SessionIndex) { | |
| assert_eq!(<Period as Get<BlockNumber>>::get(), 1, "start_session can only be used with session length 1."); | |
| for i in Session::current_index()..session_index { | |
| Staking::on_finalize(System::block_number()); | |
| System::set_block_number((i + 1).into()); | |
| Timestamp::set_timestamp(System::block_number() * 1000); | |
| Session::on_initialize(System::block_number()); | |
| Staking::on_initialize(System::block_number()); | |
| } |
To which I have added the assertion that demonstrates the issues; Up until this commit, staking's mock didn't even have a configuration to set the session length and it was always 1. The assert should prevent us from creating a bug here, but ideally the assumption should be removed and tests that use it should be revised. There should be tests that check staking's session rotation with session/era lengths of N and M, where both of them are greater than 1.
Metadata
Metadata
Assignees
Labels
I5-testsTests need fixing, improving or augmenting.Tests need fixing, improving or augmenting.Z1-easyCan be fixed primarily by duplicating and adapting code by an intermediate coderCan be fixed primarily by duplicating and adapting code by an intermediate coder
Type
Projects
Status
✅ Done