protostar icon indicating copy to clipboard operation
protostar copied to clipboard

Add strategy.comparable()

Open mkaput opened this issue 3 years ago • 0 comments

Add and document a new fuzzing strategy:

def strategy.comparable(
    min_value: Optional[int] = None,
    max_value: Optional[int] = None,
): ...

That will behave exactly the same as the existing integers strategy, but will limit explored range (no matter if unbound or specified by min_value/max_value arguments), to range_check_builtin.bound values, as Cairo stdlib comparison functions expect.

The goal is to let users not have to worry about values exceeding the range check in this builtin functions.

Consider making this the default strategy for felt parameters.

Consider extending the fuzzing tutorial in docs to use this strategy as a new step to simplify the test from having to expect_revert range overflow. If that makes sense (it doesn't have to).

mkaput avatar Aug 04 '22 13:08 mkaput