From 33536b7d4041f68b9be9d1c8632186c5717b48f8 Mon Sep 17 00:00:00 2001 From: Sean King Date: Fri, 10 Sep 2021 17:44:54 +0200 Subject: [PATCH] test: adding cases for incorrect outgoing data & channel does not exist --- .../keeper/relay_test.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/apps/27-interchain-accounts/keeper/relay_test.go b/modules/apps/27-interchain-accounts/keeper/relay_test.go index 31dad75f1fa..66c3b22d51a 100644 --- a/modules/apps/27-interchain-accounts/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/keeper/relay_test.go @@ -24,7 +24,6 @@ func (suite *KeeperTestSuite) TestTrySendTx() { amount, _ := sdk.ParseCoinsNormalized("100stake") interchainAccountAddr, _ := suite.chainB.GetSimApp().ICAKeeper.GetInterchainAccountAddress(suite.chainB.GetContext(), path.EndpointA.ChannelConfig.PortID) msg = &banktypes.MsgSend{FromAddress: interchainAccountAddr, ToAddress: suite.chainB.SenderAccount.GetAddress().String(), Amount: amount} - portID = path.EndpointA.ChannelConfig.PortID }, true, }, { @@ -34,9 +33,13 @@ func (suite *KeeperTestSuite) TestTrySendTx() { msg1 := &banktypes.MsgSend{FromAddress: interchainAccountAddr, ToAddress: suite.chainB.SenderAccount.GetAddress().String(), Amount: amount} msg2 := &banktypes.MsgSend{FromAddress: interchainAccountAddr, ToAddress: suite.chainB.SenderAccount.GetAddress().String(), Amount: amount} msg = []sdk.Msg{msg1, msg2} - portID = path.EndpointA.ChannelConfig.PortID }, true, }, + { + "incorrect outgoing data", func() { + msg = []byte{} + }, false, + }, { "active channel not found", func() { amount, _ := sdk.ParseCoinsNormalized("100stake") @@ -45,16 +48,22 @@ func (suite *KeeperTestSuite) TestTrySendTx() { portID = "incorrect portID" }, false, }, + { + "channel does not exist", func() { + amount, _ := sdk.ParseCoinsNormalized("100stake") + interchainAccountAddr, _ := suite.chainB.GetSimApp().ICAKeeper.GetInterchainAccountAddress(suite.chainB.GetContext(), path.EndpointA.ChannelConfig.PortID) + msg = &banktypes.MsgSend{FromAddress: interchainAccountAddr, ToAddress: suite.chainB.SenderAccount.GetAddress().String(), Amount: amount} + suite.chainA.GetSimApp().ICAKeeper.SetActiveChannel(suite.chainA.GetContext(), portID, "channel-100") + }, false, + }, { "data is nil", func() { msg = nil - portID = path.EndpointA.ChannelConfig.PortID }, false, }, { "data is not an SDK message", func() { msg = "not an sdk message" - portID = path.EndpointA.ChannelConfig.PortID }, false, }, } @@ -70,7 +79,7 @@ func (suite *KeeperTestSuite) TestTrySendTx() { err := suite.SetupICAPath(path, owner) suite.Require().NoError(err) - + portID = path.EndpointA.ChannelConfig.PortID tc.malleate() _, err = suite.chainA.GetSimApp().ICAKeeper.TrySendTx(suite.chainA.GetContext(), portID, msg)