Skip to content

Commit

Permalink
Merge pull request #338 from forcodedancing/disable_total_for_empty_r…
Browse files Browse the repository at this point in the history
…equest

fix: do not count total when pagination request is empty
  • Loading branch information
unclezoro authored Oct 13, 2023
2 parents 5a38210 + 825c77d commit 42da638
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions types/query/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ func Paginate(

if limit == 0 {
limit = DefaultLimit

// count total results when the limit is zero/not supplied
countTotal = true
// do not count total results when the limit is zero/not supplied
// countTotal = true
} else if limit > DefaultLimit {
// limit to protect the node would not be Query DoS
limit = DefaultLimit
Expand Down
3 changes: 2 additions & 1 deletion types/query/pagination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ func (s *paginationTestSuite) TestPagination() {
request := types.NewQueryAllBalancesRequest(addr1, pageReq)
res, err := queryClient.AllBalances(gocontext.Background(), request)
s.Require().NoError(err)
s.Require().Equal(res.Pagination.Total, uint64(numBalances))
// default page request will not return total count
// s.Require().Equal(res.Pagination.Total, uint64(numBalances))
s.Require().NotNil(res.Pagination.NextKey)
s.Require().LessOrEqual(res.Balances.Len(), defaultLimit)

Expand Down

0 comments on commit 42da638

Please sign in to comment.