Skip to content

Commit

Permalink
Fix query validator UBDs (cosmos#7228)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Bezobchuk <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 2, 2020
1 parent 979e814 commit da7a8e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions x/staking/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions x/staking/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit da7a8e6

Please sign in to comment.