Skip to content

test: add systematic unit tests for format, network, transaction, and Soroban error utils - #573

Merged
BigBen-7 merged 1 commit into
Lead-Studios:mainfrom
khalyaro:feature/utils-test-suite
Aug 30, 2026
Merged

test: add systematic unit tests for format, network, transaction, and Soroban error utils#573
BigBen-7 merged 1 commit into
Lead-Studios:mainfrom
khalyaro:feature/utils-test-suite

Conversation

@khalyaro

Copy link
Copy Markdown
Contributor

Summary

Adds comprehensive, network-free unit coverage for the four VeriTix SDK utility areas on the test backlog:

  • tests/utils/format.test.tsstroopsToXLM / xlmToStroops boundary conversions plus a 1000-value round-trip property and a guard against scientific notation for values above Number.MAX_SAFE_INTEGER.
  • tests/utils/network.test.ts — Stellar address validation (valid G-address acceptance, empty / C-address / truncated rejection), the new allowContract option, network config factories (rpcUrl / network), Horizon URL helper, and ledger math helpers.
  • tests/utils/transaction.test.tssubmitTransaction polling behaviour: immediate rejection on FAILED, retry-then-success on NOT_FOUND, TIMEOUT after maxPollAttempts, rate-limit retry, read-only rejection, and RPC hash-mismatch detection.
  • tests/utils/errors.test.ts — systematic parseSorobanError mapping across every parseable VeriTixErrorCode (including case-insensitive and embedded-pattern matching), plus VeriTixError shape (code, rawMessage/raw alias, cause).

Supporting source adjustments

  • errors: added HostError, TrappedVmError, UnexpectedTransactionHash and UnknownContractError codes (keeping legacy Unknown as a value alias); parseSorobanError now populates raw/cause, avoids double-wrapping existing VeriTixErrors, and maps catch-all host / diagnostic strings (including camelCase InvalidInput) to typed codes.
  • network: assertValidAddress now accepts a Soroban contract ID when allowContract is enabled, while still rejecting C-addresses by default.
  • transaction: an RPC hash mismatch now throws UnexpectedTransactionHash instead of the generic Unknown.

Closes #476
Closes #477
Closes #478
Closes #479

…on, and soroban errors

Adds comprehensive unit coverage for the four utility areas on the test backlog:

- tests/utils/format.test.ts: stroop<->XLM conversion boundaries plus a
  1000-value round-trip property (also guards against scientific notation
  for values above Number.MAX_SAFE_INTEGER).
- tests/utils/network.test.ts: Stellar address validation, the
  allowContract option, network config factories, Horizon URL, and ledger
  math helpers.
- tests/utils/transaction.test.ts: submitTransaction polling, immediate
  FAILED rejection, NOT_FOUND retry, TIMEOUT after max polls, rate-limit
  retry, and RPC hash-mismatch detection.
- tests/utils/errors.test.ts: systematic parseSorobanError mapping across
  every parseable VeriTixErrorCode, plus VeriTixError shape (raw, cause).

Supporting source adjustments:
- errors: add HostError, TrappedVmError, UnexpectedTransactionHash and
  UnknownContractError codes; populate cause/raw when wrapping; extend
  the panic map (including camelCase InvalidInput and catch-all host
  strings) so real RPC diagnostics map to typed errors.
- network: assertValidAddress now accepts contract IDs when
  allowContract is true.
- transaction: hash mismatch throws UnexpectedTransactionHash instead of
  generic Unknown.

Closes Lead-Studios#476
Closes Lead-Studios#477
Closes Lead-Studios#478
Closes Lead-Studios#479
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@khalyaro 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

@BigBen-7
BigBen-7 merged commit 2544ba0 into Lead-Studios:main Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment