From e2f4cff58a29da61e3f954f851468bdbc0fc3116 Mon Sep 17 00:00:00 2001 From: David Terry Date: Sun, 12 Sep 2021 23:17:14 +0200 Subject: [PATCH 1/2] hevm: no whitespace in invariant replay data Fixes #722. For some obscure reason related to bash array expansion, the whitespace in the invariant replay data ended up being passed to hevm as `' '` (i.e. two quotes with a space). I don't know why bash adds these extra quotes, but we can just ignore this problem by never including whitespace in replay strings... --- src/hevm/CHANGELOG.md | 8 +++++++- src/hevm/src/EVM/UnitTest.hs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hevm/CHANGELOG.md b/src/hevm/CHANGELOG.md index fbe491374..11e13d3d3 100644 --- a/src/hevm/CHANGELOG.md +++ b/src/hevm/CHANGELOG.md @@ -1,5 +1,12 @@ # hevm changelog +## Unreleased + +## Fixed + +- Test contracts with no code (e.g. `abstract` contracts) are now skipped +- Replay data for invariant tests is now displayed in a form that does not cause errors when used with `dapp test --replay` + ## [0.48.1] - 2021-09-08 ### Added @@ -14,7 +21,6 @@ ### Fixed - The block gas limit and basefee are now correctly fetched when running tests via rpc -- Test contracts with no code (e.g. `abstract` contracts) are now skipped ## 0.48.0 - 2021-08-03 diff --git a/src/hevm/src/EVM/UnitTest.hs b/src/hevm/src/EVM/UnitTest.hs index 3aa552c22..ca23b2db4 100644 --- a/src/hevm/src/EVM/UnitTest.hs +++ b/src/hevm/src/EVM/UnitTest.hs @@ -581,7 +581,7 @@ exploreRun opts@UnitTestOptions{..} initialVm testName replayTxs = do then return ("\x1b[32m[PASS]\x1b[0m " <> testName <> " (runs: " <> (pack $ show fuzzRuns) <>", depth: " <> pack (show depth) <> ")", Right (passOutput vm' opts testName), vm') -- no canonical "post vm" else let replayText = if null replayTxs - then "\nReplay data: '(" <> pack (show testName) <> ", " <> pack (show (show (ByteStringS $ rlpencode counterex))) <> ")'" + then "\nReplay data: '(" <> pack (show testName) <> "," <> pack (show (show (ByteStringS $ rlpencode counterex))) <> ")'" else " (replayed)" in return ("\x1b[31m[FAIL]\x1b[0m " <> testName <> replayText, Left (failOutput vm' opts testName), vm') From 79939630908dc057876b4d46d7274e0458fee0b4 Mon Sep 17 00:00:00 2001 From: David Terry Date: Sun, 12 Sep 2021 23:47:10 +0200 Subject: [PATCH 2/2] dapp: remove extraneous quotes around replay string --- src/dapp/CHANGELOG.md | 4 ++++ src/dapp/libexec/dapp/dapp---hevm-opts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dapp/CHANGELOG.md b/src/dapp/CHANGELOG.md index 4d92f7adc..1fe63feb0 100644 --- a/src/dapp/CHANGELOG.md +++ b/src/dapp/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Dapp remappings ignores non-directories in `DAPP_LIB` +### Fixed + +- Dapp can correctly parse replay strings from invariant tests + ## [0.34.1] - 2021-09-08 ### Added diff --git a/src/dapp/libexec/dapp/dapp---hevm-opts b/src/dapp/libexec/dapp/dapp---hevm-opts index fd4a1bd88..efb11d4ae 100755 --- a/src/dapp/libexec/dapp/dapp---hevm-opts +++ b/src/dapp/libexec/dapp/dapp---hevm-opts @@ -16,7 +16,7 @@ opts=() [[ "$DAPP_TEST_CACHE" ]] && opts+=(--cache "$DAPP_TEST_CACHE") [[ "$DAPP_TEST_MATCH" ]] && opts+=(--match "$DAPP_TEST_MATCH") [[ "$DAPP_TEST_SOLVER" ]] && opts+=(--solver "$DAPP_TEST_SOLVER") -[[ "$DAPP_TEST_REPLAY" ]] && opts+=(--replay \'"$DAPP_TEST_REPLAY"\') +[[ "$DAPP_TEST_REPLAY" ]] && opts+=(--replay "$DAPP_TEST_REPLAY") [[ "$DAPP_TEST_VERBOSITY" ]] && opts+=(--verbose "$DAPP_TEST_VERBOSITY") [[ "$DAPP_TEST_COV_MATCH" ]] && opts+=(--cov-match "$DAPP_TEST_COV_MATCH") [[ "$DAPP_TEST_FUZZ_RUNS" ]] && opts+=(--fuzz-runs "$DAPP_TEST_FUZZ_RUNS")