Skip to content

Commit

Permalink
chore: adding call to underlying app to OnChanCloseConfirm (#2248) (#…
Browse files Browse the repository at this point in the history
…2256)

(cherry picked from commit fcdb0fc)

Co-authored-by: Cian Hatton <cian@interchain.io>
  • Loading branch information
mergify[bot] and chatton committed Sep 11, 2022
1 parent 9e9f267 commit c77f1b0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
12 changes: 10 additions & 2 deletions modules/apps/27-interchain-accounts/controller/ibc_middleware.go
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
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

0 comments on commit c77f1b0

Please sign in to comment.