From a428d5c6054a4dac4929ce48e4e0ac409856b18b Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 28 Jul 2021 10:17:24 +0200 Subject: [PATCH] Add filtering to logic, tests pass --- x/wasm/keeper/query_plugins.go | 6 ++++-- x/wasm/keeper/query_plugins_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/x/wasm/keeper/query_plugins.go b/x/wasm/keeper/query_plugins.go index fff7953dc3..cba21cdfc7 100644 --- a/x/wasm/keeper/query_plugins.go +++ b/x/wasm/keeper/query_plugins.go @@ -198,7 +198,8 @@ func IBCQuerier(wasm contractMetaDataSource, channelKeeper types.ChannelKeeper) portID := request.ListChannels.PortID channels := make(wasmvmtypes.IBCChannels, 0) channelKeeper.IterateChannels(ctx, func(ch channeltypes.IdentifiedChannel) bool { - if portID == "" || portID == ch.PortId { + // it must match the port and be in open state + if (portID == "" || portID == ch.PortId) && ch.State == channeltypes.OPEN { newChan := wasmvmtypes.IBCChannel{ Endpoint: wasmvmtypes.IBCEndpoint{ PortID: ch.PortId, @@ -230,7 +231,8 @@ func IBCQuerier(wasm contractMetaDataSource, channelKeeper types.ChannelKeeper) } got, found := channelKeeper.GetChannel(ctx, portID, channelID) var channel *wasmvmtypes.IBCChannel - if found { + // it must be in open state + if found && got.State == channeltypes.OPEN { channel = &wasmvmtypes.IBCChannel{ Endpoint: wasmvmtypes.IBCEndpoint{ PortID: portID, diff --git a/x/wasm/keeper/query_plugins_test.go b/x/wasm/keeper/query_plugins_test.go index 57ac72f3aa..e9727b588d 100644 --- a/x/wasm/keeper/query_plugins_test.go +++ b/x/wasm/keeper/query_plugins_test.go @@ -171,7 +171,7 @@ func TestIBCQuerier(t *testing.T) { channelKeeper: &wasmtesting.MockChannelKeeper{ GetChannelFn: func(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) { return channeltypes.Channel{ - State: channeltypes.INIT, + State: channeltypes.OPEN, Ordering: channeltypes.UNORDERED, Counterparty: channeltypes.Counterparty{ PortId: "counterPartyPortID",