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

refactor: always set ics27 ports regardless of whether the capability exists #4640

Merged
merged 12 commits into from
Sep 14, 2023

Conversation

colin-axner
Copy link
Contributor

Description

Need to update genesis unit tests

closes: #4626

Commit Message / Changelog Entry

type: commit message

see the guidelines for commit messages. (view raw markdown for examples)


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md).
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

… exists

Add e2e to test integration points.
Refactor persisted port state to be separate from port binding/creation
Copy link
Contributor Author

Choose a reason for hiding this comment

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

copy/pasted from ics27 tests

@@ -62,7 +62,8 @@ func (k Keeper) registerInterchainAccount(ctx sdk.Context, connectionID, portID,
case k.portKeeper.IsBound(ctx, portID) && !k.hasCapability(ctx, portID):
return "", errorsmod.Wrapf(icatypes.ErrPortAlreadyBound, "another module has claimed capability for and bound port with portID: %s", portID)
case !k.portKeeper.IsBound(ctx, portID):
capability := k.BindPort(ctx, portID)
k.setPort(ctx, portID)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ideally gets removed #4638 in the future

@@ -123,19 +122,20 @@ func NewAppModule(controllerKeeper *controllerkeeper.Keeper, hostKeeper *hostkee
// called once and as an alternative to InitGenesis.
func (am AppModule) InitModule(ctx sdk.Context, controllerParams controllertypes.Params, hostParams hosttypes.Params) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

Awesome, thank you @colin-axner! ❤️

Hopefully we can address these issues sooner rather than later :)

Comment on lines 86 to 94
for _, port := range ports {
store := suite.chainA.GetContext().KVStore(suite.chainA.GetSimApp().GetKey(icacontrollertypes.StoreKey))
suite.Require().True(store.Has(icatypes.KeyPort(port)))

capability, found := suite.chainA.GetSimApp().ScopedICAControllerKeeper.GetCapability(suite.chainA.GetContext(), host.PortPath(port))
suite.Require().True(found)
suite.Require().NotNil(capability)
}
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the main thing added

icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
)

func (suite *KeeperTestSuite) TestInitGenesis() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's really hard to test both setups of capabilities already being initialized or not being initialized as the testing pkg will call init genesis first and the portID is hard coded. I personally think this sort of integration testing is better handled by the e2e's which is why I added coverage there

@@ -5,11 +5,29 @@ import (
"github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
genesistypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/genesis/types"
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
)

func (suite *KeeperTestSuite) TestInitGenesis() {
Copy link
Member

Choose a reason for hiding this comment

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

Table tests ++ 💪

@codecov-commenter
Copy link

codecov-commenter commented Sep 13, 2023

Codecov Report

Merging #4640 (f981eb7) into main (e49f741) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4640      +/-   ##
==========================================
+ Coverage   79.53%   79.56%   +0.03%     
==========================================
  Files         188      188              
  Lines       13191    13201      +10     
==========================================
+ Hits        10492    10504      +12     
+ Misses       2267     2266       -1     
+ Partials      432      431       -1     
Files Changed Coverage Δ
...7-interchain-accounts/controller/keeper/account.go 81.25% <100.00%> (+0.39%) ⬆️
...7-interchain-accounts/controller/keeper/genesis.go 93.54% <100.00%> (+1.54%) ⬆️
...27-interchain-accounts/controller/keeper/keeper.go 90.62% <100.00%> (-0.12%) ⬇️
...apps/27-interchain-accounts/host/keeper/genesis.go 92.59% <100.00%> (+2.11%) ⬆️
.../apps/27-interchain-accounts/host/keeper/keeper.go 85.38% <100.00%> (-0.23%) ⬇️
modules/apps/27-interchain-accounts/module.go 49.00% <100.00%> (+2.53%) ⬆️

@@ -180,17 +180,6 @@ func (s *GenesisTestSuite) TestIBCGenesis() {

s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB))
})

t.Run("verify tokens transferred", func(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should be added with #3476

@colin-axner colin-axner added the v8 label Sep 13, 2023
Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

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

Thanks for creating those clean-up issues, LGTM 👍

@colin-axner colin-axner merged commit 715536c into main Sep 14, 2023
55 checks passed
@colin-axner colin-axner deleted the colin/4626-ica-initgenesis-fix branch September 14, 2023 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ica host: genesis import does not persist the bounded port id
4 participants