@@ -647,12 +647,13 @@ func TestIBCListChannelsQuery(t *testing.T) {
647647 cdc := MakeEncodingConfig (t ).Codec
648648 pCtx , keepers := CreateTestInput (t , false , ReflectFeatures , WithMessageEncoders (reflectEncoders (cdc )), WithQueryPlugins (reflectPlugins ()))
649649 keeper := keepers .WasmKeeper
650- example := InstantiateReflectExampleContract (t , pCtx , keepers )
650+ nonIbcExample := InstantiateReflectExampleContract (t , pCtx , keepers )
651+ ibcExample := InstantiateReflectExampleContract (t , pCtx , keepers )
651652 // add an ibc port for testing
652653 myIBCPortID := "myValidPortID"
653- cInfo := keeper .GetContractInfo (pCtx , example .Contract )
654+ cInfo := keeper .GetContractInfo (pCtx , ibcExample .Contract )
654655 cInfo .IBCPortID = myIBCPortID
655- keeper .storeContractInfo (pCtx , example .Contract , cInfo )
656+ keeper .storeContractInfo (pCtx , ibcExample .Contract , cInfo )
656657 // store a random channel to be ignored in queries
657658 unusedChan := channeltypes.Channel {
658659 State : channeltypes .OPEN ,
@@ -720,14 +721,16 @@ func TestIBCListChannelsQuery(t *testing.T) {
720721 noopSetup := func (t * testing.T , ctx sdk.Context ) sdk.Context { return ctx }
721722
722723 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 )
727729 }{
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 {}},
731734 assert : func (t * testing.T , d []byte ) {
732735 rsp := unmarshalReflect [wasmvmtypes.ListChannelsResponse ](t , d )
733736 exp := wasmvmtypes.ListChannelsResponse {Channels : []wasmvmtypes.IBCChannel {
@@ -754,9 +757,10 @@ func TestIBCListChannelsQuery(t *testing.T) {
754757 assert .Equal (t , exp , rsp )
755758 },
756759 },
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" }},
760764 assert : func (t * testing.T , d []byte ) {
761765 rsp := unmarshalReflect [wasmvmtypes.ListChannelsResponse ](t , d )
762766 exp := wasmvmtypes.ListChannelsResponse {Channels : []wasmvmtypes.IBCChannel {
@@ -783,9 +787,19 @@ func TestIBCListChannelsQuery(t *testing.T) {
783787 assert .Equal (t , exp , rsp )
784788 },
785789 },
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 {}},
789803 assert : func (t * testing.T , d []byte ) {
790804 rsp := unmarshalReflect [wasmvmtypes.ListChannelsResponse ](t , d )
791805 assert .Empty (t , rsp .Channels )
@@ -803,7 +817,7 @@ func TestIBCListChannelsQuery(t *testing.T) {
803817 Request : & wasmvmtypes.QueryRequest {IBC : spec .query },
804818 },
805819 })
806- simpleRes , gotErr := keeper .QuerySmart (ctx , example . Contract , queryBz )
820+ simpleRes , gotErr := keeper .QuerySmart (ctx , spec . contract , queryBz )
807821 if spec .expErr {
808822 require .Error (t , gotErr )
809823 return
0 commit comments