diff --git a/x/wasm/ibc_integration_test.go b/x/wasm/ibc_integration_test.go index 42d367c089..4ff71dbe55 100644 --- a/x/wasm/ibc_integration_test.go +++ b/x/wasm/ibc_integration_test.go @@ -17,7 +17,7 @@ import ( ) func TestOnChanOpenInitVersion(t *testing.T) { - const startVersion = "v1" + const startVersion = "v2" specs := map[string]struct { contractRsp *wasmvmtypes.IBC3ChannelOpenResponse expVersion string diff --git a/x/wasm/keeper/handler_plugin.go b/x/wasm/keeper/handler_plugin.go index 7ac43a19b2..26086bc241 100644 --- a/x/wasm/keeper/handler_plugin.go +++ b/x/wasm/keeper/handler_plugin.go @@ -163,6 +163,13 @@ func (h IBCRawPacketHandler) DispatchMsg(ctx sdk.Context, _ sdk.AccAddress, cont return nil, nil, sdkerrors.Wrapf(types.ErrEmpty, "ibc channel") } + _, found := h.channelKeeper.GetNextSequenceSend(ctx, contractIBCPortID, contractIBCChannelID) + if !found { + return nil, nil, sdkerrors.Wrapf(channeltypes.ErrSequenceSendNotFound, + "source port: %s, source channel: %s", contractIBCPortID, contractIBCChannelID, + ) + } + channelCap, ok := h.capabilityKeeper.GetCapability(ctx, host.ChannelCapabilityPath(contractIBCPortID, contractIBCChannelID)) if !ok { return nil, nil, sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") diff --git a/x/wasm/keeper/handler_plugin_test.go b/x/wasm/keeper/handler_plugin_test.go index e99e271373..d96a004b67 100644 --- a/x/wasm/keeper/handler_plugin_test.go +++ b/x/wasm/keeper/handler_plugin_test.go @@ -247,6 +247,7 @@ func TestIBCRawPacketHandler(t *testing.T) { SourceChannel: sourceChannel, TimeoutHeight: timeoutHeight, TimeoutTimestamp: timeoutTimestamp, + Data: data, } return 1, nil }, @@ -292,6 +293,13 @@ func TestIBCRawPacketHandler(t *testing.T) { return 0, false }, }, + + capKeeper: wasmtesting.MockCapabilityKeeper{ + GetCapabilityFn: func(ctx sdk.Context, name string) (*capabilitytypes.Capability, bool) { + return nil, false + }, + }, + expErr: channeltypes.ErrSequenceSendNotFound, }, "capability not found returns error": {