-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(forge): fuzz & invariant config #2882
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
12c513f
invariant config
rkrasiuk a3c0270
separate fuzz & invariant configs
rkrasiuk d0c029f
misc fixes & value config flags
rkrasiuk 89d05fc
Merge branch 'master' into rkrasiuk/feat-invariant-config
rkrasiuk e24a551
dict weight
rkrasiuk 065e340
fix it tests
rkrasiuk a90e0b7
fix tests & add validation
rkrasiuk ac58671
Merge branch 'master' into rkrasiuk/feat-invariant-config
rkrasiuk 271fdd6
fix docs
rkrasiuk a0a8d3e
dapp compatibility
rkrasiuk 207ab9b
newline
rkrasiuk 306ee16
fallback provider
rkrasiuk c53a7eb
address comments
rkrasiuk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| //! Configuration for fuzz testing | ||
|
|
||
| use ethers_core::types::U256; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| /// Contains for fuzz testing | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] | ||
| pub struct FuzzConfig { | ||
| /// The number of test cases that must execute for each property test | ||
| pub runs: u32, | ||
| /// The maximum number of local test case rejections allowed | ||
| /// by proptest, to be encountered during usage of `vm.assume` | ||
| /// cheatcode. | ||
| pub max_local_rejects: u32, | ||
| /// The maximum number of global test case rejections allowed | ||
| /// by proptest, to be encountered during usage of `vm.assume` | ||
| /// cheatcode. | ||
| pub max_global_rejects: u32, | ||
| /// Optional seed for the fuzzing RNG algorithm | ||
| #[serde( | ||
| deserialize_with = "ethers_core::types::serde_helpers::deserialize_stringified_numeric_opt" | ||
| )] | ||
| pub seed: Option<U256>, | ||
| /// The weight of the dictionary | ||
| #[serde(deserialize_with = "crate::deserialize_stringified_percent")] | ||
| pub dictionary_weight: u32, | ||
| /// The flag indicating whether to include values from storage | ||
| pub include_storage: bool, | ||
| /// The flag indicating whether to include push bytes values | ||
| pub include_push_bytes: bool, | ||
| } | ||
|
|
||
| impl Default for FuzzConfig { | ||
| fn default() -> Self { | ||
| FuzzConfig { | ||
| runs: 256, | ||
| max_local_rejects: 1024, | ||
| max_global_rejects: 65536, | ||
| seed: None, | ||
| dictionary_weight: 40, | ||
| include_storage: true, | ||
| include_push_bytes: true, | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| //! Configuration for invariant testing | ||
|
|
||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| /// Contains for invariant testing | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] | ||
| pub struct InvariantConfig { | ||
| /// The number of runs that must execute for each invariant test group. | ||
| pub runs: u32, | ||
| /// The number of calls executed to attempt to break invariants in one run. | ||
| pub depth: u32, | ||
| /// Fails the invariant fuzzing if a revert occurs | ||
| pub fail_on_revert: bool, | ||
| /// Allows overriding an unsafe external call when running invariant tests. eg. reentrancy | ||
| /// checks | ||
| pub call_override: bool, | ||
| /// The weight of the dictionary | ||
| #[serde(deserialize_with = "crate::deserialize_stringified_percent")] | ||
| pub dictionary_weight: u32, | ||
| /// The flag indicating whether to include values from storage | ||
| pub include_storage: bool, | ||
| /// The flag indicating whether to include push bytes values | ||
| pub include_push_bytes: bool, | ||
| } | ||
|
|
||
| impl Default for InvariantConfig { | ||
| fn default() -> Self { | ||
| InvariantConfig { | ||
| runs: 256, | ||
| depth: 15, | ||
| fail_on_revert: false, | ||
| call_override: false, | ||
| dictionary_weight: 80, | ||
| include_storage: true, | ||
| include_push_bytes: true, | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome