2020-04-24 15:44:44 +00:00
|
|
|
package keeper_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2020-04-30 14:13:31 +00:00
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
|
|
|
2020-04-24 15:44:44 +00:00
|
|
|
"github.com/kava-labs/kava/x/incentive/keeper"
|
|
|
|
"github.com/kava-labs/kava/x/incentive/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (suite *KeeperTestSuite) TestQuerier() {
|
|
|
|
suite.addObjectsToStore()
|
|
|
|
querier := keeper.NewQuerier(suite.keeper)
|
|
|
|
bz, err := querier(suite.ctx, []string{types.QueryGetParams}, abci.RequestQuery{})
|
|
|
|
suite.Require().NoError(err)
|
|
|
|
suite.NotNil(bz)
|
|
|
|
|
|
|
|
var p types.Params
|
|
|
|
suite.Nil(types.ModuleCdc.UnmarshalJSON(bz, &p))
|
|
|
|
|
|
|
|
claimQueryParams := types.NewQueryClaimsParams(suite.addrs[0], "bnb")
|
|
|
|
query := abci.RequestQuery{
|
|
|
|
Path: strings.Join([]string{"custom", types.QuerierRoute, types.QueryGetClaims}, "/"),
|
|
|
|
Data: types.ModuleCdc.MustMarshalJSON(claimQueryParams),
|
|
|
|
}
|
|
|
|
bz, err = querier(suite.ctx, []string{types.QueryGetClaims}, query)
|
|
|
|
|
2020-09-01 12:34:11 +00:00
|
|
|
var claims types.AugmentedClaims
|
2020-04-24 15:44:44 +00:00
|
|
|
suite.Nil(types.ModuleCdc.UnmarshalJSON(bz, &claims))
|
|
|
|
suite.Equal(1, len(claims))
|
2020-09-01 12:34:11 +00:00
|
|
|
suite.Equal(types.AugmentedClaims{
|
|
|
|
types.NewAugmentedClaim(types.NewClaim(suite.addrs[0], c("ukava", 1000000), "bnb", 1), true),
|
|
|
|
}, claims)
|
2020-05-28 14:57:22 +00:00
|
|
|
|
|
|
|
var rp types.RewardPeriods
|
|
|
|
bz, err = querier(suite.ctx, []string{types.QueryGetRewardPeriods}, abci.RequestQuery{})
|
|
|
|
suite.Require().NoError(err)
|
|
|
|
suite.NotNil(bz)
|
|
|
|
suite.Nil(types.ModuleCdc.UnmarshalJSON(bz, &rp))
|
|
|
|
|
|
|
|
var cp types.ClaimPeriods
|
|
|
|
bz, err = querier(suite.ctx, []string{types.QueryGetClaimPeriods}, abci.RequestQuery{})
|
|
|
|
suite.Require().NoError(err)
|
|
|
|
suite.NotNil(bz)
|
|
|
|
suite.Nil(types.ModuleCdc.UnmarshalJSON(bz, &cp))
|
|
|
|
|
2020-04-24 15:44:44 +00:00
|
|
|
}
|