-
Notifications
You must be signed in to change notification settings - Fork 42
feat: add property-based testing and fuzzing for escrow & governance … #134
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
anonfedora
merged 8 commits into
anonfedora:master
from
GazzyLee:feature/property-based-testing-fuzzing
Apr 2, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
23debb2
feat: add property-based testing and fuzzing for escrow & governance …
Gazzy-Lee 0bba557
fix: resolve CI failures - rustfmt diffs and governance fuzz crash
Gazzy-Lee aad08bf
fix: move set_voting_power to separate cfg-gated contractimpl block
Gazzy-Lee c082dc0
fix: resolve merge conflict in migration_lock.toml
Gazzy-Lee dbf7f00
Merge remote-tracking branch 'upstream/master' into feature/property-…
Gazzy-Lee 2a25270
fix: resolve compilation errors in proptest and fuzz targets
Gazzy-Lee 9ef88cc
fix(fuzz): reset auth state in each as_contract frame to prevent Host…
Gazzy-Lee ec40e25
fix(fuzz): add mock_all_auths to prevent require_auth panics in fuzz_…
Gazzy-Lee 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| name: Fuzzing & Property Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, master, contract] | ||
| paths: | ||
| - 'contracts/**' | ||
| pull_request: | ||
| branches: [main, master, contract] | ||
| paths: | ||
| - 'contracts/**' | ||
| # Allow manual triggering for extended fuzzing campaigns | ||
| workflow_dispatch: | ||
| inputs: | ||
| fuzz_duration: | ||
| description: 'Fuzzing duration in seconds per target' | ||
| required: false | ||
| default: '300' | ||
|
|
||
| jobs: | ||
| # ── Property-based tests (proptest) ──────────────────────────────────── | ||
| proptest: | ||
| name: Property-Based Tests (proptest) | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: ./contracts | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: wasm32-unknown-unknown | ||
|
|
||
| - name: Cache Cargo Dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| contracts/target | ||
| key: ${{ runner.os }}-cargo-proptest-${{ hashFiles('contracts/Cargo.lock') }} | ||
|
|
||
| - name: Run proptest suite (escrow-manager) | ||
| run: cargo test --package escrow-manager --features testutils -- --include-ignored fuzz --test-threads=1 | ||
| env: | ||
| PROPTEST_CASES: 10000 | ||
|
|
||
| - name: Run proptest suite (governance) | ||
| run: cargo test --package governance --features testutils -- --include-ignored fuzz --test-threads=1 | ||
| env: | ||
| PROPTEST_CASES: 10000 | ||
|
|
||
| # ── Cargo-fuzz (libfuzzer) ───────────────────────────────────────────── | ||
| cargo-fuzz: | ||
| name: Cargo Fuzz (libfuzzer) | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: ./contracts/fuzz | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust nightly (required by cargo-fuzz) | ||
| uses: dtolnay/rust-toolchain@nightly | ||
|
|
||
| - name: Install cargo-fuzz | ||
| run: cargo install cargo-fuzz | ||
|
|
||
| - name: Cache Cargo Dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| contracts/fuzz/target | ||
| key: ${{ runner.os }}-cargo-fuzz-${{ hashFiles('contracts/fuzz/Cargo.lock') }} | ||
|
|
||
| - name: Fuzz escrow invariants | ||
| run: | | ||
| DURATION=${{ github.event.inputs.fuzz_duration || '120' }} | ||
| cargo +nightly fuzz run fuzz_escrow_invariants -- \ | ||
| -max_total_time=${DURATION} \ | ||
| -max_len=4096 \ | ||
| -runs=1000000 | ||
| - name: Fuzz governance voting | ||
| run: | | ||
| DURATION=${{ github.event.inputs.fuzz_duration || '120' }} | ||
| cargo +nightly fuzz run fuzz_governance_voting -- \ | ||
| -max_total_time=${DURATION} \ | ||
| -max_len=4096 \ | ||
| -runs=1000000 | ||
| - name: Upload crash artifacts | ||
| if: failure() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: fuzz-crashes | ||
| path: contracts/fuzz/artifacts/ | ||
| retention-days: 30 | ||
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,2 @@ | ||
| [alias] | ||
| test-fuzz = "test --features testutils -- --include-ignored fuzz" |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.