From a8c3b4414de6eb0b88f5a6730d56f453556ad195 Mon Sep 17 00:00:00 2001 From: Emmanuel T Odeke Date: Mon, 7 Dec 2020 01:32:59 -0800 Subject: [PATCH] x/bank/keeper: fix a missing gRPC error in AllBalances (#8085) * x/bank/keeper: fix a missing gRPC error in AllBalances Fixes an incoherent return which had: (non-nil value, non-nil-non-grpc error) to (nil value, non-nil-gRPC error) and it is a follow-up of PR #7814. * types/query: fix pagination test (#8096) Co-authored-by: Alessio Treglia --- types/query/pagination_test.go | 2 +- x/bank/keeper/grpc_query.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/query/pagination_test.go b/types/query/pagination_test.go index e24d7c489d..f0e1377a1e 100644 --- a/types/query/pagination_test.go +++ b/types/query/pagination_test.go @@ -159,7 +159,7 @@ func (s *paginationTestSuite) TestPagination() { request = types.NewQueryAllBalancesRequest(addr1, pageReq) res, err = queryClient.AllBalances(gocontext.Background(), request) s.Require().Error(err) - s.Require().Equal(err.Error(), "invalid request, either offset or key is expected, got both") + s.Require().Equal("rpc error: code = InvalidArgument desc = paginate: invalid request, either offset or key is expected, got both", err.Error()) s.T().Log("verify paginate with offset greater than total results") pageReq = &query.PageRequest{Offset: 300, Limit: defaultLimit, CountTotal: false} diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index a71d0d72c0..bcf143b8aa 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -72,7 +72,7 @@ func (k BaseKeeper) AllBalances(ctx context.Context, req *types.QueryAllBalances }) if err != nil { - return &types.QueryAllBalancesResponse{}, err + return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) } return &types.QueryAllBalancesResponse{Balances: balances, Pagination: pageRes}, nil