Skip to content

Add edge-case tests for Decimal i128 range and ReDoS-safe parsing #354

@thlpkee20-wq

Description

@thlpkee20-wq

Description

src/lib/decimal.ts validates decimal strings against POSITIVE_DECIMAL_REGEX and range-checks against I128_MAX/I128_MIN for Soroban compatibility, but the boundary cases (exactly I128_MAX, overflow by one, 18 vs 19 fractional digits, ReDoS-style inputs) need explicit tests. Expand src/lib/decimal.test.ts to cover them.

Requirements and context

  • Must be secure, tested, and documented
  • Should be efficient and easy to review
  • Relevant code: src/lib/decimal.ts, src/lib/decimal.test.ts
  • Inputs exceeding 18 fractional digits or i128 range must throw a structured AppError

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/decimal-i128-boundaries
  • Implement changes
    • Add tests for values at and just beyond I128_MAX
    • Assert rejection of .5, leading-zero, and 19-digit fractions
    • Add a long-repetition input to confirm bounded-time parsing
  • Validate security and correctness assumptions

Test and commit

  • Run tests
    • npm test
  • Cover edge cases
    • Scaling to Stellar 7-decimal precision, zero, max precision, overflow on conversion
  • Include test output and notes

Example commit message

test: cover Decimal i128 range and parsing edge cases

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions