test: property-based coverage for amount validator#595
Open
Ope4196 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: Property-based tests for amountValidator (Stellar/USDC precision)
Summary
Adds 11 fast-check property-based tests to
src/validators/amountValidator.test.ts, expanding coverage beyond the existing unit tests to fuzz fractional precision, leading zeros, negative sentinels, and denormalized number strings so silent regressions are caught automatically.Changes
Modified files
src/validators/amountValidator.test.ts— added 11fc.propertytests (PBT-1 through PBT-11), all with pinned seeds for determinismProperties covered
normalizedAmountequals input for valid amountstoSmallestUnitstroop → string → stroop round-tripN.0000000) round-triptoSmallestUnitalways returns positive bigintDesign notes
fc.assertcalls use{ seed: 1234567 }for reproducibility — no flaky seedsvalidAmountArbgenerates amounts from stroop integers viastroopsToCanonical, guaranteeing exact IEEE 754 representation with no precision lossnumRunskept to 200–500 per property; total runtime well under 5 sfast-checkis already a devDependency — no new dependencies addedValidation
npm test -- --testPathPattern=amountValidatorcloses #420