Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sometimes assertions #450

Open
0xalpharush opened this issue Aug 22, 2024 · 1 comment
Open

Add sometimes assertions #450

0xalpharush opened this issue Aug 22, 2024 · 1 comment

Comments

@0xalpharush
Copy link
Contributor

A common issue is not knowing whether some state is being reached effectively and wanting greater insight into execution statistics (see this issue #431 and PR with some progress here #364)

We can add "tests" that fail if they are not successful some percentage of the time (TBD if configuring this is desirable) by making the fuzzer monitor the success/fail rate. By encouraging a pattern like the following, they should get put in the corpus, but we could consider prioritizing them as well.

function fuzz() external {
bool result = ...
emit sometimesTrue(result); // fail if never true
....
}

function sometimesSucceeds() external { // fail if always reverts
... 
}

This is effectively asserting that some path of the code is reached. Some test harnesses/fuzzers will let you mark a line of code as expected to be reached by a given input, for example. That way it is clear the harness/test was not invalidated or regressed to a point that it's no longer effective thereby serving as a "fuzz canary", alerting devs of trouble in the mines.

See also https://antithesis.com/docs/best_practices/sometimes_assertions.html

@bsamuels453
Copy link

crytic/echidna#880

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants