Skip to content

test(sdk): cover waitForConfirmation polling and timeout#371

Open
giftexceed wants to merge 1 commit into
tributary-protocol:mainfrom
giftexceed:test/wait-for-confirmation-coverage
Open

test(sdk): cover waitForConfirmation polling and timeout#371
giftexceed wants to merge 1 commit into
tributary-protocol:mainfrom
giftexceed:test/wait-for-confirmation-coverage

Conversation

@giftexceed

Copy link
Copy Markdown

What

Adds test coverage for waitForConfirmation in sdk/src/index.ts, which polls RPC for a transaction's status and previously had none. It's small but on the critical path for every payment UI.

Tests

The RPC server's getTransaction is stubbed (via t.mock.method on rpc.Server.prototype, auto-restored per test) so no network is used. Poll/timeout values are tiny so the suite runs in milliseconds. Coverage:

  • Immediate success — returns the successful response on the first poll.
  • Immediate failure — returns the failed response on the first poll.
  • Pending then success — a NOT_FOUND response is polled past until SUCCESS arrives (verifies polling).
  • Timeout — throws once the deadline passes when the transaction never resolves.

Notes

  • One concern; tests only, no behaviour change.
  • npm run build and npm test pass in sdk/.

Closes #334

waitForConfirmation is on the critical path for every payment UI but had
no test coverage. Add tests that stub the RPC server's getTransaction and
exercise the four behaviours: immediate success, immediate failure, a
pending response followed by success (polling), and throwing once the
timeout deadline passes.

Closes tributary-protocol#334
@giftexceed
giftexceed requested a review from Spagero763 as a code owner July 22, 2026 16:03
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.

Add test coverage for waitForConfirmation in the SDK

1 participant