Skip to content

[Testing] Add unit tests for backend services/indexerService.ts (getIndexerStatus / resetIndexer) #697

@ogazboiz

Description

@ogazboiz

Join the discussion on Telegram

Why this matters

backend/src/services/indexerService.ts exports getIndexerStatus, resetIndexer, replayFromLedger. These are admin-facing and destructive (resetIndexer drops the cursor; replayFromLedger triggers a re-poll), but I don't see direct unit-test coverage for them in backend/tests/.

The functions are small and mockable (they only touch prisma.indexerState and sorobanEventWorker.triggerPoll).

Acceptance criteria

  • Add backend/tests/indexer-service.test.ts
  • Mock prisma.indexerState (Vitest module mock) and sorobanEventWorker
  • Tests: getIndexerStatus returns lagSeconds=-1 when no state row, returns lagSeconds=>0 when a row exists; resetIndexer(0) upserts the row with lastCursor=null; replayFromLedger calls resetIndexer then triggerPoll
  • Coverage row in the lcov report should increase

Files to touch

  • new backend/tests/indexer-service.test.ts

Out of scope

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksgood first issueGood for newcomerstestingTesting related tasks

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions