Skip to content

test: add unit tests for event dedup guard by txHash and eventIndex - #746

Closed
stableprogrammer wants to merge 1 commit into
accesslayerorg:mainfrom
stableprogrammer:test/event-dedup-guard-734
Closed

test: add unit tests for event dedup guard by txHash and eventIndex#746
stableprogrammer wants to merge 1 commit into
accesslayerorg:mainfrom
stableprogrammer:test/event-dedup-guard-734

Conversation

@stableprogrammer

@stableprogrammer stableprogrammer commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

What

Adds 17 unit tests for the (txHash, eventIndex) deduplication guard in the event ingestion pipeline.

Why

The pipeline can receive the same event more than once when the Horizon cursor resets or a worker restarts mid-batch. These tests verify the guard correctly skips duplicates without writing side effects.

Tests added

src/modules/indexer/event-dedup-guard.unit.test.ts — 17 tests covering:

  • New (txHash, eventIndex) pair is processed — handler called once, record written
  • Duplicate pair is skipped — handler not called, DB count stays at 1
  • Same txHash with different eventIndex treated as two distinct events, both written
  • No side effects (balance update, price snapshot) fire on a skipped duplicate
  • Mixed batches: only unique pairs reach the handler
  • Edge cases: empty batch, eventIndex 0, case-sensitive txHash, large index values

…ccesslayerorg#734)

17 tests covering: new pair processed once, duplicate skipped with no
handler call, same txHash different eventIndex treated as distinct,
no side effects on skip, DB count unchanged after duplicate, edge cases.
@stableprogrammer

Copy link
Copy Markdown
Contributor Author

Closing to reopen with complete implementation and full description.

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.

2 participants