Skip to content

Commit

Permalink
feat: binding error to match expected
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersuweijie committed Mar 25, 2024
1 parent eb2c43c commit b6617f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion x/alliance/bindings/query_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bindings

import (
"encoding/json"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"

Expand Down Expand Up @@ -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")
}
}

Expand Down
18 changes: 18 additions & 0 deletions x/alliance/bindings/tests/query_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit b6617f3

Please sign in to comment.