Skip to content

Commit

Permalink
test: Investigate Fuzzing (#477)
Browse files Browse the repository at this point in the history
<!--
Thank you for your interest in contributing to OpenZeppelin!

Consider opening an issue for discussion prior to submitting a PR. New
features will be merged faster if they were first discussed and designed
with the team.

Describe the changes introduced in this pull request. Include any
context necessary for understanding the PR's purpose.
-->

As [per our
agreement](https://openzeppelin.slack.com/archives/C06R5AGFE9G/p1737021738986409),
this PR includes a basic fuzz tests setup and some missing unit/property
tests for `openzeppelin-crypto` crate.

I created a couple of related issues to address missing property tests
(see #501 #502 #503).
Adding property tests for contract will be easily possible after `motsu`
is refactored (see
https://github.com/OpenZeppelin/stylus-test-helpers/pull/14/files#r1919897820)

<!-- Fill in with issue number -->
Resolves #458 

#### PR Checklist

<!--
Before merging the pull request all of the following must be completed.
Feel free to submit a PR or Draft PR even if some items are pending.
Some of the items may not apply.
-->

- [x] Tests
- [x] Documentation
- [ ] Changelog

---------

Co-authored-by: Daniel Bigos <[email protected]>
Co-authored-by: Alisander Qoshqosh <[email protected]>
  • Loading branch information
3 people authored Feb 5, 2025
1 parent a283748 commit 1c86069
Show file tree
Hide file tree
Showing 13 changed files with 2,597 additions and 55 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ default-members = [
"examples/ecdsa",
"examples/poseidon",
]
exclude = ["fuzz"]

# Explicitly set the resolver to version 2, which is the default for packages
# with edition >= 2021.
Expand Down
33 changes: 29 additions & 4 deletions GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,25 @@ Some other examples of automation are:

Always check your code with the linter (`clippy`), by running:

$ cargo clippy --tests --all-features
```shell
cargo clippy --tests --all-features
```

And make sure your code is formatted with, using:

$ cargo +nightly fmt
```shell
cargo +nightly fmt
```

Finally, ensure there is no trailing whitespace anywhere.

### Running tests

Make sure all tests are passing with:

$ cargo test --all-features
```shell
cargo test --all-features
```

### Running end-to-end tests

Expand All @@ -241,12 +247,31 @@ Then you will be able to run e2e tests:
./scripts/e2e-tests.sh
```

### Running fuzz tests

To run fuzz tests, you need to have [cargo-fuzz] installed.
Then from the root of the project you can use `cargo fuzz list` to view the list of all existing fuzz targets:

```shell
cargo fuzz list
```

Finally you need to run:

```shell
cargo fuzz run <fuzz target name>
```

[cargo-fuzz]: https://rust-fuzz.github.io/book/cargo-fuzz/setup.html

### Checking the docs

If you make documentation changes, you may want to check whether there are any
warnings or errors:

$ cargo doc --all-features
```shell
cargo doc --all-features
```

## Pull requests

Expand Down
4 changes: 4 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
corpus
artifacts
coverage
Loading

0 comments on commit 1c86069

Please sign in to comment.