-
Notifications
You must be signed in to change notification settings - Fork 607
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
Fix epochs modules tests #1893
Fix epochs modules tests #1893
Conversation
// This test ensures legacy EpochInfo messages will not throw errors via InitGenesis and BeginBlocker | ||
func TestLegacyEpochSerialization(t *testing.T) { |
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.
This is deadcode / for an obsoleted concern. (it was for the v4 upgrade, when we added some more fields to this struct, and deleted a dead one)
heights := maps.Keys(test.blockHeightTimePairs) | ||
osmoutils.SortSlice(heights) | ||
for _, h := range heights { |
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.
This go 1.18 deterministic iteration over maps API 😍
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.
love it
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.
🧀
heights := maps.Keys(test.blockHeightTimePairs) | ||
osmoutils.SortSlice(heights) | ||
for _, h := range heights { |
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.
love it
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
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 like reviewing this has really improved my understanding of epochs implementation details. Great work on the refactor and tests!
expectedEpochInfo := epochInfo | ||
expectedEpochInfo.StartTime = suite.Ctx.BlockTime() | ||
expectedEpochInfo.CurrentEpochStartHeight = suite.Ctx.BlockHeight() | ||
suite.Require().Equal(expectedEpochInfo, epochInfoSaved) | ||
|
||
allEpochs := suite.App.EpochsKeeper.AllEpochInfos(suite.Ctx) |
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.
Does it make sense splitting up the AllEpochInfos
test into its own test fixture? It seems that we are testing 2 separate methods in one fixture
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.
Not really sure theres much to add as a general test here that'd be of value, versus us making this test have documentation for what exactly its doing. I guess we could provide a list of []types.EpochInfo
and then call AllEpochInfos on it
All comments resolved I believe! |
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.
🚀
block1Time := time.Unix(1656907200, 0).UTC() | ||
const defaultIdentifier = "hourly" | ||
const defaultDuration = time.Hour | ||
const eps = time.Nanosecond |
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.
Consider adding a comment with the explanation from our earlier discussion please:
#1893 (comment)
* Fix epochs modules tests * Remove debug code * Fix altered API usage within superfluid * Add changelog entry * Add more AddEpochInfo checks * Fix superfluid tests * Update osmoutils/slice_helper.go Co-authored-by: Aleksandr Bezobchuk <[email protected]> * Changelog nit * Apply Roman's suggestions! Co-authored-by: Roman <[email protected]> * add const * Apply roman's suggestion of tests w/ non-default values * Apply roman's comment update suggestions * AddEpochInfo comment * fix gomod order Co-authored-by: Aleksandr Bezobchuk <[email protected]> Co-authored-by: Roman <[email protected]> (cherry picked from commit 21f7f98) # Conflicts: # CHANGELOG.md # go.mod # x/epochs/abci_test.go # x/epochs/keeper/epoch.go # x/epochs/keeper/genesis.go # x/superfluid/keeper/keeper.go # x/superfluid/keeper/twap_price_test.go
* Fix epochs modules tests (#1893) * Fix epochs modules tests * Remove debug code * Fix altered API usage within superfluid * Add changelog entry * Add more AddEpochInfo checks * Fix superfluid tests * Update osmoutils/slice_helper.go Co-authored-by: Aleksandr Bezobchuk <[email protected]> * Changelog nit * Apply Roman's suggestions! Co-authored-by: Roman <[email protected]> * add const * Apply roman's suggestion of tests w/ non-default values * Apply roman's comment update suggestions * AddEpochInfo comment * fix gomod order
Part of: #1834
What is the purpose of the change
Update the epochs modules tests to be readable, make sense & cover more relevant cases.
As part of this, we remove the prior
SetEpochInfo
API, and solely use a saferAddEpochInfo
api, that includes relevant entries if they're left blank, and errors if its an invalid configurationBrief Changelog
Testing and Verifying
This change added tests and can be verified as follows:
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? yes