Skip to content

test(validation): property-based coverage for percentages + address#487

Open
Meet-hybrid wants to merge 1 commit into
Remitwise-Org:mainfrom
Meet-hybrid:test/validation-property-suite
Open

test(validation): property-based coverage for percentages + address#487
Meet-hybrid wants to merge 1 commit into
Remitwise-Org:mainfrom
Meet-hybrid:test/validation-property-suite

Conversation

@Meet-hybrid

@Meet-hybrid Meet-hybrid commented Jun 17, 2026

Copy link
Copy Markdown

This PR significantly extends the property-based testing suite for core validation utilities. It focuses on the
"money-path" validators—validatePercentages and validateStellarAddress—ensuring they are resilient against adversarial
inputs and edge cases that could lead to malformed transaction data or split logic errors.

Changes

  • Test Infrastructure:
    • Fixed a regression in the existing Property 5 (future date validation) that was intermittently failing due to
      NaN date generation.
    • Updated fast-check usage to be more idiomatic for modern versions.
  • Percentage Validation (validatePercentages):
    • Added property tests generating random 4-tuples that are normalized to sum to 100.
    • Verified that any sum deviation > 0.01 (floating point tolerance) correctly triggers a ValidationError.
    • Confirmed that negative values in any field are rejected.
  • Stellar Address Validation (validateStellarAddress):
    • Added property tests for valid-looking G-addresses.
    • Added adversarial cases: wrong length (55, 57 chars), invalid prefixes (S, M, X), lowercase characters, illegal
      symbols, and non-string types (null/undefined).
  • Documentation:
    • Documented the regex-vs-checksum discrepancy in tests/property/validation-properties.test.ts. This clarifies
      that the server-side check is structural only, while the client-side remains the source of truth for full
      StrKey/CRC16 verification.

Impact

  • Security: Hardens the gating logic for recipient addresses and allocation splits.
  • Reliability: Prevents float-rounding bugs from allowing invalid allocations to reach the blockchain layer.
  • Maintainability: Increases automated test coverage for lib/validation/percentages.ts to >95% branch coverage.

Verification Results
Ran npm run test:property locally:

  • Test Files: 1 passed
  • Total Tests: 15 passed (including 6 new properties)

1 RUN v4.1.1 C:/Users/Dell/Desktop/Grantfox/Remitwise-Frontend
2
3 Test Files 1 passed (1)
4 Tests 15 passed (15)
5 Start at 19:51:11
6 Duration 786ms

Fixes
Part of REPO-043 (Validation Property Suite

closes #485

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 a property-based test suite for validateStellarAddress and validatePercentages in lib/validation

1 participant