Skip to content

test: add tests for submitTransaction and getTransactionStatus - #345

Merged
Just-Bamford merged 1 commit into
Sorokit:mainfrom
Trovic1:test/issue-249-submit-getStatus
Jul 29, 2026
Merged

test: add tests for submitTransaction and getTransactionStatus#345
Just-Bamford merged 1 commit into
Sorokit:mainfrom
Trovic1:test/issue-249-submit-getStatus

Conversation

@Trovic1

@Trovic1 Trovic1 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #249

Adds comprehensive test coverage for submitTransaction (src/transaction/submitTransaction.ts) and getTransactionStatus (src/transaction/status.ts) in a new file src/tests/transaction-submit-status.test.ts.

How the mocks work

  • createHorizonServer from src/shared/serverFactory is mocked via �i.mock('../shared/serverFactory') returning a controlled object with submitTransaction and ransactions().transaction().call() fns — both are �i.fn() so each test can set its own resolved/rejected value without any network calls.
  • TransactionBuilder.fromXDR is kept real for submitTransaction tests so the actual passphrase-mismatch detection logic runs against real signed XDRs.
  • Hoisted helpers (mockSubmit, mockTransactionCall) are declared with �i.hoisted() so they are available before �i.mock is hoisted by Vitest.

Acceptance criteria coverage

submitTransaction

  • ✅ Successful submission returns { status: 'success', hash }
  • ✅ Horizon error returns TX_SUBMIT_FAILED
  • ✅ Malformed XDR returns TX_SUBMIT_FAILED
  • ✅ Network passphrase mismatch returns TX_SUBMIT_FAILED (caught client-side, Horizon never called)
  • ✅ Cache is populated on success

getTransactionStatus

  • ✅ x.successful === true maps to 'success'
  • ✅ x.successful === false maps to 'failed'
  • ✅ ledger_attr === 0 maps to 'pending' with no ledger number
  • ✅ 404 returns TX_NOT_FOUND
  • ✅ Other errors return TX_SUBMIT_FAILED
  • ✅ Cache hit skips Horizon entirely
  • ✅ Successful lookup is written to cache

@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@Trovic1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Just-Bamford
Just-Bamford merged commit 5d2a523 into Sorokit:main Jul 29, 2026
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.

submitTransaction and getTransactionStatus Have No Tests

2 participants