Skip to content

test: expand stellarRpcFailure Horizon result-code coverage#361

Open
samueloyibodevv wants to merge 1 commit into
RevoraOrg:masterfrom
samueloyibodevv:test/stellar-failure-result-codes
Open

test: expand stellarRpcFailure Horizon result-code coverage#361
samueloyibodevv wants to merge 1 commit into
RevoraOrg:masterfrom
samueloyibodevv:test/stellar-failure-result-codes

Conversation

@samueloyibodevv
Copy link
Copy Markdown

@samueloyibodevv samueloyibodevv commented May 27, 2026

Overview

This PR expands src/lib/stellarRpcFailure.test.ts to comprehensively cover Horizon extras.result_codes classification for transaction- and operation-level failures. It verifies tx_bad_seq, tx_insufficient_fee, op_no_destination, and op_underfunded, confirms shouldRetry behavior for each classified failure, and adds security assertions to ensure raw upstream messages never leak through classified output.

Related Issue

Closes #349

Changes

⚙️ Stellar Result-Code Classification Coverage

  • [MODIFY] src/lib/stellarRpcFailure.test.ts
  • Added deterministic fixtures for Horizon extras.result_codes payloads.
  • Added explicit coverage for tx_bad_seq and tx_insufficient_fee mapping to TX_RESULT_CODE.
  • Added explicit coverage for op_no_destination and op_underfunded mapping to OP_RESULT_CODE.
  • Added assertions for shouldRetry on tx/op result-code classifications.
  • Added coverage for operation-code precedence over transaction codes.
  • Added UNKNOWN fallback coverage for unrecognized and nested unsupported shapes.
  • Added edge-case coverage for missing extras, non-Error objects, and null/undefined input.

🔒 Sanitization And Security

  • [MODIFY] src/lib/stellarRpcFailure.ts
  • Hardened sanitizeError() so raw upstream message text is replaced with UPSTREAM_MESSAGE_REDACTED.
  • Preserved a narrow diagnostic shape without leaking Horizon error strings across trust boundaries.
  • Removed duplicate type/enum declarations to keep the classifier easier to review.

🧪 Related Test Alignment

  • [MODIFY] src/routes/payouts.test.ts

  • Updated existing assertions to match the classifier’s structured return shape.

  • Added security checks confirming redacted classified output is not the raw upstream object.

  • [MODIFY] src/__tests__/stellarRpcFailure.integration.test.ts

  • Updated the logger mock to include .child().

  • Aligned the long-message sanitization expectation with the redacted behavior.

📘 Documentation

  • [MODIFY] docs/payouts-stellar-result-codes-retry-storms.md
  • Documented the expanded Horizon result-code coverage and the message-redaction security guarantee.

Verification Results

Acceptance Criteria Status
Covers tx_bad_seq classification
Covers tx_insufficient_fee classification
Covers op_no_destination classification
Covers op_underfunded classification
Asserts shouldRetry for tx/op result-code failures
Asserts UNKNOWN fallback for unrecognized shapes
Asserts raw upstream messages do not leak
Targeted classifier-related tests pass

Screenshots

✅ Targeted test run

A screenshot of:

npm test -- --runInBand src/lib/stellarRpcFailure.test.ts src/routes/payouts.test.ts
image

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

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

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.

Expand stellarRpcFailure classification tests to cover Horizon tx/op result codes

1 participant