From 38ebbff9543c89fd42a330ff5ca4956fdc98656f Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 5 Aug 2021 17:09:39 +0200 Subject: [PATCH] test: adding test for OnChanOpenConfirm (#312) --- .../keeper/handshake_test.go | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/modules/apps/27-interchain-accounts/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/keeper/handshake_test.go index ef689f12f2c..4b8a6f005fb 100644 --- a/modules/apps/27-interchain-accounts/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/keeper/handshake_test.go @@ -230,3 +230,53 @@ func (suite *KeeperTestSuite) TestOnChanOpenAck() { }) } } + +// ChainA is controller, ChainB is host chain +func (suite *KeeperTestSuite) TestOnChanOpenConfirm() { + var ( + path *ibctesting.Path + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + + { + "success", func() {}, true, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() // reset + path = NewICAPath(suite.chainA, suite.chainB) + owner := "owner" + suite.coordinator.SetupConnections(path) + + err := InitInterchainAccount(path.EndpointA, owner) + suite.Require().NoError(err) + + err = path.EndpointB.ChanOpenTry() + suite.Require().NoError(err) + + err = path.EndpointA.ChanOpenAck() + suite.Require().NoError(err) + + tc.malleate() // explicitly change fields in channel and testChannel + + err = suite.chainB.GetSimApp().ICAKeeper.OnChanOpenConfirm(suite.chainA.GetContext(), + path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + + if tc.expPass { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } + + }) + } +}