Skip to content

Commit

Permalink
test: adding cases for incorrect outgoing data & channel does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
seantking committed Sep 10, 2021
1 parent 477b9ba commit 33536b7
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions modules/apps/27-interchain-accounts/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
{
Expand All @@ -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")
Expand All @@ -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,
},
}
Expand All @@ -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)

Expand Down

0 comments on commit 33536b7

Please sign in to comment.