test: add systematic unit tests for format, network, transaction, and Soroban error utils - #573
Merged
Conversation
…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
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds comprehensive, network-free unit coverage for the four VeriTix SDK utility areas on the test backlog:
tests/utils/format.test.ts—stroopsToXLM/xlmToStroopsboundary conversions plus a 1000-value round-trip property and a guard against scientific notation for values aboveNumber.MAX_SAFE_INTEGER.tests/utils/network.test.ts— Stellar address validation (valid G-address acceptance, empty / C-address / truncated rejection), the newallowContractoption, network config factories (rpcUrl/network), Horizon URL helper, and ledger math helpers.tests/utils/transaction.test.ts—submitTransactionpolling behaviour: immediate rejection onFAILED, retry-then-success onNOT_FOUND,TIMEOUTaftermaxPollAttempts, rate-limit retry, read-only rejection, and RPC hash-mismatch detection.tests/utils/errors.test.ts— systematicparseSorobanErrormapping across every parseableVeriTixErrorCode(including case-insensitive and embedded-pattern matching), plusVeriTixErrorshape (code, rawMessage/raw alias,cause).Supporting source adjustments
HostError,TrappedVmError,UnexpectedTransactionHashandUnknownContractErrorcodes (keeping legacyUnknownas a value alias);parseSorobanErrornow populatesraw/cause, avoids double-wrapping existingVeriTixErrors, and maps catch-all host / diagnostic strings (including camelCaseInvalidInput) to typed codes.assertValidAddressnow accepts a Soroban contract ID whenallowContractis enabled, while still rejecting C-addresses by default.UnexpectedTransactionHashinstead of the genericUnknown.Closes #476
Closes #477
Closes #478
Closes #479