diff --git a/x/wasm/keeper/query_plugins_test.go b/x/wasm/keeper/query_plugins_test.go index 9baa9aa428..57ac72f3aa 100644 --- a/x/wasm/keeper/query_plugins_test.go +++ b/x/wasm/keeper/query_plugins_test.go @@ -14,6 +14,7 @@ import ( func TestIBCQuerier(t *testing.T) { myExampleChannels := []channeltypes.IdentifiedChannel{ + // this is returned { State: channeltypes.OPEN, Ordering: channeltypes.ORDERED, @@ -26,9 +27,22 @@ func TestIBCQuerier(t *testing.T) { PortId: "myPortID", ChannelId: "myChannelID", }, + // this is filtered out { State: channeltypes.INIT, Ordering: channeltypes.UNORDERED, + Counterparty: channeltypes.Counterparty{ + PortId: "foobar", + }, + ConnectionHops: []string{"one"}, + Version: "initversion", + PortId: "initPortID", + ChannelId: "initChannelID", + }, + // this is returned + { + State: channeltypes.OPEN, + Ordering: channeltypes.UNORDERED, Counterparty: channeltypes.Counterparty{ PortId: "otherCounterPartyPortID", ChannelId: "otherCounterPartyChannelID", @@ -38,6 +52,19 @@ func TestIBCQuerier(t *testing.T) { PortId: "otherPortID", ChannelId: "otherChannelID", }, + // this is filtered out + { + State: channeltypes.CLOSED, + Ordering: channeltypes.ORDERED, + Counterparty: channeltypes.Counterparty{ + PortId: "super", + ChannelId: "duper", + }, + ConnectionHops: []string{"no-more"}, + Version: "closedVersion", + PortId: "closedPortID", + ChannelId: "closedChannelID", + }, } specs := map[string]struct { srcQuery *wasmvmtypes.IBCQuery @@ -183,7 +210,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", @@ -210,6 +237,51 @@ func TestIBCQuerier(t *testing.T) { } }`, }, + "query channel in init state": { + srcQuery: &wasmvmtypes.IBCQuery{ + Channel: &wasmvmtypes.ChannelQuery{ + PortID: "myQueryPortID", + ChannelID: "myQueryChannelID", + }, + }, + channelKeeper: &wasmtesting.MockChannelKeeper{ + GetChannelFn: func(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) { + return channeltypes.Channel{ + State: channeltypes.INIT, + Ordering: channeltypes.UNORDERED, + Counterparty: channeltypes.Counterparty{ + PortId: "foobar", + }, + ConnectionHops: []string{"one"}, + Version: "initversion", + }, true + }, + }, + expJsonResult: "{}", + }, + "query channel in closed state": { + srcQuery: &wasmvmtypes.IBCQuery{ + Channel: &wasmvmtypes.ChannelQuery{ + PortID: "myQueryPortID", + ChannelID: "myQueryChannelID", + }, + }, + channelKeeper: &wasmtesting.MockChannelKeeper{ + GetChannelFn: func(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) { + return channeltypes.Channel{ + State: channeltypes.CLOSED, + Ordering: channeltypes.ORDERED, + Counterparty: channeltypes.Counterparty{ + PortId: "super", + ChannelId: "duper", + }, + ConnectionHops: []string{"no-more"}, + Version: "closedVersion", + }, true + }, + }, + expJsonResult: "{}", + }, "query channel - empty result": { srcQuery: &wasmvmtypes.IBCQuery{ Channel: &wasmvmtypes.ChannelQuery{