Skip to content

Commit

Permalink
update querier test
Browse files Browse the repository at this point in the history
  • Loading branch information
atheeshp committed Jun 23, 2022
1 parent d8cd781 commit 3286ad8
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions x/slashing/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,52 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/simapp"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/cosmos/cosmos-sdk/x/slashing/keeper"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
"github.com/cosmos/cosmos-sdk/x/slashing/testslashing"
"github.com/cosmos/cosmos-sdk/x/slashing/testutil"
"github.com/cosmos/cosmos-sdk/x/slashing/types"
)

func TestNewQuerier(t *testing.T) {
app := simapp.Setup(t, false)
var slashingKeeper slashingkeeper.Keeper
var legacyAmino *codec.LegacyAmino
app, err := simtestutil.Setup(
testutil.AppConfig,
&legacyAmino,
&slashingKeeper,
)
require.NoError(t, err)

ctx := app.BaseApp.NewContext(false, tmproto.Header{})
app.SlashingKeeper.SetParams(ctx, testslashing.TestParams())
legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino())
querier := keeper.NewQuerier(app.SlashingKeeper, legacyQuerierCdc.LegacyAmino)
slashingKeeper.SetParams(ctx, testslashing.TestParams())
legacyQuerierCdc := codec.NewAminoCodec(legacyAmino)
querier := keeper.NewQuerier(slashingKeeper, legacyQuerierCdc.LegacyAmino)

query := abci.RequestQuery{
Path: "",
Data: []byte{},
}

_, err := querier(ctx, []string{types.QueryParameters}, query)
_, err = querier(ctx, []string{types.QueryParameters}, query)
require.NoError(t, err)
}

func TestQueryParams(t *testing.T) {
var slashingKeeper slashingkeeper.Keeper
app, err := simtestutil.Setup(
testutil.AppConfig,
&slashingKeeper,
)
require.NoError(t, err)

cdc := codec.NewLegacyAmino()
legacyQuerierCdc := codec.NewAminoCodec(cdc)
app := simapp.Setup(t, false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
app.SlashingKeeper.SetParams(ctx, testslashing.TestParams())
slashingKeeper.SetParams(ctx, testslashing.TestParams())

querier := keeper.NewQuerier(app.SlashingKeeper, legacyQuerierCdc.LegacyAmino)
querier := keeper.NewQuerier(slashingKeeper, legacyQuerierCdc.LegacyAmino)

query := abci.RequestQuery{
Path: "",
Expand All @@ -52,5 +68,5 @@ func TestQueryParams(t *testing.T) {

err = cdc.UnmarshalJSON(res, &params)
require.NoError(t, err)
require.Equal(t, app.SlashingKeeper.GetParams(ctx), params)
require.Equal(t, slashingKeeper.GetParams(ctx), params)
}

0 comments on commit 3286ad8

Please sign in to comment.