From c7ea0e850e927d497bbe1fff6ff97d27fbc190d5 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Thu, 3 Feb 2022 13:17:08 +0100 Subject: [PATCH] test: ensure ics27 optimistic packet sends are disallowed (#842) --- .../27-interchain-accounts/controller/keeper/relay.go | 2 +- .../controller/keeper/relay_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/relay.go b/modules/apps/27-interchain-accounts/controller/keeper/relay.go index 4375b3e3ee0..4eaf26c52a6 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay.go @@ -16,7 +16,7 @@ import ( // absolute timeoutTimestamp must be provided. If the packet is timed out, the channel will be closed. // In the case of channel closure, a new channel may be reopened to reconnect to the host chain. func (k Keeper) SendTx(ctx sdk.Context, chanCap *capabilitytypes.Capability, connectionID, portID string, icaPacketData icatypes.InterchainAccountPacketData, timeoutTimestamp uint64) (uint64, error) { - activeChannelID, found := k.GetActiveChannelID(ctx, connectionID, portID) + activeChannelID, found := k.GetOpenActiveChannel(ctx, connectionID, portID) if !found { return 0, sdkerrors.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel on connection %s for port %s", connectionID, portID) } diff --git a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go index e687e0a751e..bb4d17b8232 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go @@ -100,6 +100,17 @@ func (suite *KeeperTestSuite) TestSendTx() { }, false, }, + { + "channel in INIT state - optimistic packet sends fail", + func() { + channel, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + suite.Require().True(found) + + channel.State = channeltypes.INIT + suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel) + }, + false, + }, { "sendPacket fails - channel closed", func() {