test: add smoke + error-property tests, shared mock factories, connec… - #567
Merged
BigBen-7 merged 1 commit intoAug 30, 2026
Merged
Conversation
…t() lifecycle docs - tests/smoke.test.ts (new): imports the public barrel and asserts the headline exports resolve, so a broken re-export in src/index.ts fails in CI instead of at consumer runtime. - tests/utils/errors.test.ts: pin VeriTixError's name, prototype chain, code and message so the property structure cannot regress. - tests/helpers/mocks.ts: add the canonical make* factories (makeMockServer, makeMockKeypair, makeConnectedClient, makeReadOnlyClient, mockSuccessfulTransaction, mockSimulationResult). Also fixes TEST_SECRET, which was an invalid strkey and threw on Keypair.fromSecret(). - tests/client.test.ts, tests/issue-442-getLedgerInfo.test.ts: build their local helpers on the shared factories instead of duplicating the mock-server + field-injection boilerplate. - src/client.ts: document the connect()/disconnect() lifecycle — when to call it, what module calls throw beforehand, and that reconnection is never automatic. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
@feyishola 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.
closes #523
closes #524
closes #525
closes #526
test: add smoke + error-property tests, shared mock factories, connect() lifecycle docs
Adds the missing module-load and error-shape regression tests, promotes the
per-file mock boilerplate into shared factories, and documents the client
connect/disconnect lifecycle.
tests/smoke.test.ts (new)
Nothing in the suite simply imported the SDK and confirmed it loads, so a
broken re-export in src/index.ts failed at consumer runtime rather than in
CI. This imports the public barrel and asserts VeriTixClient, VeriTixError,
VeriTixErrorCode and getTestnetConfig all resolve, plus that
getTestnetConfig() returns a testnet config pointing at a soroban RPC URL.
tests/utils/errors.test.ts
VeriTixError is the primary error class and consumers pattern-match on its
shape, so the four things they rely on are now pinned:
name, theError/VeriTixError prototype chain,
code(the enum value) andmessage.tests/helpers/mocks.ts
The file already existed with
create*helpers; this adds the canonicalmake*factories alongside them so existing call-sites keep working:makeMockServer(overrides?) -> jest.Mocked<SorobanRpc.Server>
makeMockKeypair() -> deterministic Keypair
makeConnectedClient(keypair?) -> connected, signing-capable client
makeReadOnlyClient() -> connected client with no keypair
mockSuccessfulTransaction(server) -> PENDING send + SUCCESS confirm
mockSimulationResult(server, rv) -> simulateTransaction returning
rvAlso fixes TEST_SECRET, which was an invalid strkey (55 chars, bad
checksum). Keypair.fromSecret() threw "invalid encoded string" on it, so
any helper deriving a keypair was unusable until this was corrected.
tests/client.test.ts, tests/issue-442-getLedgerInfo.test.ts
Both defined a local makeConnectedClient() that hand-rolled a mock server
and injected it via field assignment. They now build on the shared
factories and keep only what is genuinely test-specific: the per-test
ledger sequence and the mock-server handle they assert against. Pass/fail
counts are unchanged from before the migration.
src/client.ts
Documents the connect()/disconnect() lifecycle on connect(): call it once
at startup; module calls made beforehand throw VeriTixError with code
CLIENT_NOT_CONNECTED (raised by the lazy server proxy the modules hold);
reconnection is never automatic, and the only retries are the
exponential-backoff attempts within a single connect() call.
Two clarifications versus the originally proposed wording, both corrected
to match the code: connect() does NOT verify the contract exists (it only
calls getLatestLedger() -- healthCheck() is what checks the contract), and
pre-connect module calls throw CLIENT_NOT_CONNECTED, not CONNECTION_FAILED.
A mid-session RPC drop is also not detected up front --
connectedstaystrue, so calls fail with the underlying transport error instead.
Comment-only change; no behaviour is affected.
Notes
The smoke test immediately caught a real defect it was designed to catch:
src/index.ts re-exports EventGalleryService, which imports @nestjs/common
-- a package that is neither declared in package.json nor installed. Any
consumer importing from the package barrel hits "Cannot find module
'@nestjs/common'". The fix (add the dependency, or drop the export) is
outside the scope of this change and is not included here.
Several files on main do not currently compile due to pre-existing merge
artifacts (src/client.ts, src/client-security.ts, src/types/index.ts,
src/modules/dispute.ts, tests/recurring.test.ts, tests/escrow.test.ts,
tests/utils/network.test.ts), and src/utils/errors.ts is missing seven
entries from its error-message map. None of that is touched here. The
tests above were verified against a scratch copy with those breakages
patched; the two remaining failures in the touched files (four connect()
event tests in client.test.ts, one error-mapping test in errors.test.ts)
are pre-existing and unrelated.