Skip to content

Add unit tests for the event deduplication guard skipping already-processed events by transaction hash and event index #734

Description

@Chucks1093

Summary

The event ingestion pipeline can receive the same event more than once if the Horizon cursor is reset or a worker restarts mid-batch. The deduplication guard should detect already-processed events by their (txHash, eventIndex) composite key and skip them without writing a duplicate row.

Scope

  • Test an event with a new (txHash, eventIndex) pair is inserted successfully
  • Test an event with an already-seen (txHash, eventIndex) is skipped and returns { skipped: true }
  • Test two events sharing the same txHash but different eventIndex values are both inserted
  • Test the deduplication check is performed before any other processing (no side effects on skip)
  • Assert the total event count in the database is unchanged after processing a duplicate

Acceptance Criteria

  • New event pair inserted successfully
  • Duplicate pair skipped with { skipped: true }
  • Same tx hash with different event index treated as two distinct events
  • No side effects (balance updates, logs) triggered on a skipped event
  • Database event count unchanged after duplicate is skipped

ETA: 12 hours


Coordinate on Telegram

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions