test(indexer): add user.processor spec and reconcile-users CLI - #1696
Merged
Otaiki1 merged 2 commits intoSep 30, 2026
Merged
Conversation
Closes crackedstudio#1593. - Add indexer/src/processors/user.processor.spec.ts (25 tests) Covers all four handler methods with the scenarios called out in the issue: first event for a new address, subsequent events, replayed duplicate (same txHash → no-op), compensating rollback (lastTxHash cleared → event re-applied), address normalisation, own-transaction lifecycle (connect / commit / release / rollback), and cache invalidation assertions. - Add indexer/src/cli/reconcile-users.command.ts Standalone CLI that recomputes user aggregates (totalTicketsBought, totalRafflesEntered, totalRafflesWon, totalPrizeXlm, firstSeenLedger) from the tickets + raffles tables and compares them against the stored user rows. Supports --dry-run (report only, exit 2 on drift), --fix (rewrite drifted rows, nulls lastTxHash with maintenance-window caveat documented), and --address <G...> (single-address scope). - Add users:reconcile script to indexer/package.json
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.
Summary
Closes #1593
user.processor.ts(235 lines) had no spec while the raffle and ticketprocessors both did. User aggregates underpin the leaderboard and creator
profiles — double-counting from a replayed event or an uncompensated reorg
corrupts them permanently.
Changes
indexer/src/processors/user.processor.spec.ts(new, 25 tests)indexer/src/cli/reconcile-users.command.ts(new)Recomputes all five aggregate columns from
tickets+rafflesand diffsagainst stored
usersrows.indexer/package.jsonAdded
users:reconcilescript.Test results
25/25 passing. The 12 lint errors in CI are pre-existing parserOptions.project
failures on integration files excluded from tsconfig — zero issues in the two
new files.