Skip to content

Commit

Permalink
Merge pull request #342 from bnb-chain/master
Browse files Browse the repository at this point in the history
sync: sync master branch to develop branch
  • Loading branch information
unclezoro authored Oct 24, 2023
2 parents 3803e78 + 376e9d9 commit f5f1749
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v1.0.1
This release includes 1 bug fix.

* [#338](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/338) fix: count total when pagination request is empty

## v1.0.0
This release includes 2 new features.

Expand Down
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 f5f1749

Please sign in to comment.