From 25f52c72b18990ea686565ba34354b70d83c7dca Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Mon, 30 Jan 2023 14:35:14 +0100 Subject: [PATCH] [ci] Run fuzzing in CI --- .github/workflows/ci.yml | 9 +++++---- fuzzing/fuzz.sh | 22 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56eb695..7e8bd27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,12 +7,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 with: node-version: 18 - - run: npm install - - run: npm test - + - uses: actions/cache@v3 + with: + path: fuzzing/corpus + key: fuzzing + - run: npm run fuzz diff --git a/fuzzing/fuzz.sh b/fuzzing/fuzz.sh index 75e2424..f030ccf 100755 --- a/fuzzing/fuzz.sh +++ b/fuzzing/fuzz.sh @@ -1,3 +1,23 @@ #!/bin/bash set -e -echidna-test . --contract FuzzMarketplace --config fuzzing/echidna.yaml + +if command -v echidna-test; then + fuzz () { + echidna-test . \ + --config fuzzing/echidna.yaml \ + --contract $1 + } +else + fuzz () { + docker run \ + --rm \ + -v `pwd`:/src ghcr.io/crytic/echidna/echidna \ + bash -c \ + "cd /src && echidna-test . \ + --config fuzzing/echidna.yaml \ + --crytic-args --ignore-compile \ + --contract $1" + } +fi + +fuzz FuzzMarketplace