test(indexer): add integration test for indexer resume from checkpoint after restart - #690
Merged
Chucks1093 merged 1 commit intoJul 28, 2026
Conversation
…restart Adds accesslayerorg#667 integration test covering the checkpoint-driven resume contract: * Writes a checkpoint record for ledger 5000 * Reinitialises the indexer (simulates a restart) via getResumePoint() * Asserts the indexer begins fetching from ledger 5001 * Asserts ledgers below 5001 are not reprocessed Coverage: * Primary scenario — checkpoint 5000 \u2192 resume 5001 * Most-recent-checkpoint is selected when multiple rows exist * Resume ledger is sourced from the checkpoint table, not hardcoded (verified at ledger 9999 \u2192 10000 and on empty table \u2192 0) * No ledgers below the resume point are reprocessed (pre-populated activity rows remain untouched; spy observes writes are at ledgers \u2265 resumeFrom; checkpoint table shape unchanged) Mirrors the existing ledger-checkpoint.integration.test.ts pattern: real Prisma DB + jest.spyOn for scoped read-model mocks only, so the real ledger_checkpoint connection stays intact. processTradeEvents extends prisma behind $extends; the mockImplementation on prisma.activity.create is cast to any with an inline explanatory note to satisfy the PrismaPromise return shape. Refs accesslayerorg#667
|
@omoh5 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
Resolves #667 — adds an integration test that proves the indexer resumes from
checkpoint.ledger + 1after a simulated restart, and that no ledgers below the resume point are reprocessed.The test (
src/modules/indexer/indexer-resume.integration.test.ts) writes checkpoint records into the realledgerCheckpointtable, callsgetResumePoint()to simulate the indexer on-startup behaviour, and asserts both the resume-point value and the post-restart write boundary.Acceptance Criteria Coverage
writes a checkpoint for ledger 5000 and resumes from ledger 5001 after restartafter restart at checkpoint 5000, pre-existing activity rows are untouched and only events at ledgers ≥ 5001 are writtenreturns ledger + 1 for a checkpoint at non-5000 ledger(9999 → 10_000)selects the highest ledger record and returns ledger + 1(100, 2000, 5000 → resume 5001)Design notes
ledger-checkpoint.integration.test.tspattern.jest.spyOn(notjest.mock) scopes mocks to read-model operationsprocessTradeEventstouches (activity,keyOwnership,creatorPriceSnapshot,indexedLedger). The realledgerCheckpointconnection stays intact and is the unit under test.processTradeEventsdoes not filter input events by ledger (the gating happens upstream, in the indexer polling loop). The test mirrors that contract explicitly in comments and feeds the function only events ≥ the resume point. The strongest contract assertion is the resume-point value itself (verified across 3 distinct ledger values).Running locally
Expected:
Tests: 5 passed, 5 total.Testing
pnpm exec jest src/modules/indexer/indexer-resume.integration.test.ts— 5/5 tests pass locally against a Postgres test instancepnpm exec tsc --noEmit— cleanpnpm lint— clean (test-only change, no production source touched)pnpm build— N/A (test-only change)pnpm exec prisma generate— no schema changeChecklist