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(fuzz): ability to declare fuzz test fixtures #7428

Merged
merged 31 commits into from
Apr 22, 2024
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ef15bab
fix(fuzz): deduplicate fuzz inputs
grandizzy Mar 14, 2024
3c48666
Fix tests, collect fixtures in test setup, arc fixtures
grandizzy Mar 19, 2024
e1f8a95
Merge remote-tracking branch 'origin' into issue-3521-fixtures
grandizzy Mar 19, 2024
254017c
Cleanup
grandizzy Mar 19, 2024
8586bf4
Merge remote-tracking branch 'origin' into issue-3521-fixtures
grandizzy Mar 20, 2024
14c869a
Use fixture_ prefix
grandizzy Mar 20, 2024
d0442de
Update tests to reflect that random values are used if no fixtures
grandizzy Mar 20, 2024
7e4b14c
Review changes
grandizzy Mar 21, 2024
972d993
Group fuzz_calldata and fuzz_calldata_from_state in calldata mod
grandizzy Mar 21, 2024
708e4db
Review changes: remove unnecessary clones, nicer code to collect fixt…
grandizzy Mar 21, 2024
f93254a
Merge remote-tracking branch 'origin' into issue-3521-fixtures
grandizzy Mar 22, 2024
9276893
Add support for bytes and string fixtures, fixture strategy macro. So…
grandizzy Mar 24, 2024
a5e8da0
Remove unnecessary clone
grandizzy Mar 26, 2024
14273fa
Merge remote-tracking branch 'origin' into issue-3521-fixtures
grandizzy Mar 26, 2024
09ee66e
Use inline config
grandizzy Mar 26, 2024
342eaf7
Merge remote-tracking branch 'origin' into issue-3521-fixtures
grandizzy Mar 26, 2024
4785f93
More robust invariant assume test
grandizzy Mar 26, 2024
0b7a230
Merge remote-tracking branch 'origin' into issue-3521-fixtures
grandizzy Apr 5, 2024
f9adb66
Merge remote-tracking branch 'origin' into issue-3521-fixtures
grandizzy Apr 10, 2024
fb86084
Fixtures as storage arrays, remove inline config
grandizzy Apr 10, 2024
6874ead
Simplify code
grandizzy Apr 10, 2024
ca4d44b
Support fixed size arrays fixtures
grandizzy Apr 10, 2024
acdf92d
Update comment
grandizzy Apr 11, 2024
12115fa
Use DynSolValue::type_strategy for address and fixed bytes fuzzed params
grandizzy Apr 11, 2024
e76fe8e
Add prefix to mark a storage array or a function as fixture
grandizzy Apr 11, 2024
3ac9e33
Fix test
grandizzy Apr 11, 2024
7e95208
Simplify code / fixture strategy macro, panic if configured fixture n…
grandizzy Apr 11, 2024
4cf19cb
Consistent panic with fixture strategy if uint / int fixture of diffe…
grandizzy Apr 13, 2024
53c64d3
Merge remote-tracking branch 'origin' into issue-3521-fixtures
grandizzy Apr 17, 2024
997c5d4
Review changes: don't panic when invalid fixture, use prop_filter_map…
grandizzy Apr 18, 2024
a127780
Merge remote-tracking branch 'origin' into issue-3521-fixtures
grandizzy Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update comment
  • Loading branch information
grandizzy committed Apr 11, 2024
commit acdf92d08ff583723879938c90327dc7504a27f5
8 changes: 4 additions & 4 deletions crates/forge/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,18 @@ impl<'a> ContractRunner<'a> {

/// Collect fixtures from test contract.
///
/// - as storage arrays defined in test contract
/// Fixtures can be defined:
/// - as storage arrays in test contract
/// - as functions by having inline fixture configuration and same name as the parameter to be
/// fuzzed
///
/// For example, a storage variable declared as
/// Storage array fixtures:
/// `uint256[] public amount = [1, 2, 3];`
/// define an array of uint256 values to be used for fuzzing `amount` named parameter in scope
/// of the current test.
///
/// For example, a function declared as
/// `function owner() public returns (address[] memory)`
/// Function fixtures:
/// `function owner() public returns (address[] memory){}`
/// returns an array of addresses to be used for fuzzing `owner` named parameter in scope of the
/// current test.
fn fuzz_fixtures(&mut self, address: Address) -> FuzzFixtures {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just have this check here

Expand Down
Loading