-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Dynamic Protocol State] Extend tests for EpochStateMachine
#5681
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clean and well-documented test. Added a few minor suggestions for improving the tests specificity and documentation.
s.epochStateDB.On("StoreTx", mocks.Anything, mocks.Anything).Run(func(args mocks.Arguments) { | ||
updatedState := args[1].(*flow.ProtocolStateEntry) | ||
require.Equal(s.T(), flow.EpochPhaseStaking, updatedState.EpochPhase()) | ||
}).Return(storeTxDeferredUpdate.Execute, nil).Once() | ||
|
||
s.mutator.On("SetEpochStateID", mocks.Anything).Return().Once() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that only looking the epoch phase is a relatively coarse check, that could succeed in a variety of ways despite the Epoch State machine doing something wrong. I may be overlooking something, but I feel it should be relatively straight forward to verify that we produce the expected epoch state here:
expectedEpochState := &flow.ProtocolStateEntry{
PreviousEpoch: s.parentEpochState.CurrentEpoch.Copy(),
CurrentEpoch: *s.parentEpochState.NextEpoch.Copy(),
NextEpoch: nil,
InvalidEpochTransitionAttempted: true,
}
and with that, we should be able to do
s.epochStateDB.On("StoreTx", mocks.Anything, mocks.Anything).Run(func(args mocks.Arguments) { | |
updatedState := args[1].(*flow.ProtocolStateEntry) | |
require.Equal(s.T(), flow.EpochPhaseStaking, updatedState.EpochPhase()) | |
}).Return(storeTxDeferredUpdate.Execute, nil).Once() | |
s.mutator.On("SetEpochStateID", mocks.Anything).Return().Once() | |
s.epochStateDB.On("StoreTx", expectedEpochState.ID(), expectedEpochState).Return(storeTxDeferredUpdate.Execute, nil).Once() | |
s.mutator.On("SetEpochStateID", expectedEpochState.ID()).Return().Once() |
Hope that makes sense. 😅
Co-authored-by: Alexander Hentschel <alex.hentschel@flowfoundation.org>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5681 +/- ##
==========================================
- Coverage 55.52% 55.51% -0.02%
==========================================
Files 1132 1132
Lines 89474 89474
==========================================
- Hits 49680 49668 -12
- Misses 35018 35033 +15
+ Partials 4776 4773 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Context
Added a test which verifies that epoch transition indeed happens in edge cases described in #5631.