pcl test to run Forge-style fuzz tests against assertions across random inputs.
Prerequisites
Start with a working local assertion test, a pinned library, and the assertion profile defined by your project. Confirm an allowed case and an expected assertion rejection before varying the inputs.Example
This illustrative fragment assumes aPhyLockAssertion, a funded user1 with a 5 ether deposit, and the matching protocol fixture. It is not a standalone runnable test. Adapt it to a passing test in your project; the starter tutorial documents the separate failure in its pinned PhyLock suite.
runs = 256, the runner targets 256 accepted fuzz cases within the vm.assume() constraints. The selected profile controls the run count; rejected inputs do not count as policy tests. This example checks allowed withdrawals only. Add separate tests for intended violations and legitimate exceptions.
Use
vm.assume() to filter out invalid inputs that would cause the test to fail for reasons unrelated to your assertion logic.Best Practices
Constrain inputs to realistic ranges withvm.assume(). Include valid boundary cases and combinations of inputs that affect the policy.
Running Fuzz Tests
Fuzz tests run automatically withpcl test:
foundry.toml:
Verify the Run
Confirm that the intended fuzz tests ran under the selected profile and inspect the reported run counts, failures, and rejected-input limits. A filtered-out test provides no evidence. Preserve any failing input as a regression case and run the full assertion suite before preparing a release. Learn More:- Testing Assertions - Basic testing guide
- CI/CD Integration - Automate your tests
- Forge Fuzz Testing Documentation

