-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Component
Forge
Describe the feature you would like
see convo foundry-rs/forge-std#584 (comment)
Additional context
-
The uint and int strategies should take an option with min / max bound values
foundry/crates/evm/fuzz/src/strategies/uint.rs
Lines 96 to 109 in 2b39094
impl UintStrategy { /// Create a new strategy. /// #Arguments /// * `bits` - Size of uint in bits /// * `fixtures` - A set of fixed values to be generated (according to fixtures weight) pub fn new(bits: usize, fixtures: Option<&[DynSolValue]>) -> Self { Self { bits, fixtures: Vec::from(fixtures.unwrap_or_default()), edge_weight: 10usize, fixtures_weight: 40usize, random_weight: 50usize, } }
which should be enforced on value tree current values
foundry/crates/evm/fuzz/src/strategies/uint.rs
Lines 46 to 48 in 2b39094
fn current(&self) -> Self::Value { self.curr } -
the
randomUint
/randomInt
cheatcodes should reuse the UintStrategy/IntStrategy to apply bounds (PR feat(cheatcodes): random* cheatcodes to aid in symbolic testing #8882 is updating these cheatcodes to use proptest strategies) -
for fuzzed tests we could use the inline config as suggested in feat: add boundLog to enable log-uniform sampling forge-std#584 (comment)
/// forge-config: default.fuzz.range.y = [1, 10];
function testFoo(uint256 x, uint256 y) public {
and pass the min / max bound values to UintStrategy/IntStrategy
- tests should make sure that, if fuzzing over a large space, logarithmic uniformity is preferred, whereas if fuzzing a uint8 then standard uniform sampling is preferred
Metadata
Metadata
Assignees
Labels
Type
Projects
Status