[fuzzing] allow fuzz.sh to be called from any directory

This commit is contained in:
Mark Spanbroek 2023-01-30 17:44:34 +01:00 committed by markspanbroek
parent 25f52c72b1
commit c1b412c589
2 changed files with 7 additions and 4 deletions

View File

@ -2,5 +2,4 @@
testMode: "assertion" # check that solidity asserts are never triggered testMode: "assertion" # check that solidity asserts are never triggered
multi-abi: true # allow calls to e.g. TestToken in test scenarios multi-abi: true # allow calls to e.g. TestToken in test scenarios
corpusDir: "fuzzing/corpus" # collect coverage maximizing corpus in this dir
format: "text" # disable interactive ui format: "text" # disable interactive ui

View File

@ -1,20 +1,24 @@
#!/bin/bash #!/bin/bash
set -e set -e
root=$(cd $(dirname "$0")/.. && pwd)
if command -v echidna-test; then if command -v echidna-test; then
fuzz () { fuzz () {
echidna-test . \ echidna-test ${root} \
--config fuzzing/echidna.yaml \ --config ${root}/fuzzing/echidna.yaml \
--corpus-dir ${root}/fuzzing/corpus \
--contract $1 --contract $1
} }
else else
fuzz () { fuzz () {
docker run \ docker run \
--rm \ --rm \
-v `pwd`:/src ghcr.io/crytic/echidna/echidna \ -v ${root}:/src ghcr.io/crytic/echidna/echidna \
bash -c \ bash -c \
"cd /src && echidna-test . \ "cd /src && echidna-test . \
--config fuzzing/echidna.yaml \ --config fuzzing/echidna.yaml \
--corpus-dir fuzzing/corpus \
--crytic-args --ignore-compile \ --crytic-args --ignore-compile \
--contract $1" --contract $1"
} }