Skip to content

test: add MockNetworkConditions latency/failure injection utility (closes #443) - #543

Open
bilhokista wants to merge 1 commit into
Nodal-stellar:mainfrom
bilhokista:test/mock-network-conditions-443
Open

test: add MockNetworkConditions latency/failure injection utility (closes #443)#543
bilhokista wants to merge 1 commit into
Nodal-stellar:mainfrom
bilhokista:test/mock-network-conditions-443

Conversation

@bilhokista

Copy link
Copy Markdown

Closes #443. Stellar Wave complexity 150 applicant: bilhokista.

Changes

  • NEW tests/helpers/MockNetworkConditions.ts: applyConditions({ latencyMs, failureRate, errorType }) over vi.fn mocks or { object, method } targets, plus reset(). Fake-timers compatible (plain setTimeout promise).
  • tests/payment.test.ts: slow-network payment demo block (1500ms latency succeeds; failureRate 1 rejects; reset restores).

Verification

  • tsc --noEmit: clean
  • vitest run tests/payment.test.ts: 59/59 pass (57 existing + 2 new)
  • prettier --write applied; eslint: 0 errors (25 pre-existing as-any warnings in file, untouched)
  • Isolated to tests/, zero production changes

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.

[Test] Build MockNetworkConditions utility for injecting latency and failures in tests

1 participant