Repository navigation
test: property-test USDC unit conversion round trips - #1436
AkpakaProsper wants to merge 3 commits into
Conversation
|
@AkpakaProsper Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Thanks for the contribution! We reviewed this PR while merging the open queue and couldn't merge it yet. Here's what needs fixing:
Once these are fixed, push to this branch and we'll take another look. |
|
@greatest0fallt1me thanks for the review — pushed a fix to this branch. What changed:
Head: |
…roperties The new fast-check properties were asserting against local copies of parseUsdcToContractUnits / formatContractUnitsToUsdc, so they could pass even if the production converter regressed. Import the real helpers from src/services/billing.ts (billingInternals) instead. All 11 tests in the file still pass, including the 10k-case round trip.
|
@greatest0fallt1me Thanks for the review — checked both points against the current head:
One genuine gap fixed: the new USDC property tests asserted against local copies of Verification:
Could you take another look? |
Overview
This PR adds fast-check property tests for the USDC unit conversion helpers in
src/services/billing.ts(parseUsdcToContractUnits/formatContractUnitsToUsdc, exposed viabillingInternals). It locks in the 7-decimal precision invariants that example-based tests only sampled: round-trip normalisation, rejection of over-precise and negative inputs, zero handling, and precision preservation for very large whole numbers.Related Issue
Changes
🧪 Property Tests
[ADD]
tests/unit/amountValidator.property.test.tsformat(parse(x))round-trip property over 10k generated valid amounts (0–7 fractional digits), asserting the formatted output normalises the input (no trailing zeros, no lost precision).0throws'must be greater than zero'.[MODIFY]
src/__tests__/billing-credits.test.ts[MODIFY]
src/__tests__/billing-index.test.tsbillingInternalssurface (used by the property tests) verified.Verification Results
Security and Failure Modes
'must be greater than zero'message, keeping the guard explicit and observable.Compatibility
fast-checkwas already a devDependency, so no install changes are required.Closes #1313