Skip to main content

assume

def assume(condition: bool) -> None:

assume(condition) skips testing against the given example if the condition is False.

danger

This cheatcode is only available in fuzz tests.

Example
%lang starknet

@external
func test_function_that_takes_nonzero_argument(value) {
%{ assume(ids.value != 0) %}

// ...

return ();
}
tip

The assume cheatcode should only be used for narrow checks dependent on logic written in Cairo, as it can slow down the tests significantly due to the need for more specific inputs. If the condition is independent of the test code, using the filter method on fuzzing strategies is preferred. If you need to restrict example space by a vast range, consider using more sophisticated fuzzing strategies instead.