-
Notifications
You must be signed in to change notification settings - Fork 11
/
run-foundry.sh
executable file
·37 lines (36 loc) · 1.39 KB
/
run-foundry.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/ash
cd /daedaluzz
rm -rf foundry-tmp/task-$1
mkdir foundry-tmp/task-$1
cd foundry-tmp/task-$1
forge init --no-git foundry-project
cd foundry-project
cp /daedaluzz/generated-mazes/maze-$3.foundry.sol test/maze-$3.t.sol
cp foundry.toml foundry.original.toml
forge build
# Default settings:
# - fuzz.runs: 256
# - fuzz.max_test_rejects: 65536
# - invariant.runs: 256
# - invariant.depth: 15
RUNS=500 # We also tried several other values, but did not observe a significant change in performance
MAX_TEST_REJECTS=1073741823
DEPTH=100 # We also tried 15 and 30, but observed lower performance.
INIT_SEED=$4
RANDOM=$INIT_SEED
START_TIME=$(date +%s)
TIME_LIMIT=$2
END_TIME=$((START_TIME + TIME_LIMIT))
while true; do
NOW_TIME=$(date +%s)
echo "{\"timestamp\": $NOW_TIME}"
if [ $END_TIME -lt $NOW_TIME ]; then
break
fi
SEED=$RANDOM
echo "{\"random-seed\": $SEED}"
HEX_SEED=$(printf "0x%x" $SEED)
cp foundry.original.toml foundry.toml
printf "\n[fuzz]\nruns = %s\nmax_test_rejects = %s\nseed = '%s'\ndictionary_weight = 40\ninclude_storage = true\ninclude_push_bytes = true\n\n[invariant]\nruns = %s\ndepth = %s\nfail_on_revert = false\ncall_override = false\ndictionary_weight = 80\ninclude_storage = true\ninclude_push_bytes = true\n" $RUNS $MAX_TEST_REJECTS $HEX_SEED $RUNS $DEPTH >> foundry.toml
forge test --match-path test/maze-$3.t.sol --fuzz-seed $HEX_SEED
done