From 825c77d57f460717635d5305bd9abbf189ddd3fb Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Fri, 13 Oct 2023 15:02:15 +0800 Subject: [PATCH 1/2] fix: do not count total when pagination request is empty --- types/query/pagination.go | 5 ++--- types/query/pagination_test.go | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/query/pagination.go b/types/query/pagination.go index de984dd2f8..bef2cd6575 100644 --- a/types/query/pagination.go +++ b/types/query/pagination.go @@ -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 diff --git a/types/query/pagination_test.go b/types/query/pagination_test.go index 4228b0cde9..a8119361d1 100644 --- a/types/query/pagination_test.go +++ b/types/query/pagination_test.go @@ -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) From 02d2136d7e0021d9cfb9abec1f5307f30846b383 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Fri, 13 Oct 2023 20:06:59 +0800 Subject: [PATCH 2/2] release: draft release for v1.0.1 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 115746a460..58bf9b3e3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.