2019-07-19 06:43:38 -07:00
|
|
|
package keeper
|
2018-12-14 11:09:39 -08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2020-02-19 16:04:13 -08:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/slashing/types"
|
2018-12-14 11:09:39 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewQuerier(t *testing.T) {
|
2019-07-19 06:43:38 -07:00
|
|
|
ctx, _, _, _, keeper := CreateTestInput(t, TestParams())
|
2019-05-16 08:25:32 -07:00
|
|
|
querier := NewQuerier(keeper)
|
2018-12-14 11:09:39 -08:00
|
|
|
|
|
|
|
query := abci.RequestQuery{
|
|
|
|
Path: "",
|
|
|
|
Data: []byte{},
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := querier(ctx, []string{"parameters"}, query)
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestQueryParams(t *testing.T) {
|
|
|
|
cdc := codec.New()
|
2019-07-19 06:43:38 -07:00
|
|
|
ctx, _, _, _, keeper := CreateTestInput(t, TestParams())
|
2018-12-14 11:09:39 -08:00
|
|
|
|
2019-07-19 06:43:38 -07:00
|
|
|
var params types.Params
|
2018-12-14 11:09:39 -08:00
|
|
|
|
2019-05-16 08:25:32 -07:00
|
|
|
res, errRes := queryParams(ctx, keeper)
|
2018-12-14 11:09:39 -08:00
|
|
|
require.NoError(t, errRes)
|
|
|
|
|
|
|
|
err := cdc.UnmarshalJSON(res, ¶ms)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, keeper.GetParams(ctx), params)
|
|
|
|
}
|