Skip to main content
Use Forge’s fuzz tests to check assertion behavior across random inputs.

Example

This would run the test with 256 different values for withdrawalAmount that adhere to the bounds set by the vm.assume() constraints.
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 with vm.assume(). Include valid boundary cases and combinations of inputs that affect the policy.

Running Fuzz Tests

Fuzz tests run automatically with pcl test:
You can configure the number of runs in your foundry.toml:
Consider creating a separate profile for fuzz tests so they don’t run during quick local development cycles. See CI/CD Integration for complete profile configuration examples.
Learn More: