From 73af7043b93a1440030c9a67786a572a0df1d162 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Fri, 9 Sep 2022 09:40:20 +0100 Subject: [PATCH] chore: adding call to underlying app to OnChanCloseConfirm --- .../controller/ibc_middleware.go | 12 ++++++++++-- .../controller/ibc_middleware_test.go | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware.go index 5be4baf5aee..b9091502d64 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware.go @@ -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, @@ -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 diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index 44fd201b0ef..ec0d6bf4110 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -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 @@ -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) @@ -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)