test: add regression tests for beyond-count and off-by-one settlement listing boundaries#227
Open
onyekachi66 wants to merge 1 commit into
Open
test: add regression tests for beyond-count and off-by-one settlement listing boundaries#227onyekachi66 wants to merge 1 commit into
onyekachi66 wants to merge 1 commit into
Conversation
… listing boundaries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #150
Overview
This PR addresses a test-coverage gap identified in the settlement pagination logic. Specifically, the boundary where the paginated request parameter
startexceeds the total number of settlements (settlement_count()) did not have explicit, dedicated coverage to prevent regression panics.While the existing implementation correctly handles this under-the-hood (using loop guards like
id <= countwith(out.len() as u32) < limit), this PR guarantees safety at these boundaries for external integrators who might naively incrementstartbeyond the available index set.Changes Made
Tests Added in
src/test.rsAdded two new unit tests to explicitly lock down the behavior of the following four APIs:
list_settlementslist_settlements_by_anchorlist_settlements_by_assetlist_settlements_by_status1.
test_list_settlements_beyond_countstartparameter is set significantly higher than the total number of settlements.startvalue of100. Asserts that all endpoints successfully return an emptyVecrather than throwing an error or panicking.2.
test_list_settlements_off_by_one_boundarystartparameter is exactly equal tosettlement_count() + 1.1and2, totalsettlement_count() = 2). Queries all four endpoints withstartset to3. Asserts that each call returns an emptyVecwithout panic.Acceptance Criteria Checklist
list_settlementsbeyond-count boundary.list_settlements_by_anchorbeyond-count boundary.list_settlements_by_assetbeyond-count boundary.list_settlements_by_statusbeyond-count boundary.start == count + 1off-by-one boundary.