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

Generalize gamm Inverse relationship test , add Inverse relationship test for stableswap #1456

Merged
merged 12 commits into from
Jul 1, 2022

Conversation

mattverse
Copy link
Member

Closes: #1371

What is the purpose of the change

Upon adding invariant test for inverse relationship on CalculateAmountOutAndIn(https://github.com/osmosis-labs/osmosis/blob/main/x/gamm/pool-models/balancer/amm_test.go#L89-L216) the goal of this PR is to generalize the test case, and also add the same test for stableswap using the generalized test case.

*Add a description of the overall background and high level changes that this PR introduces *

(E.g.: This pull request improves documation of area A by adding ....

Testing and Verifying

No testings changed in balancer package, inverse relationship test added for stableswap

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? no
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? no
  • How is the feature or change documented? not applicable

@mattverse mattverse requested a review from a team May 9, 2022 15:20
@github-actions github-actions bot added the C:x/gamm Changes, features and bugs related to the gamm module. label May 9, 2022
@codecov-commenter
Copy link

codecov-commenter commented May 9, 2022

Codecov Report

Merging #1456 (8d65ee8) into main (f56fbe5) will decrease coverage by 0.51%.
The diff coverage is 16.26%.

@@            Coverage Diff             @@
##             main    #1456      +/-   ##
==========================================
- Coverage   19.82%   19.31%   -0.52%     
==========================================
  Files         202      229      +27     
  Lines       27685    31452    +3767     
==========================================
+ Hits         5489     6075     +586     
- Misses      21175    24269    +3094     
- Partials     1021     1108      +87     
Impacted Files Coverage Δ
x/epochs/client/cli/query.go 0.00% <ø> (ø)
x/gamm/client/cli/query.go 36.74% <0.00%> (-0.36%) ⬇️
x/gamm/pool-models/stableswap/msgs.go 0.00% <0.00%> (ø)
x/gamm/pool-models/stableswap/pool.go 0.00% <0.00%> (ø)
x/gamm/pool-models/stableswap/stableswap_pool.go 0.00% <0.00%> (ø)
.../gamm/pool-models/stableswap/stableswap_pool.pb.go 0.58% <0.00%> (-0.09%) ⬇️
x/gamm/types/pool.go 0.00% <ø> (ø)
x/incentives/client/cli/query.go 0.00% <ø> (ø)
x/incentives/keeper/distribute.go 61.00% <0.00%> (ø)
x/incentives/keeper/hooks.go 50.00% <0.00%> (ø)
... and 53 more

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 de69b2a...8d65ee8. Read the comment docs.

Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

Great work @xBalbinus @mattverse ! Left some comments, please take a look

x/gamm/pool-models/internal/test_helpers/test_helpers.go Outdated Show resolved Hide resolved
x/gamm/pool-models/stableswap/amm_test.go Show resolved Hide resolved
x/gamm/pool-models/stableswap/amm_test.go Show resolved Hide resolved
x/gamm/pool-models/stableswap/amm_test.go Show resolved Hide resolved
x/gamm/pool-models/stableswap/amm_test.go Outdated Show resolved Hide resolved
app/apptesting/test_suite.go Show resolved Hide resolved
x/gamm/pool-models/balancer/amm_test.go Show resolved Hide resolved
x/gamm/pool-models/stableswap/util_test.go Outdated Show resolved Hide resolved
@stackman27
Copy link
Contributor

Closes #1349?

@mattverse mattverse requested a review from p0mvn May 25, 2022 13:47
@mattverse
Copy link
Member Author

I didn't notice this PR was open for so long, just made the changes you've requested per last review can you review the updates? tysm!

x/gamm/pool-models/balancer/amm_test.go Outdated Show resolved Hide resolved
"github.com/osmosis-labs/osmosis/v7/x/gamm/types"
)

type CfmmCommonTestSuite struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a small godoc to what CFMM abbreviation is?

@mattverse mattverse requested a review from alexanderbez May 27, 2022 07:14
@ValarDragon ValarDragon self-requested a review June 2, 2022 15:43
@github-actions github-actions bot added the C:app-wiring Changes to the app folder label Jun 16, 2022
// CfmmCommonTestSuite is the common test suite struct of Constant Function Market Maker,
// that pool-models can inherit from.
type CfmmCommonTestSuite struct {
suite.Suite
Copy link
Member

Choose a reason for hiding this comment

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

Why aren't we just using apptesting here?

Copy link
Member

Choose a reason for hiding this comment

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

We could also delete the CreateTestContext if we used apptesting

Copy link
Member Author

@mattverse mattverse Jun 17, 2022

Choose a reason for hiding this comment

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

It's because we have import cycle problems when we do that since the apptesting package imports gamm module and the balancer module

@ValarDragon
Copy link
Member

uhh, could you take a stab at solving the merge conflict here @mattverse , then we can get it merged in?

@mattverse
Copy link
Member Author

np! Thanks for getting this reviewed! Merging once final CI checks have passed upon approval

@mattverse mattverse merged commit 2007bab into main Jul 1, 2022
@mattverse mattverse deleted the mattverse/inverse-testing branch July 1, 2022 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:app-wiring Changes to the app folder C:x/gamm Changes, features and bugs related to the gamm module.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[x/gamm][Testing] generalize TestCalculateAmountOutAndIn_InverseRelationship
7 participants