-
Notifications
You must be signed in to change notification settings - Fork 608
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
Write test for AddEpochInfo #1895
Conversation
// | ||
// TODO: Make a new test for init genesis logic |
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.
InitGenesis basically just shells out to AddEpochInfo. Error on duplicate is tested in its TestEpochsInitGenesis already!
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.
LGTM overall, just some nits and a question about more tests for table-driven setup
x/epochs/keeper/epoch_test.go
Outdated
expErr bool | ||
expEpochInfo types.EpochInfo | ||
}{ | ||
"simple_add": {addedEpochInfo: types.EpochInfo{ |
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 think formatting might be off here. Should this be on the next line?
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.
yeah whole tests fields' formatting would be better fixed before merging!
@@ -6,6 +6,60 @@ import ( | |||
"github.com/osmosis-labs/osmosis/v7/x/epochs/types" | |||
) | |||
|
|||
func (suite *KeeperTestSuite) TestAddEpochInfo() { | |||
defaultIdentifier := "default_add_epoch_info_id" |
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.
These might better be consts since these never change
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.
eh, I'm not sure I really buy into the notion that const vs not const matters for variables at the top of a test. If it was file-wide, I'd totally agree
suite.Require().Equal(test.expEpochInfo, actualEpochInfo) | ||
} else { | ||
suite.Require().Error(err) | ||
} |
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.
Are you planning to add more tests? I don't see one with an error expected
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.
imo, I think the only notable errror for AddEpochInfo
is the case for returning an error when there's a duplicate epoch identifier, which is tested in the test below
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 think a check before merging on the testing format would help, but other than that LGTM!
x/epochs/keeper/epoch_test.go
Outdated
expErr bool | ||
expEpochInfo types.EpochInfo | ||
}{ | ||
"simple_add": {addedEpochInfo: types.EpochInfo{ |
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.
yeah whole tests fields' formatting would be better fixed before merging!
suite.Require().Equal(test.expEpochInfo, actualEpochInfo) | ||
} else { | ||
suite.Require().Error(err) | ||
} |
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.
imo, I think the only notable errror for AddEpochInfo
is the case for returning an error when there's a duplicate epoch identifier, which is tested in the test below
Co-authored-by: Roman <[email protected]>
…osis into dev/add_epoch_info_test
Fixed formatting, added a zero duration test |
Closes: #1834
What is the purpose of the change
Adds a table driven test for AddEpochInfo functionality, and a unit test for its behavior on duplicates.
This is part of followup from #1893
Testing and Verifying
This change added tests
Documentation and Release Note
Unreleased
section inCHANGELOG.md
?no