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

Adding call to underlying app to OnChanCloseConfirm #2248

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (im IBCMiddleware) OnChanOpenAck(
return nil
}

// OnChanOpenAck implements the IBCMiddleware interface
// OnChanOpenConfirm implements the IBCMiddleware interface
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not relevant but we had an incorrect docstring.

func (im IBCMiddleware) OnChanOpenConfirm(
ctx sdk.Context,
portID,
Expand All @@ -140,7 +140,15 @@ func (im IBCMiddleware) OnChanCloseConfirm(
portID,
channelID string,
) error {
return im.keeper.OnChanCloseConfirm(ctx, portID, channelID)
if err := im.keeper.OnChanCloseConfirm(ctx, portID, channelID); err != nil {
return err
}

if im.app != nil && im.keeper.IsMiddlewareEnabled(ctx, portID, channelID) {
return im.app.OnChanCloseConfirm(ctx, portID, channelID)
}

return nil
}

// OnRecvPacket implements the IBCMiddleware interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,10 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseInit() {
}

func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() {
var path *ibctesting.Path
var (
path *ibctesting.Path
isNilApp bool
)

testCases := []struct {
name string
Expand All @@ -484,11 +487,17 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() {
{
"success", func() {}, true,
},
{
"nil underlying app", func() {
isNilApp = true
}, true,
},
}

for _, tc := range testCases {
suite.Run(tc.name, func() {
suite.SetupTest() // reset
isNilApp = false

path = NewICAPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)
Expand All @@ -503,6 +512,10 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() {
cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module)
suite.Require().True(ok)

if isNilApp {
cbs = controller.NewIBCMiddleware(nil, suite.chainA.GetSimApp().ICAControllerKeeper)
}

err = cbs.OnChanCloseConfirm(
suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)

Expand Down