@@ -14,6 +14,7 @@ import (
14
14
15
15
func TestIBCQuerier (t * testing.T ) {
16
16
myExampleChannels := []channeltypes.IdentifiedChannel {
17
+ // this is returned
17
18
{
18
19
State : channeltypes .OPEN ,
19
20
Ordering : channeltypes .ORDERED ,
@@ -26,9 +27,22 @@ func TestIBCQuerier(t *testing.T) {
26
27
PortId : "myPortID" ,
27
28
ChannelId : "myChannelID" ,
28
29
},
30
+ // this is filtered out
29
31
{
30
32
State : channeltypes .INIT ,
31
33
Ordering : channeltypes .UNORDERED ,
34
+ Counterparty : channeltypes.Counterparty {
35
+ PortId : "foobar" ,
36
+ },
37
+ ConnectionHops : []string {"one" },
38
+ Version : "initversion" ,
39
+ PortId : "initPortID" ,
40
+ ChannelId : "initChannelID" ,
41
+ },
42
+ // this is returned
43
+ {
44
+ State : channeltypes .OPEN ,
45
+ Ordering : channeltypes .UNORDERED ,
32
46
Counterparty : channeltypes.Counterparty {
33
47
PortId : "otherCounterPartyPortID" ,
34
48
ChannelId : "otherCounterPartyChannelID" ,
@@ -38,6 +52,19 @@ func TestIBCQuerier(t *testing.T) {
38
52
PortId : "otherPortID" ,
39
53
ChannelId : "otherChannelID" ,
40
54
},
55
+ // this is filtered out
56
+ {
57
+ State : channeltypes .CLOSED ,
58
+ Ordering : channeltypes .ORDERED ,
59
+ Counterparty : channeltypes.Counterparty {
60
+ PortId : "super" ,
61
+ ChannelId : "duper" ,
62
+ },
63
+ ConnectionHops : []string {"no-more" },
64
+ Version : "closedVersion" ,
65
+ PortId : "closedPortID" ,
66
+ ChannelId : "closedChannelID" ,
67
+ },
41
68
}
42
69
specs := map [string ]struct {
43
70
srcQuery * wasmvmtypes.IBCQuery
@@ -144,7 +171,7 @@ func TestIBCQuerier(t *testing.T) {
144
171
channelKeeper : & wasmtesting.MockChannelKeeper {
145
172
GetChannelFn : func (ctx sdk.Context , srcPort , srcChan string ) (channel channeltypes.Channel , found bool ) {
146
173
return channeltypes.Channel {
147
- State : channeltypes .INIT ,
174
+ State : channeltypes .OPEN ,
148
175
Ordering : channeltypes .UNORDERED ,
149
176
Counterparty : channeltypes.Counterparty {
150
177
PortId : "counterPartyPortID" ,
@@ -183,7 +210,7 @@ func TestIBCQuerier(t *testing.T) {
183
210
channelKeeper : & wasmtesting.MockChannelKeeper {
184
211
GetChannelFn : func (ctx sdk.Context , srcPort , srcChan string ) (channel channeltypes.Channel , found bool ) {
185
212
return channeltypes.Channel {
186
- State : channeltypes .INIT ,
213
+ State : channeltypes .OPEN ,
187
214
Ordering : channeltypes .UNORDERED ,
188
215
Counterparty : channeltypes.Counterparty {
189
216
PortId : "counterPartyPortID" ,
@@ -210,6 +237,51 @@ func TestIBCQuerier(t *testing.T) {
210
237
}
211
238
}` ,
212
239
},
240
+ "query channel in init state" : {
241
+ srcQuery : & wasmvmtypes.IBCQuery {
242
+ Channel : & wasmvmtypes.ChannelQuery {
243
+ PortID : "myQueryPortID" ,
244
+ ChannelID : "myQueryChannelID" ,
245
+ },
246
+ },
247
+ channelKeeper : & wasmtesting.MockChannelKeeper {
248
+ GetChannelFn : func (ctx sdk.Context , srcPort , srcChan string ) (channel channeltypes.Channel , found bool ) {
249
+ return channeltypes.Channel {
250
+ State : channeltypes .INIT ,
251
+ Ordering : channeltypes .UNORDERED ,
252
+ Counterparty : channeltypes.Counterparty {
253
+ PortId : "foobar" ,
254
+ },
255
+ ConnectionHops : []string {"one" },
256
+ Version : "initversion" ,
257
+ }, true
258
+ },
259
+ },
260
+ expJsonResult : "{}" ,
261
+ },
262
+ "query channel in closed state" : {
263
+ srcQuery : & wasmvmtypes.IBCQuery {
264
+ Channel : & wasmvmtypes.ChannelQuery {
265
+ PortID : "myQueryPortID" ,
266
+ ChannelID : "myQueryChannelID" ,
267
+ },
268
+ },
269
+ channelKeeper : & wasmtesting.MockChannelKeeper {
270
+ GetChannelFn : func (ctx sdk.Context , srcPort , srcChan string ) (channel channeltypes.Channel , found bool ) {
271
+ return channeltypes.Channel {
272
+ State : channeltypes .CLOSED ,
273
+ Ordering : channeltypes .ORDERED ,
274
+ Counterparty : channeltypes.Counterparty {
275
+ PortId : "super" ,
276
+ ChannelId : "duper" ,
277
+ },
278
+ ConnectionHops : []string {"no-more" },
279
+ Version : "closedVersion" ,
280
+ }, true
281
+ },
282
+ },
283
+ expJsonResult : "{}" ,
284
+ },
213
285
"query channel - empty result" : {
214
286
srcQuery : & wasmvmtypes.IBCQuery {
215
287
Channel : & wasmvmtypes.ChannelQuery {
0 commit comments