rustup default stable
rustup target add wasm32-unknown-unknown
cd aura-vaultPROPTEST_PROFILE=quick cargo test --lib fuzzExpected Output:
test fuzz::prop_first_deposit_one_to_one ... ok
test fuzz::prop_deposit_withdraw_no_gain ... ok
test fuzz::prop_total_shares_consistency ... ok
test fuzz::prop_cannot_overdraw ... ok
test fuzz::prop_zero_amount_rejected ... ok
test fuzz::prop_harvest_improves_exchange_rate ... ok
test fuzz::prop_no_overflow ... ok
test invariants::invariant_assets_cover_shares ... ok
test invariants::invariant_balance_non_negative ... ok
test invariants::invariant_version_exists ... ok
test invariants::invariant_must_initialize ... ok
test result: ok. 11 passed
Duration: ~5 seconds
cargo test --lib fuzzEnvironment:
PROPTEST_CASES=1000 \
PROPTEST_MAX_SHRINK_ITERS=100000 \
cargo test --lib fuzz -- --nocapture --test-threads=1Expected Output:
test fuzz::prop_first_deposit_one_to_one ... ok
test fuzz::prop_deposit_withdraw_no_gain ... ok
test fuzz::prop_total_shares_consistency ... ok
test fuzz::prop_cannot_overdraw ... ok
test fuzz::prop_zero_amount_rejected ... ok
test fuzz::prop_harvest_improves_exchange_rate ... ok
test fuzz::prop_no_overflow ... ok
test invariants::invariant_assets_cover_shares ... ok
test invariants::invariant_balance_non_negative ... ok
test invariants::invariant_version_exists ... ok
test invariants::invariant_must_initialize ... ok
test result: ok. 11 passed in 45.2s
Duration: ~45 seconds
PROPTEST_CASES=10000 cargo test --lib fuzzDuration: ~5 minutes
# Test only first deposit property
cargo test --lib prop_first_deposit_one_to_one
# Test only invariants
cargo test --lib invariantcargo test --lib fuzz -- --nocaptureShows all generated test cases and detailed failure messages.
If a test fails with seed, reproduce with:
PROPTEST_SEED=0x1234567890abcdef cargo test --lib prop_first_deposit_one_to_oneFuzz tests run automatically via GitHub Actions:
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
- cron: '0 2 * * *' # Daily at 2 AM UTC- Go to GitHub Repository
- Click Actions tab
- Select "Fuzz Testing" workflow
- View latest run
File: .github/workflows/fuzz-test.yml
- name: Run property tests (1000+ transactions)
run: PROPTEST_CASES=1000 cargo test --lib fuzz
- name: Run invariant checks
run: cargo test --lib invariantsthread 'fuzz::prop_deposit_withdraw_no_gain' panicked at '
assertion failed: redeemed <= amount
Seed: 0x1234567890abcdef
Input: amount = 999999999999999999
Shrunk to: amount = 1000000
Debug Steps:
-
Reproduce:
PROPTEST_SEED=0x1234567890abcdef cargo test --lib prop_deposit_withdraw_no_gain -
Understand: Run with verbose output
cargo test --lib prop_deposit_withdraw_no_gain -- --nocapture -
Fix: Modify contract code and re-test
cargo test --lib prop_deposit_withdraw_no_gain -
Verify: Re-run with same seed to confirm fix
PROPTEST_SEED=0x1234567890abcdef cargo test --lib prop_deposit_withdraw_no_gain
Failed cases are saved in .proptest-regressions/:
# View regression cases
ls -la .proptest-regressions/
# Re-test regressions automatically
cargo test --lib fuzz# Use quick profile (100 cases)
PROPTEST_PROFILE=quick cargo test --lib fuzz# Increase cases
PROPTEST_CASES=50000 cargo test --lib fuzz# Default: sequential (deterministic)
cargo test --lib fuzz -- --test-threads=1
# Parallel (faster but non-deterministic)
cargo test --lib fuzzGenerate code coverage for fuzz tests:
# Install tarpaulin
cargo install cargo-tarpaulin
# Generate coverage
cargo tarpaulin --lib --out Html --output-dir coverage
# View report
open coverage/index.htmlTarget Coverage: >90%
- src/fuzz.rs - Proptest property tests and invariants
- proptest.toml - Fuzzing configuration
- .github/workflows/fuzz-test.yml - CI/CD workflow
- FUZZING_STRATEGY.md - Detailed strategy documentation
- FUZZ_FINDINGS.md - Test results and findings
- FUZZ_TEST_GUIDE.md - This file
- src/lib.rs - Added fuzz module import
- ✅ Every push to main/develop
- ✅ Every pull request
- ✅ Daily at 2 AM UTC
- ✅ Manual trigger via GitHub UI
Each run must satisfy:
- 1,000+ transactions per property
- All 7 properties pass
- All 4 invariants hold
- Zero panics or overflows
- Coverage ≥ 80%
# View GitHub Actions logs
gh run view <RUN_ID> --log
# Download artifacts
gh run download <RUN_ID> -n coverage-report# Increase timeout
PROPTEST_TIMEOUT=600000 cargo test --lib fuzz# Reduce cases
PROPTEST_CASES=100 cargo test --lib fuzz# Clean and rebuild
cargo clean
cargo test --lib fuzz# Remove and re-generate
rm -rf .proptest-regressions/
cargo test --lib fuzzQuestions about fuzz testing?
- Documentation: See FUZZING_STRATEGY.md
- Issues: github.com/aura-vault/aura-vault-protocol/issues
- Email: fuzzing-support@aura-vault.dev
| Command | Purpose |
|---|---|
cargo test --lib fuzz |
Run all 1,000+ case fuzz tests |
PROPTEST_PROFILE=quick cargo test --lib fuzz |
Quick 100-case test |
PROPTEST_CASES=10000 cargo test --lib fuzz |
Intensive 10k case test |
cargo test --lib invariant |
Run invariants only |
PROPTEST_SEED=0x... cargo test --lib prop_X |
Reproduce specific case |
cargo test --lib fuzz -- --nocapture |
Show verbose output |
cargo tarpaulin --lib --out Html |
Generate coverage report |
Status: ✅ Ready for use
Last Updated: 2024-06-25