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
- 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
Description
src/lib/decimal.tsvalidates decimal strings againstPOSITIVE_DECIMAL_REGEXand range-checks againstI128_MAX/I128_MINfor Soroban compatibility, but the boundary cases (exactlyI128_MAX, overflow by one, 18 vs 19 fractional digits, ReDoS-style inputs) need explicit tests. Expandsrc/lib/decimal.test.tsto cover them.Requirements and context
src/lib/decimal.ts,src/lib/decimal.test.tsAppErrorSuggested execution
git checkout -b test/decimal-i128-boundariesI128_MAX.5, leading-zero, and 19-digit fractionsTest and commit
npm testExample commit message
test: cover Decimal i128 range and parsing edge casesGuidelines