Skip to content

test(utils): cover Stellar memo limits, decimal rounding, and asset code validation - #2222

Open
maxx-GENIUS wants to merge 1 commit into
LabsCrypt:mainfrom
maxx-GENIUS:test/stellar-memo-amount-parsing-2089
Open

maxx-GENIUS wants to merge 1 commit into
LabsCrypt:mainfrom
maxx-GENIUS:test/stellar-memo-amount-parsing-2089

Conversation

@maxx-GENIUS

Copy link
Copy Markdown

Summary

This PR adds comprehensive unit test coverage and utility helpers for Stellar memo byte limits, decimal rounding, and asset code validation in backend/src/utils/stellar.ts and backend/src/utils/__tests__/stellar.test.ts.

Closes #2089

Details of Changes

  • Stellar Memo Validation (isValidStellarMemo / assertValidStellarMemo):
    • Enforces the 28-byte protocol boundary using UTF-8 byte counting (Buffer.byteLength).
    • Validates boundary cases (empty string, 28 bytes ASCII, multi-byte UTF-8 emojis exceeding 28 bytes) and non-string inputs.
  • Asset Code Validation (isValidAssetCode / assertValidAssetCode):
    • Validates 1-12 alphanumeric characters (AlphaNum4, AlphaNum12, native, XLM).
    • Rejects asset codes exceeding 12 characters, containing spaces, special characters, or invalid types.
  • Decimal Rounding & Amount Parsing (formatStellarAmount / parseStellarAmount):
    • Formats amounts with exact 7-decimal precision (stroops representation).
    • Applies standard half-up decimal rounding to eliminate floating-point drift.
    • Rejects negative, NaN, or non-finite inputs.

Verification & CI Proof

  • npm run lint: Passed (0 errors)
  • npm run build: Passed (0 errors)
  • npm test -- src/utils/__tests__/stellar.test.ts: 16/16 tests passing (100% green)

@github-actions github-actions Bot added the security:malware-suspected Automated malware indicator found in a pull request label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

Malware detection scan flagged this pull request

The scan found 1 indicator(s) in the PR diff. This PR is blocked until a maintainer reviews the flagged files.

  • backend/src/utils/stellar.ts — hidden-appended-config-payload (high)

This is an automated triage signal; maintainers must verify whether the finding is malicious or intentional.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security:malware-suspected Automated malware indicator found in a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[test] Cover Stellar memo and amount parsing

1 participant