Skip to content

Write unit tests for event worker XDR decoding and event handlers #368

@ogazboiz

Description

@ogazboiz

Join our community: https://t.me/+DOylgFv1jyJlNzM0

Description

The decodeU64, decodeI128, decodeAddress, decodeMap helpers and all event handlers in the event worker have no tests. A subtle decoding bug would silently corrupt all indexed stream data.

Test Cases Needed

  • test_decodeU64_max_value
  • test_decodeI128_positive, test_decodeI128_negative, test_decodeI128_max_i128
  • test_decodeAddress_g_address (account key)
  • test_decodeAddress_c_address (contract ID)
  • test_handleStreamCreated_writes_correct_db_record (mock Prisma)
  • test_handleStreamToppedUp_updates_deposited_amount
  • test_handleStreamCancelled_sets_inactive
  • test_handleStreamPaused_sets_isPaused (once handlers added)
  • test_unknown_event_type_silently_ignored

Files

  • backend/tests/soroban-event-worker.test.ts (create)

Acceptance Criteria

  • All tests pass with mocked Prisma
  • Edge values (max i128, negative, C... addresses) covered
  • Runs in npm test

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related taskstestingTesting 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