Skip to content

Commit d07b2b1

Browse files
authored
Merge pull request #1421 from crytic/test-improvements
Test improvements
2 parents 256c244 + 4779e7b commit d07b2b1

File tree

6 files changed

+50
-9
lines changed

6 files changed

+50
-9
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -eux -o pipefail
3+
4+
VERSION=0.8.2
5+
6+
mkdir -p "$HOME/.local/bin/"
7+
8+
if [ "$HOST_OS" = "Linux" ]; then
9+
if [ $(uname -m) = "aarch64" ]; then
10+
curl -fsSL -o bitwuzla.zip https://github.com/bitwuzla/bitwuzla/releases/download/0.8.2/Bitwuzla-Linux-arm64-static.zip
11+
elif [ $(uname -m) = "x86_64" ]; then
12+
curl -fsSL -o bitwuzla.zip https://github.com/bitwuzla/bitwuzla/releases/download/0.8.2/Bitwuzla-Linux-x86_64-static.zip
13+
fi
14+
unzip bitwuzla.zip
15+
cp Bitwuzla*/bin/bitwuzla "$HOME/.local/bin/"
16+
fi
17+
if [ "$HOST_OS" = "Windows" ]; then
18+
curl -fsSL "https://github.com/bitwuzla/bitwuzla/releases/download/$VERSION/Bitwuzla-Win64-x86_64-static.zip" -o bitwuzla.zip
19+
unzip bitwuzla.zip
20+
cp Bitwuzla*/bin/bitwuzla.exe "$HOME/.local/bin/"
21+
fi
22+
23+
rm -rf bitwuzla.zip Bitwuzla*/

.github/scripts/install-z3.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
set -eux -o pipefail
33

44
if [ "$HOST_OS" = "Linux" ]; then
5-
sudo apt-get update
6-
sudo apt-get install -y z3
5+
if [ $(uname -m) = "aarch64" ]; then
6+
curl -fsSL -o z3.zip https://github.com/Z3Prover/z3/releases/download/z3-4.15.2/z3-4.15.2-arm64-glibc-2.34.zip
7+
elif [ $(uname -m) = "x86_64" ]; then
8+
curl -fsSL -o z3.zip https://github.com/Z3Prover/z3/releases/download/z3-4.15.2/z3-4.15.2-x64-glibc-2.39.zip
9+
fi
10+
unzip z3.zip
11+
cp -a z3-*/bin/z3 "$HOME/.local/bin/"
12+
rm -rf z3-*/ z3.zip
713
fi
814
if [ "$HOST_OS" = "Windows" ]; then
915
choco install z3

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ jobs:
220220
- ubuntu-latest
221221
- windows-latest
222222
solc: ${{
223-
(github.event_name == 'push' && github.ref == 'refs/heads/master') &&
223+
((github.event_name == 'push' && github.ref == 'refs/heads/master') ||
224+
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci-all-solc'))) &&
224225
fromJSON('["0.4.25", "0.5.7", "0.6.12", "0.7.5", "0.8.10", "0.8.25"]') ||
225226
fromJSON('["0.8.10", "0.8.25"]')
226227
}}
@@ -243,6 +244,7 @@ jobs:
243244
.github/scripts/install-solc.sh
244245
.github/scripts/install-crytic-compile.sh
245246
.github/scripts/install-z3.sh
247+
.github/scripts/install-bitwuzla.sh
246248
env:
247249
HOST_OS: ${{ runner.os }}
248250
SOLC_VER: ${{ matrix.solc }}
@@ -254,6 +256,8 @@ jobs:
254256

255257
- name: Test
256258
run: |
259+
export PATH="$PATH:$HOME/.local/bin"
257260
solc-select use ${{ matrix.solc }}
258261
chmod +x echidna-testsuite*
259262
./echidna-testsuite*
263+
shell: bash

src/test/Tests/Symbolic.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ import Common (testContract', solcV, solved, verified)
55
import Echidna.Types.Worker (WorkerType(..))
66

77
symbolicTests :: TestTree
8-
symbolicTests = testGroup "Symbolic tests"
9-
[ testContract' "symbolic/verify.sol" Nothing (Just (>= solcV (0,6,9))) (Just "symbolic/verify.yaml") True SymbolicWorker
8+
symbolicTests = testGroup "Symbolic tests" $
9+
map (\conf ->
10+
testContract' "symbolic/verify.sol" Nothing (Just (>= solcV (0,6,9))) (Just conf) True SymbolicWorker
1011
[ ("simple passed", solved "simple")
1112
, ("array passed", solved "array")
1213
, ("negative passed", solved "negative")
1314
, ("close passed", solved "close")
1415
, ("far not verified", verified "far")
1516
, ("correct not verified", verified "correct")
16-
]
17+
]
18+
) ["symbolic/verify.yaml", "symbolic/verify.bitwuzla.yaml"]
19+
++ ([
1720
-- This test is commented out because it requires a specific setup where both the FuzzWorker and SymbolicWorker are used.
1821
-- If you run the symbolic worker alone, it will hang indefinitely.
1922
--, testContract' "symbolic/explore.sol" Nothing Nothing (Just "symbolic/explore.yaml") True SymbolicWorker
2023
-- [ ("f passed", solved "f")
2124
--]
22-
]
25+
] :: [TestTree])

tests/solidity/cheat/ffi.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ contract TestFFI {
1111

1212
function foo(int x) external {
1313
string[] memory inputs = new string[](3);
14-
inputs[0] = "python3";
14+
inputs[0] = "sh";
1515
inputs[1] = "-c";
1616
// ABI encoded "gm", as a string
17-
inputs[2] = "print('0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002676d000000000000000000000000000000000000000000000000000000000000', end='')";
17+
inputs[2] = "printf '%s' '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002676d000000000000000000000000000000000000000000000000000000000000'";
1818

1919
bytes memory res = Hevm(HEVM_ADDRESS).ffi(inputs);
2020

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
testMode: assertion
2+
symExec: true
3+
symExecSMTSolver: bitwuzla
4+
workers: 0
5+
seqLen: 1

0 commit comments

Comments
 (0)