Fix query validator UBDs (#7228)

Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Anil Kumar Kammari 2020-09-02 22:17:29 +05:30 committed by GitHub
parent 979e8144fb
commit da7a8e603f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -133,9 +133,13 @@ func (k Querier) ValidatorUnbondingDelegations(c context.Context, req *types.Que
ctx := sdk.UnwrapSDKContext(c)
store := ctx.KVStore(k.storeKey)
ubdStore := prefix.NewStore(store, types.GetUBDsByValIndexKey(req.ValidatorAddr))
srcValPrefix := types.GetUBDsByValIndexKey(req.ValidatorAddr)
ubdStore := prefix.NewStore(store, srcValPrefix)
pageRes, err := query.Paginate(ubdStore, req.Pagination, func(key []byte, value []byte) error {
ubd, err := types.UnmarshalUBD(k.cdc, value)
storeKey := types.GetUBDKeyFromValIndexKey(append(srcValPrefix, key...))
storeValue := store.Get(storeKey)
ubd, err := types.UnmarshalUBD(k.cdc, storeValue)
if err != nil {
return err
}

View File

@ -706,6 +706,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryValidatorUnbondingDelegations() {
suite.NoError(err)
suite.Equal(uint64(1), res.Pagination.Total)
suite.Equal(1, len(res.UnbondingResponses))
suite.Equal(res.UnbondingResponses[0].ValidatorAddress, val1.GetOperator())
} else {
suite.Error(err)
suite.Nil(res)