diff --git a/x/alliance/bindings/query_plugin.go b/x/alliance/bindings/query_plugin.go index c2a095ee..df00cc5f 100644 --- a/x/alliance/bindings/query_plugin.go +++ b/x/alliance/bindings/query_plugin.go @@ -2,6 +2,7 @@ package bindings import ( "encoding/json" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" @@ -25,7 +26,7 @@ func CustomQuerier(q *QueryPlugin) func(ctx sdk.Context, request json.RawMessage var AllianceRequest types.AllianceQuery err = json.Unmarshal(request, &AllianceRequest) if err != nil { - return + return nil, err } if AllianceRequest.Alliance != nil { return q.GetAlliance(ctx, AllianceRequest.Alliance.Denom) @@ -48,7 +49,7 @@ func CustomQuerier(q *QueryPlugin) func(ctx sdk.Context, request json.RawMessage validator, ) } - return nil, nil + return nil, fmt.Errorf("unknown query") } } diff --git a/x/alliance/bindings/tests/query_plugin_test.go b/x/alliance/bindings/tests/query_plugin_test.go index 8a6c9f09..444a9153 100644 --- a/x/alliance/bindings/tests/query_plugin_test.go +++ b/x/alliance/bindings/tests/query_plugin_test.go @@ -203,3 +203,21 @@ func TestDelegationRewardsQuery(t *testing.T) { }, }, response) } + +func TestCustomQuerier(t *testing.T) { + app, ctx := createTestContext(t) + genesisTime := ctx.BlockTime() + app.AllianceKeeper.InitGenesis(ctx, &types.GenesisState{ + Params: types.DefaultParams(), + Assets: []types.AllianceAsset{ + types.NewAllianceAsset(AllianceDenom, sdk.NewDec(2), sdk.ZeroDec(), sdk.NewDec(5), sdk.NewDec(0), genesisTime), + }, + }) + + querierPlugin := bindings.NewAllianceQueryPlugin(app.AllianceKeeper) + querier := bindings.CustomQuerier(querierPlugin) + + queryBytes := []byte("{\"random\": \"query\"}") + _, err := querier(ctx, queryBytes) + require.Error(t, err) +}