[823] Add pagination safety tests for get_active_subscriber_page with tombstones - #999
Merged
orunganiekan merged 4 commits intoAug 31, 2026
Conversation
…ith tombstones Closes SiLioLabs#823 Fixed two bugs in get_active_subscriber_page: 1. Added missing is_subscriber_index_removed check to skip tombstoned slots, preventing duplicate entries when a user resubscribes after cancellation. 2. Capped scan range at offset+cap to prevent pagination overlap where the same active user appears in consecutive pages. Added comprehensive pagination safety tests: - Tests with interleaved cancellations proving keepers can scan all active users - Tests for bounded scan per call (no infinite loops) - Tests for resubscribe-after-cancel producing no duplicates - Tests for edge cases (empty index, all cancelled, offset beyond count) Documented pagination semantics: offset is a slot index (not result count), callers must advance offset by cap on each call.
- App.tsx: remove duplicate imports, duplicate state declarations, fix broken JSX (unclosed gate banner, unclosed RPC failure banner) - stellar.test.ts: close missing describe block, deduplicate imports - ConfirmModal.tsx: merge duplicate button opening tags - PayPerUseForm.tsx: remove duplicate forwardRef signature, add missing imports (useMemo, validateStroopAmount), remove incomplete handleSubmit - SubscribeForm.tsx: remove duplicate variable declarations, fix missing && operator, fix undefined amount references - stellar.ts: remove duplicate const account declaration - scripts/package.json: remove duplicate key, fix missing comma
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 #823
Summary
Bug Fixes
Fixed two bugs in
get_active_subscriber_page(contract/src/lib.rs):Added missing tombstone check: The function now checks
is_subscriber_index_removedbefore reading each slot, preventing duplicate entries when a user resubscribes after cancellation. Without this fix, a cancelled-then-resubscribed user would appear twice in paginated results.Capped scan range: The scan loop now uses
end = (offset + cap).min(count)instead of scanning untilcapresults are found. This ensures each page covers exactlymin(limit, 50)slots, preventing pagination overlap where the same active user appears in consecutive pages.Documented Pagination Semantics
Added comprehensive documentation to
get_active_subscriber_pageexplaining:offsetis a slot index, not a result countoffsetbycap = min(limit, 50)on each callcapresultsTests Added
11 new tests covering pagination safety under tombstones:
test_active_subscriber_page_no_tombstones_covers_all- basic pagination workstest_active_subscriber_page_with_tombstones_covers_all- keeper iteration with interleaved cancellationstest_active_subscriber_page_offset_beyond_count_returns_empty- edge casetest_active_subscriber_page_zero_limit_returns_empty- edge casetest_active_subscriber_page_all_cancelled_returns_empty- all cancelledtest_active_subscriber_page_bounded_scan_with_sparse_index- sparse index bounded scantest_active_subscriber_page_alternating_active_cancelled- alternating patterntest_active_subscriber_page_resubscribe_after_cancel- no duplicates after resubscribetest_active_subscriber_page_keeper_iteration_terminates- no infinite loopstest_active_subscriber_page_limit_capped_at_50- limit cappingtest_active_subscriber_page_only_last_active- all but last cancelledAll 446 tests pass (
cargo test).