test: add property-based tests for XDR transaction builder - #796
Merged
Nanle-code merged 1 commit intoJul 29, 2026
Merged
Conversation
…t boundaries
- Add fast-check as a devDependency for property-based testing
- Create transactionBuilder.property.test.ts with property-based tests:
* XDR round-trips: payment, createAccount, changeTrust transactions
* Amount boundary rejection: zero, negative, infinity, NaN, extreme values
* Memo boundary handling: valid text/id/hash/return memos and invalid
oversized/hash-length-mismatch rejection
* Time bounds round-trip through XDR serialization
* Operation set boundaries: 1-10 operations, mixed operation types
- Each property test runs 50-200 random iterations with fast-check
generators for public keys, amounts, memos, and time bounds
Closes Nanle-code#785
|
@jaymoneymanxl is attempting to deploy a commit to the nanle-code's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@jaymoneymanxl 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! 🚀 |
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.
Closes #785
Problem
The
TransactionBuilderand related XDR serialisation modules lacked property-based (fuzz) testing. Unit tests cover specific known cases, but they don't explore the vast space of valid and invalid inputs that real-world usage can produce, such as:u64::MAX, extreme decimals).maxTime < minTime.Without property-based tests, regressions in XDR round-trip encoding/decoding or input validation can slip through.
Changes
src/lib/__tests__/transactionBuilder.property.test.ts(new)Install
fast-checkas a devDependency and add the following property tests, each running 50–200 random iterations:1. XDR Round-Trips (
xdrRoundtrip)Transactionwith 1–10 operations, each of typepayment,createAccount, orchangeTrust.2. Amount Boundary Rejection (
amountBoundaries)0, negative numbers,Infinity,-Infinity,NaN, extreme floats (>u64::MAX), non-integer decimals.TransactionBuilder.isValidAmount()returnsfalsefor every invalid input.u64::MAX) and verifies they returntrue.3. Memo Boundary Handling (
memoBoundaries)u64range), hash memos (exactly 32 bytes), and return hash memos.Memo.toXDR()/Memo.fromXDR()without error.4. Time Bounds Round-Trip (
timeBoundsRoundtrip)minTime/maxTimepairs whereminTime <= maxTime.minTime > maxTimepairs are rejected.5. Operation Set Boundaries (
operationSetBoundaries)package.jsonfast-check: ^3.xdevDependency.Verification
npx vitest run src/lib/__tests__/transactionBuilder.property.test.ts→ all 5 property suites pass.