Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: API/Fix checkpoint list total error #283

Merged
merged 2 commits into from
Jan 17, 2023
Merged

Conversation

gitferry
Copy link
Contributor

@gitferry gitferry commented Jan 17, 2023

This PR fixed the total error in pagination of the response of RawCheckpointList. Before the fix, when Finalized checkpoints are requested, the total in the pagination of the response is the total number of all the checkpoints instead of only finalized ones. This PR fixed the bug and added relevant test.

Copy link
Member

@vitsalis vitsalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

req := types.NewQueryRawCheckpointListRequest(pagination, status)

for ckptsRetrieved := uint64(0); ckptsRetrieved < uint64(len(checkpointList)); ckptsRetrieved += limit {
resp, err := ckptKeeper.RawCheckpointList(ctx, req)
require.NoError(t, err)
if ckptsRetrieved == 0 {
require.Equal(t, uint64(len(checkpointList)), resp.Pagination.Total)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this check happens only once, maybe it can happen outside of the loop?

@gitferry gitferry merged commit df7d98d into dev Jan 17, 2023
@gitferry gitferry deleted the fix-raw-checkpoint-list-total branch January 17, 2023 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants