Skip to content

test(stellar): cover signing rejection classification#500

Merged
Jagadeeshftw merged 2 commits into
Fluxora-Org:mainfrom
Opulencechuks:test/tx-rejected-mapping
Jun 29, 2026
Merged

test(stellar): cover signing rejection classification#500
Jagadeeshftw merged 2 commits into
Fluxora-Org:mainfrom
Opulencechuks:test/tx-rejected-mapping

Conversation

@Opulencechuks

Copy link
Copy Markdown
Contributor

This PR closes #447
PR Description

Summary

This PR hardens the handling of Freighter signing errors for Stellar transactions.
The previous implementation relied on brittle string‑matching of user‑visible messages, which could misclassify genuine RPC/signing failures when the Freighter UI or localization changes.
A dedicated utility now maps structured Freighter error codes, with a fallback keyword heuristic, and comprehensive tests protect against regression.

Changes

  • src/lib/stellar/tx.ts
    • Added mapFreighterSigningError utility with detailed TSDoc explaining the mapping logic and fallback.
    • Refactored the signing catch block to invoke this utility, checking for the user_rejected error code before keyword matching.
  • src/lib/stellar/__tests__/tx.test.ts
    • Added unit tests for each rejection keyword (reject, decline, cancel, dismiss) ensuring the resulting TransactionError.type is "rejected".
    • Added a test for a non‑matching error confirming it falls back to generic handling.
  • Documentation
    • Updated inline TSDoc to describe the keyword list and the structured error fallback, aiding future maintenance.
  • Security
    • No signed XDR or wallet secrets are logged during error classification.

Test plan

  • npm run build passes (type‑check + production build)
  • npm run test passes (all unit tests green)
  • npm run test:coverage passes (statements/branches/functions/lines ≥ 95%)
  • New code is covered by tests; the coverage include list in vitest.config.ts is expanded if new production modules are added

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

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

@Jagadeeshftw

Copy link
Copy Markdown
Contributor

the tests covering signing rejection classification fill an important gap -- it's easy for that mapping logic to drift silently without coverage. having explicit cases for user-cancelled, timeout, and network-error paths makes the stellar tx layer much more trustworthy. nice work.

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.

Add an explicit accept/reject test for the TransactionError "rejected" mapping in stellar/tx.ts signing

3 participants