@@ -647,12 +647,13 @@ func TestIBCListChannelsQuery(t *testing.T) {
647
647
cdc := MakeEncodingConfig (t ).Codec
648
648
pCtx , keepers := CreateTestInput (t , false , ReflectFeatures , WithMessageEncoders (reflectEncoders (cdc )), WithQueryPlugins (reflectPlugins ()))
649
649
keeper := keepers .WasmKeeper
650
- example := InstantiateReflectExampleContract (t , pCtx , keepers )
650
+ nonIbcExample := InstantiateReflectExampleContract (t , pCtx , keepers )
651
+ ibcExample := InstantiateReflectExampleContract (t , pCtx , keepers )
651
652
// add an ibc port for testing
652
653
myIBCPortID := "myValidPortID"
653
- cInfo := keeper .GetContractInfo (pCtx , example .Contract )
654
+ cInfo := keeper .GetContractInfo (pCtx , ibcExample .Contract )
654
655
cInfo .IBCPortID = myIBCPortID
655
- keeper .storeContractInfo (pCtx , example .Contract , cInfo )
656
+ keeper .storeContractInfo (pCtx , ibcExample .Contract , cInfo )
656
657
// store a random channel to be ignored in queries
657
658
unusedChan := channeltypes.Channel {
658
659
State : channeltypes .OPEN ,
@@ -720,14 +721,16 @@ func TestIBCListChannelsQuery(t *testing.T) {
720
721
noopSetup := func (t * testing.T , ctx sdk.Context ) sdk.Context { return ctx }
721
722
722
723
specs := map [string ]struct {
723
- setup func (t * testing.T , ctx sdk.Context ) sdk.Context
724
- query * wasmvmtypes.IBCQuery
725
- expErr bool
726
- assert func (t * testing.T , d []byte )
724
+ setup func (t * testing.T , ctx sdk.Context ) sdk.Context
725
+ contract sdk.AccAddress
726
+ query * wasmvmtypes.IBCQuery
727
+ expErr bool
728
+ assert func (t * testing.T , d []byte )
727
729
}{
728
- "only open channels - portID empty" : {
729
- setup : withChannelsStored (myIBCPortID , myExampleChannels ... ),
730
- query : & wasmvmtypes.IBCQuery {ListChannels : & wasmvmtypes.ListChannelsQuery {}},
730
+ "open channels - with query portID empty" : {
731
+ contract : ibcExample .Contract ,
732
+ setup : withChannelsStored (myIBCPortID , myExampleChannels ... ),
733
+ query : & wasmvmtypes.IBCQuery {ListChannels : & wasmvmtypes.ListChannelsQuery {}},
731
734
assert : func (t * testing.T , d []byte ) {
732
735
rsp := unmarshalReflect [wasmvmtypes.ListChannelsResponse ](t , d )
733
736
exp := wasmvmtypes.ListChannelsResponse {Channels : []wasmvmtypes.IBCChannel {
@@ -754,9 +757,10 @@ func TestIBCListChannelsQuery(t *testing.T) {
754
757
assert .Equal (t , exp , rsp )
755
758
},
756
759
},
757
- "open channels - portID set to non contract addr" : {
758
- setup : withChannelsStored ("OtherPortID" , myExampleChannels ... ),
759
- query : & wasmvmtypes.IBCQuery {ListChannels : & wasmvmtypes.ListChannelsQuery {PortID : "OtherPortID" }},
760
+ "open channels - with query portID passed" : {
761
+ contract : ibcExample .Contract ,
762
+ setup : withChannelsStored ("OtherPortID" , myExampleChannels ... ),
763
+ query : & wasmvmtypes.IBCQuery {ListChannels : & wasmvmtypes.ListChannelsQuery {PortID : "OtherPortID" }},
760
764
assert : func (t * testing.T , d []byte ) {
761
765
rsp := unmarshalReflect [wasmvmtypes.ListChannelsResponse ](t , d )
762
766
exp := wasmvmtypes.ListChannelsResponse {Channels : []wasmvmtypes.IBCChannel {
@@ -783,9 +787,19 @@ func TestIBCListChannelsQuery(t *testing.T) {
783
787
assert .Equal (t , exp , rsp )
784
788
},
785
789
},
786
- "no channels" : {
787
- setup : noopSetup ,
788
- query : & wasmvmtypes.IBCQuery {ListChannels : & wasmvmtypes.ListChannelsQuery {}},
790
+ "non ibc contract - with query portID empty" : {
791
+ contract : nonIbcExample .Contract ,
792
+ setup : withChannelsStored (myIBCPortID , myExampleChannels ... ),
793
+ query : & wasmvmtypes.IBCQuery {ListChannels : & wasmvmtypes.ListChannelsQuery {}},
794
+ assert : func (t * testing.T , d []byte ) {
795
+ rsp := unmarshalReflect [wasmvmtypes.ListChannelsResponse ](t , d )
796
+ assert .Nil (t , rsp .Channels )
797
+ },
798
+ },
799
+ "no matching channels" : {
800
+ contract : ibcExample .Contract ,
801
+ setup : noopSetup ,
802
+ query : & wasmvmtypes.IBCQuery {ListChannels : & wasmvmtypes.ListChannelsQuery {}},
789
803
assert : func (t * testing.T , d []byte ) {
790
804
rsp := unmarshalReflect [wasmvmtypes.ListChannelsResponse ](t , d )
791
805
assert .Empty (t , rsp .Channels )
@@ -803,7 +817,7 @@ func TestIBCListChannelsQuery(t *testing.T) {
803
817
Request : & wasmvmtypes.QueryRequest {IBC : spec .query },
804
818
},
805
819
})
806
- simpleRes , gotErr := keeper .QuerySmart (ctx , example . Contract , queryBz )
820
+ simpleRes , gotErr := keeper .QuerySmart (ctx , spec . contract , queryBz )
807
821
if spec .expErr {
808
822
require .Error (t , gotErr )
809
823
return
0 commit comments