Property-based testing for Fe
Write a property as a Fe function. Fuzzloom tries 10,000 inputs on it inside Fe, shrinks every failure and checks that the EVM and native backends agree.
Every failing property, shrunk and saved
A failing property becomes a record in .fuzzloom/failures, holding the smallest input that still fails. After the fix, replay runs every record again and marks it Fixed.
Read about saved failures- VMprop_withdraw_never_overdrawsbalance 0, amount 1Openprop
- VMprop_fee_matches_exact_mathamount 614891469123651721Openprop
- VMprop_redeem_rounds_toward_vaultshares 1, assets 0, supply 1Openprop
- VMprop_share_price_definedassets 0, supply 0 · Panic 0x12Openabort
- TLprop_transfer_conserves_supplyamount 0, to_bob false · Panic 0x11Openabort
- TLprop_vested_never_exceeds_totalstart 1668464001 · Panic 0x11Openabort
- VMdiff_rounding_modex 15398200176277126999Opendiff
/// Whether a withdrawal of `amount` from `balance` is allowed.
///
/// PLANTED BUG (off by one between two arguments): `<=` against
/// `balance + 1` admits a withdrawal one unit larger than the balance.
/// Fix: `amount <= balance`.
pub fn can_withdraw(_ balance: u128, _ amount: u128) -> bool {
if balance == u128::max() {
return true
}
amount <= balance + 1
}
/// An allowed withdrawal never exceeds the balance.
pub fn prop_withdraw_never_overdraws(_ balance: u128, _ amount: u128) -> bool {
!can_withdraw(balance, amount) || amount <= balance
Fuzzloom campaigns in 3 steps
-
The property, written in Fe
Any pub fn named prop_ that returns bool. Effects come from your fixture functions; a doc comment can restrict a range.
-
The aborting input, found by fuzzing
10,000 inputs, one in four from the edges of its type. Fe cannot catch a panic, so the input is recovered by search and shrunk by replay.
-
The fixed property, checked by replay
Each failure stays in .fuzzloom/failures. After the fix, fuzzloom replay runs them all again, and later campaigns mutate them.
Differential testing of sonatina and native
Every diff_ function runs 100,000 inputs on both backends. One test per backend returns 256 checkpoint digests, so the first differing input is pinned in 8 fe runs.
vault-math, seed 7: input 269
sonatina returns 1539820017627712699
native returns 1539820017627712700
Results on the examples
Both examples ship with their planted bugs. CI reruns them on every push and checks that seed 7 still finds the same results.
6
planted bugs found and shrunk
8
fe runs to pin a backend divergence
94
Fe tests on both backends
56 kB
npm package, no dependencies
Does a passing campaign prove the property?
No. It means 10,000 inputs found nothing, and the report says which edges they reached.
Does it need fe 26.6?
Yes. npx fuzzloom doctor checks the version and that the library compiles with it.
Does the fuzzing run on Windows?
Yes. Native tests run inside WSL.
Can a property use effects?
Yes, through one fixture_ function per effect, built fresh for every input.
Where do saved failures go?
To .fuzzloom/failures, one JSON record each. Commit them: replay re-checks them all.
What is the price?
Nothing. It is open source under the Apache License 2.0.
Runs on Node 22 and fe 26.6
npx fuzzloom needs Node 22.18 and fe 26.6. JUnit reports drop into any CI; native tests run on Linux, macOS, or through WSL on Windows.
npx fuzzloom doctor checks every piece and prints the fix for anything missing.