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

style: address forced type assertions in tests #5116

Merged
merged 11 commits into from
May 10, 2023
Merged

Conversation

faddat
Copy link
Member

@faddat faddat commented May 7, 2023

Brief Changelog

This PR addresses forced type assertions in the Osmosis test suite.

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

@github-actions github-actions bot added C:app-wiring Changes to the app folder C:CLI C:x/concentrated-liquidity C:x/gamm Changes, features and bugs related to the gamm module. C:x/incentives C:x/mint C:x/poolmanager C:x/twap Changes to the twap module labels May 7, 2023
@faddat faddat changed the title faddat/forcetypeassert style: address forced type assertions in tests May 7, 2023
@faddat faddat added no-changelog V:state/compatible/no_backport State machine compatible PR, depends on prior breaks labels May 7, 2023
Copy link
Member

@pysel pysel left a comment

Choose a reason for hiding this comment

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

Thanks! Left a few comments:

tests/e2e/e2e_test.go Outdated Show resolved Hide resolved
x/concentrated-liquidity/pool_test.go Outdated Show resolved Hide resolved
x/gamm/keeper/swap_test.go Outdated Show resolved Hide resolved
x/incentives/keeper/suite_test.go Show resolved Hide resolved
faddat and others added 3 commits May 8, 2023 10:51
Co-authored-by: Ruslan Akhtariev <46343690+pysel@users.noreply.github.com>
Co-authored-by: Ruslan Akhtariev <46343690+pysel@users.noreply.github.com>
@faddat
Copy link
Member Author

faddat commented May 8, 2023

Thanks for the review @pysel :)

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.

LGTM, nice work. Only nits

x/concentrated-liquidity/pool_test.go Outdated Show resolved Hide resolved
x/concentrated-liquidity/pool_test.go Outdated Show resolved Hide resolved
x/gamm/keeper/swap_test.go Outdated Show resolved Hide resolved
faddat and others added 3 commits May 9, 2023 16:05
Co-authored-by: Roman <roman@osmosis.team>
Co-authored-by: Roman <roman@osmosis.team>
Co-authored-by: Roman <roman@osmosis.team>
@@ -1056,12 +1056,34 @@ func (s *IntegrationTestSuite) TestIBCWasmHooks() {
var response map[string]interface{}
s.Require().Eventually(func() bool {
response, err = nodeA.QueryWasmSmartObject(contractAddr, fmt.Sprintf(`{"get_total_funds": {"addr": "%s"}}`, senderBech32))
totalFunds := response["total_funds"].([]interface{})[0]
amount := totalFunds.(map[string]interface{})["amount"].(string)
denom := totalFunds.(map[string]interface{})["denom"].(string)
Copy link
Contributor

Choose a reason for hiding this comment

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

I find the old versions much more readable here (since it's just a test). I'm not strongly against the type assertion checks and get the point in chain code, but in tests I tend to favor making the test shorted since robustness doesn't matter.

For json in particular, we may want to use https://github.com/tidwall/gjson

Copy link
Contributor

@nicolaslara nicolaslara left a comment

Choose a reason for hiding this comment

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

looks good to me. I have a stylistic preference that I left a comment for, but happy either way.

@faddat
Copy link
Member Author

faddat commented May 9, 2023

@nicolaslara is it okay if I try to get your style preference into the final PR for #5061 ?

makes sense to me actually

@nicolaslara
Copy link
Contributor

sounds good! :)

@czarcas7ic czarcas7ic merged commit efc1ae6 into main May 10, 2023
@czarcas7ic czarcas7ic deleted the faddat/forcetypeassert branch May 10, 2023 15:51
pysel added a commit that referenced this pull request Jun 6, 2023
* fix forced type assertions

* revert change to linter config

* Update tests/e2e/e2e_test.go

Co-authored-by: Ruslan Akhtariev <46343690+pysel@users.noreply.github.com>

* Update x/concentrated-liquidity/pool_test.go

Co-authored-by: Ruslan Akhtariev <46343690+pysel@users.noreply.github.com>

* skip pool = poolI

* update swap_test.go to test that cl type assertions fail

* trial

* we needed pool because it's used to CalcInGivenOut

* Update x/concentrated-liquidity/pool_test.go

Co-authored-by: Roman <roman@osmosis.team>

* Update x/concentrated-liquidity/pool_test.go

Co-authored-by: Roman <roman@osmosis.team>

* Update x/gamm/keeper/swap_test.go

Co-authored-by: Roman <roman@osmosis.team>

---------

Co-authored-by: Ruslan Akhtariev <46343690+pysel@users.noreply.github.com>
Co-authored-by: Roman <roman@osmosis.team>
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:CLI C:x/concentrated-liquidity C:x/gamm Changes, features and bugs related to the gamm module. C:x/incentives C:x/mint C:x/poolmanager C:x/twap Changes to the twap module V:state/compatible/no_backport State machine compatible PR, depends on prior breaks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants