Skip to content

Commit

Permalink
Add failure case for msg failing on ValidateBasic.
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitrisJim committed Jul 25, 2023
1 parent ac6300b commit 6d3c70f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions modules/apps/27-interchain-accounts/host/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,45 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() {
},
true,
},
{
"Msg fails its ValidateBasic: MsgTransfer has an empty receiver",
func(encoding string) {
transferPath := ibctesting.NewPath(suite.chainB, suite.chainC)
transferPath.EndpointA.ChannelConfig.PortID = ibctesting.TransferPort
transferPath.EndpointB.ChannelConfig.PortID = ibctesting.TransferPort
transferPath.EndpointA.ChannelConfig.Version = transfertypes.Version
transferPath.EndpointB.ChannelConfig.Version = transfertypes.Version

suite.coordinator.Setup(transferPath)

interchainAccountAddr, found := suite.chainB.GetSimApp().ICAHostKeeper.GetInterchainAccountAddress(suite.chainB.GetContext(), ibctesting.FirstConnectionID, path.EndpointA.ChannelConfig.PortID)
suite.Require().True(found)

msg := &transfertypes.MsgTransfer{
SourcePort: transferPath.EndpointA.ChannelConfig.PortID,
SourceChannel: transferPath.EndpointA.ChannelID,
Token: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)),
Sender: interchainAccountAddr,
Receiver: "",
TimeoutHeight: suite.chainB.GetTimeoutHeight(),
TimeoutTimestamp: uint64(0),
}

data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []proto.Message{msg}, encoding)
suite.Require().NoError(err)

icaPacketData := icatypes.InterchainAccountPacketData{
Type: icatypes.EXECUTE_TX,
Data: data,
}

packetData = icaPacketData.GetBytes()

params := types.NewParams(true, []string{sdk.MsgTypeURL(msg)})
suite.chainB.GetSimApp().ICAHostKeeper.SetParams(suite.chainB.GetContext(), params)
},
false,
},
{
"unregistered sdk.Msg",
func(encoding string) {
Expand Down

0 comments on commit 6d3c70f

Please sign in to comment.