Skip to content

Add a property-based test suite for validateStellarAddress and validatePercentages in lib/validation #485

@Baskarayelu

Description

@Baskarayelu

📋 Description

lib/validation/percentages.ts exports validatePercentages (must sum to 100, non-negative) and validateStellarAddress (regex ^G[A-Z0-9]{55}$). There is an existing property test file at tests/property/validation-properties.test.ts and a test:property script, but coverage of these two functions' invariants and adversarial inputs is incomplete.

Why this matters: these validators sit on the money path (allocation gating, recipient acceptance). A weak charset/length check on the address regex can accept malformed keys; a float-tolerance bug on percentages can let a non-100 split through.

🎯 Requirements & Context

Functional requirements

  • Extend tests/property/validation-properties.test.ts (run via npm run test:property) with generated cases for validatePercentages: random 4-tuples, asserting it accepts iff sum≈100 and all non-negative.
  • Add adversarial cases for validateStellarAddress: wrong prefix, wrong length (55/57), lowercase, illegal characters, empty/non-string.
  • Note any discrepancy between this server regex and the stricter base32 + StrKey checksum used in RecipientAddressInput, and document the intended source of truth.

Context & constraints

  • Use the existing property-test harness style in the repo.
  • This is test-only; if a real validation gap is found, document it in the PR rather than silently changing behavior.

🛠️ Suggested Execution

git checkout -b test/validation-property-suite
  • Extend the property suite, add adversarial address cases, document regex-vs-checksum discrepancy.
npm run lint
npm run test:property
npm run test:coverage
  • Edge cases: sum = 99.999/100.001 (tolerance), all-zero, negative, 56 chars but bad checksum (regex passes — flag it).

Example commit message

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

Extends the property suite with generated percentage tuples and
adversarial Stellar address inputs; documents regex-vs-checksum gap.

✅ Acceptance Criteria & Guidelines

Requirement Target
Property cases for both validators Required
Adversarial address inputs covered Required
Validation coverage ≥ 95% branches
Regex-vs-checksum discrepancy documented Required
Lint clean, property suite green Required
Timeframe 96 hours from assignment

💬 Community & Support

Join the RemitWise contributor community on Discord: https://discord.gg/CtQuPZFMA

Comment to claim before starting. 🚀

Metadata

Metadata

Assignees

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions