diff --git a/x/alliance/bindings/query_plugin.go b/x/alliance/bindings/query_plugin.go index 1ea17848..1cda6725 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 0b1f7eaf..625b892f 100644 --- a/x/alliance/bindings/tests/query_plugin_test.go +++ b/x/alliance/bindings/tests/query_plugin_test.go @@ -208,3 +208,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, math.LegacyNewDec(2), math.LegacyZeroDec(), math.LegacyNewDec(5), math.LegacyNewDec(0), genesisTime), + }, + }) + + querierPlugin := bindings.NewAllianceQueryPlugin(app.AllianceKeeper) + querier := bindings.CustomQuerier(querierPlugin) + + queryBytes := []byte("{\"random\": \"query\"}") + _, err := querier(ctx, queryBytes) + require.Error(t, err) +}