Skip to content

[823] Add pagination safety tests for get_active_subscriber_page with tombstones - #999

Merged
orunganiekan merged 4 commits into
SiLioLabs:masterfrom
gloriaibrahim2002-blip:fix/823-pagination-safety-tombstones
Aug 31, 2026
Merged

[823] Add pagination safety tests for get_active_subscriber_page with tombstones#999
orunganiekan merged 4 commits into
SiLioLabs:masterfrom
gloriaibrahim2002-blip:fix/823-pagination-safety-tombstones

Conversation

@gloriaibrahim2002-blip

Copy link
Copy Markdown
Contributor

Closes #823

Summary

Bug Fixes

Fixed two bugs in get_active_subscriber_page (contract/src/lib.rs):

  1. Added missing tombstone check: The function now checks is_subscriber_index_removed before 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.

  2. Capped scan range: The scan loop now uses end = (offset + cap).min(count) instead of scanning until cap results are found. This ensures each page covers exactly min(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_page explaining:

  • offset is a slot index, not a result count
  • Callers must advance offset by cap = min(limit, 50) on each call
  • Tombstoned and inactive slots are skipped; pages may return fewer than cap results
  • The scan is bounded per call, preventing unbounded iteration on sparse indexes

Tests Added

11 new tests covering pagination safety under tombstones:

  • test_active_subscriber_page_no_tombstones_covers_all - basic pagination works
  • test_active_subscriber_page_with_tombstones_covers_all - keeper iteration with interleaved cancellations
  • test_active_subscriber_page_offset_beyond_count_returns_empty - edge case
  • test_active_subscriber_page_zero_limit_returns_empty - edge case
  • test_active_subscriber_page_all_cancelled_returns_empty - all cancelled
  • test_active_subscriber_page_bounded_scan_with_sparse_index - sparse index bounded scan
  • test_active_subscriber_page_alternating_active_cancelled - alternating pattern
  • test_active_subscriber_page_resubscribe_after_cancel - no duplicates after resubscribe
  • test_active_subscriber_page_keeper_iteration_terminates - no infinite loops
  • test_active_subscriber_page_limit_capped_at_50 - limit capping
  • test_active_subscriber_page_only_last_active - all but last cancelled

All 446 tests pass (cargo test).

gloriaibrahim2002-blip and others added 4 commits August 31, 2026 11:14
…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
@orunganiekan
orunganiekan merged commit 88d4708 into SiLioLabs:master Aug 31, 2026
0 of 3 checks passed
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.

Issue 027: Add pagination safety tests for get_active_subscriber_page with tombstones

2 participants