Skip to content
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

misc test improvements #612

Merged
merged 1 commit into from
Nov 24, 2021
Merged

misc test improvements #612

merged 1 commit into from
Nov 24, 2021

Conversation

ValarDragon
Copy link
Member

This PR contains the following misc test improvements:

  • x/gamm: Deduplicate the FundAccounts coins constant
  • x/gamm: Fix staticcheck being angry about unnecessary fmt.Sprintf's
  • x/lockup: Fix noise from FundAccount in gas_test
  • osmotestutils: Add GetFeeString function
  • Replace complex fee cli line with simple osmotestutils call

Description

This osmotestutils should accrue more improvements to testing here. The latency of trying to get improvements into the SDK, then back onto our own repo is far too high.


For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

* x/gamm: Deduplicate the FundAccounts coins constant
* x/lockup: Fix noise from FundAccount in gas_test
* osmotestutils: Add GetFeeString function
* Replace complex fee cli line with simple osmotestutils call
@codecov-commenter
Copy link

Codecov Report

Merging #612 (73d769b) into main (dedcfb8) will not change coverage.
The diff coverage is 33.33%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #612   +/-   ##
=======================================
  Coverage   18.43%   18.43%           
=======================================
  Files         172      172           
  Lines       24203    24203           
=======================================
  Hits         4462     4462           
  Misses      18977    18977           
  Partials      764      764           
Impacted Files Coverage Δ
x/gamm/keeper/invariants.go 14.92% <33.33%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dedcfb8...73d769b. Read the comment docs.

@mattverse mattverse self-requested a review November 22, 2021 08:09
@@ -78,7 +79,7 @@ func (s *IntegrationTestSuite) TestNewCreatePoolCmd() {
newAddr,
sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 200000000), sdk.NewInt64Coin("node0token", 20000)), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
Copy link
Member

@mattverse mattverse Nov 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also want to move broadcast mode flag to osmotestutils and replace them with osmotestutils call
?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats a good idea, though I wonder if theres a better way we can just get more of these common flags to all be handled, to better mitigate the boilerplate. (E.g. Just appending all the common flags to the args array)

We should probs open an issue for tracking how to improve this

Copy link
Member

@mattverse mattverse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks LGTM!

Comment on lines +17 to 26
// fundAccount outside of gas measurement
err := simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr, coins)
suite.Require().NoError(err)
// start measuring gas
alreadySpent := suite.ctx.GasMeter().GasConsumed()
suite.LockTokens(addr, coins, dur)
_, err = suite.app.LockupKeeper.LockTokens(suite.ctx, addr, coins, dur)
suite.Require().NoError(err)
newSpent := suite.ctx.GasMeter().GasConsumed()
spentNow := newSpent - alreadySpent
return spentNow
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on this!
One further thing we can do in the future is set a range and simply test if the avgGas and maxGas is within the range, or something similar to remove hard coding gas, considering that there could be further instances where we would have to manually change the hard-coded gas whenever there is a logic change within the method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrmm, thats a good idea. (Basically lower the sensitivity to small noise that we care about)

Depends on our general attitude towards gas, where does tracking small changes matter. I tend to agree with you, at this stage, having small aberrations is totally fine, as long as we can bound the max, and that max and average don't get too far apart.

@ValarDragon ValarDragon merged commit 17f3de3 into main Nov 24, 2021
@ValarDragon ValarDragon deleted the dev/misc_test_improvements branch November 24, 2021 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants