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

feat: support time-based and continuous fuzzing and invariant testing #990

Open
mds1 opened this issue Mar 19, 2022 · 7 comments
Open

feat: support time-based and continuous fuzzing and invariant testing #990

mds1 opened this issue Mar 19, 2022 · 7 comments
Labels
A-testing Area: testing C-forge Command: forge Cmd-forge-test Command: forge test P-normal Priority: normal T-feature Type: feature
Milestone

Comments

@mds1
Copy link
Collaborator

mds1 commented Mar 19, 2022

Component

Forge

Describe the feature you would like

Right now fuzz campaigns are defined by their number of runs. It’s also useful to instead define campaigns with a timeout which specifies the duration of the campaign, with a value of 0 meaning to run indefinitely. This is common in other fuzzers such as Echidna.

It would also be helpful to support config via cheat codes as discussed in #744, to allow some fuzz/invariant tests to be defined by number of runs with others defined by a timeout

Additional context

No response

@mds1 mds1 added the T-feature Type: feature label Mar 19, 2022
@onbjerg onbjerg added A-testing Area: testing Cmd-forge-test Command: forge test C-forge Command: forge P-normal Priority: normal labels Mar 21, 2022
@mds1 mds1 changed the title feat: support time-based fuzzing and invariant testing feat: support time-based and continuous fuzzing and invariant testing Jul 21, 2022
@onbjerg
Copy link
Member

onbjerg commented Aug 3, 2022

Noting here that it does not seem like proptest supports time-based fuzzing out of the box, so we will have to roll our own - that does look like it is somewhat doable, though. We need to wrap the test runner in some time based executor and continually call TestRunner::run_one, but this function takes a case, not a strategy, so it looks like we might need to manage the simplification/complication of values etc. ourselves

@mds1
Copy link
Collaborator Author

mds1 commented Aug 3, 2022

Proptest is largely unmaintained at this point. There hasn't been an update for over a year, though there is a fork that's made a few fixes—more info here: proptest-rs/proptest#268

I only mention that because two alternative options for implementation include:

  1. Forking and maintaining proptest to add support for features like this
  2. Switching to a better maintained fuzzing framework that has this feature implemented (or makes it easy to wrap around). A few alternatives to look into can be found in meta: forge fuzzer improvements #387, but a lot may have changed since that issue was created so there may be newer/better crates not listed

@onbjerg
Copy link
Member

onbjerg commented Aug 3, 2022

I think we should consider switching at some point. I looked around but didn't find anything that immediately struck me but I haven't looked much. I think forking and maintaining a fuzzer on top of Cast + Anvil + Forge + supporting stuff (foundry-hardhat, book etc.) is probably stretching resources a bit thin 😄 Will take a look at the ones linked in #387

@rex-remind101
Copy link

Your input on this thread would be appreciated since it sounds like you all have some direction already proptest-rs/proptest#268 (comment)

@0xPhaze
Copy link

0xPhaze commented Feb 14, 2023

Any progress on this one?

@wuestholz
Copy link

I'm not familiar with the internals of how proptest is invoked, but I was wondering if the following approach could work: wrap the proptest invokation by repeatedly running proptest for a small number of runs until the time limit has been reached. Each "short run" needs to provide a different random seed (derived from the user-provided random seed) when invoking proptest and the results of all "short runs" need to be aggregated.

Feel free to ignore this if the proposed approach doesn't make sense. :)

@grandizzy
Copy link
Collaborator

proposed way to interrupt runs for fuzz / invariant tests when timer expires proptest-rs/proptest#460 to be applied in addition to using rayon collect / short-circuit on Err

@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testing Area: testing C-forge Command: forge Cmd-forge-test Command: forge test P-normal Priority: normal T-feature Type: feature
Projects
Status: Todo
Development

No branches or pull requests

7 participants