Repository navigation
test(frontend): cover Soroban network mismatch, simulation timeout and malformed RPC responses - #2195
Merged
Merged
Conversation
Adds regression coverage for LabsCrypt#2143 around the XDR builders in `frontend/src/app/utils/soroban.ts`. The suite pins the fail-closed contract of both `buildUnsignedLoanRequestXdr` and `buildUnsignedRepaymentXdr`: - the returned XDR is bound to the passphrase it was built with: the signature base carries sha256(passphrase), the same invocation hashes differently on TESTNET and PUBLIC, and a signature only verifies on the network it was produced for; - an explicit `networkPassphrase` wins over the ambient NEXT_PUBLIC_STELLAR_NETWORK_PASSPHRASE, and the shared default is used when neither is supplied; - a network mismatch reported by the RPC propagates as a rejection and no unsigned XDR is returned; - a simulation timeout (or a simulation that is still pending) rejects after exactly one attempt instead of falling back to the unprepared transaction; - malformed account and simulation responses (null, non-transaction, failed lookup, JSON-RPC error payloads) are rejected untouched; - invocations carry no pre-filled auth entries, simulation-time authorization failures propagate, and invalid amounts / contract ids / loan ids are rejected before simulating. CI now runs this suite alongside the existing loan-stream and session-expiry regression suites.
Banx17
force-pushed
the
fix/issue-2143
branch
from
October 24, 2026 04:08
f1eb75f to
128f2c2
Compare
2 tasks
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
Closes #2143.
Adds
frontend/src/app/utils/soroban.networkMismatch.test.ts, a regression suite for the two XDR builders infrontend/src/app/utils/soroban.ts(buildUnsignedLoanRequestXdrandbuildUnsignedRepaymentXdr). Every case runs against both builders, with the RPC server stubbed so the suite stays offline and deterministic.The contract the suite pins is fail closed: the builder must reject (so
transactionErrors/mapTransactionErrorcan keep classifying the failure) and must never return an unsigned XDR that was not simulated on the wallet's network.Acceptance criteria coverage
networkPassphrasebeatsNEXT_PUBLIC_STELLAR_NETWORK_PASSPHRASE; the sharedDEFAULT_NETWORK_PASSPHRASEis used when neither is given; a mismatch reported by the RPC propagates as a rejection with no XDR returned.prepareTransactioninstead of racing it.getAccountpayload rejects before simulation; a failed account lookup rejects before simulation; anullsimulation response and a non-transaction simulation payload are rejected instead of serialized; a malformed JSON-RPC error object is propagated by identity.authentries (3 contract args, the wallet signs), andHostError: Error(Auth, InvalidAction)raised during simulation propagates untouched.NaN/Infinity/1e21amounts and unparseable contract ids are rejected before simulating; the u32 term and u64 loan-id boundaries are accepted; a fractional loan id throwsSyntaxErrorinstead of being truncated, and a negative loan id is rejected as unsigned.Changes
frontend/src/app/utils/soroban.networkMismatch.test.ts— new suite, 42 assertions-level tests (21 per builder)..github/workflows/ci.yml— the existing "Frontend regression tests" step now also runs this suite, so a network/simulation regression fails CI instead of only local runs.Test plan
Notes
soroban.tsalready has, so it fails if the builders regress (droppednetworkPassphrase, serializing before/without simulation, swallowing RPC errors).frontend/src/app/components/providers/WalletProvider.tsx:249referencesNETWORK_PASSPHRASESwithout importing it, sosoroban.networkSigner.test.tsxfails withReferenceError: NETWORK_PASSPHRASES is not definedonmain. Left untouched to keep this PR scoped; happy to fix it separately if you want.