Skip to content

Commit

Permalink
hevm: fix prove tests for latest ds-test
Browse files Browse the repository at this point in the history
Since dapphub/ds-test#30 calls to `failed()` can
contain reverting branches due to the call into abi.decode().

This meant that using prove tests with the latest ds-test version would
always fail with a hard error.

This change updates the symbolic test stepper to correctly report
`bailed` as true for branches that reverted during the call to
`failed()`.
  • Loading branch information
d-xo committed Jun 29, 2022
1 parent 97f73ec commit 2b031e9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/hevm/src/EVM/UnitTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -770,10 +770,14 @@ execSymTest opts@UnitTestOptions{ .. } method cd = do
Stepper.runFully >>= \vm' -> case view result vm' of
Just (VMFailure err) ->
-- If we failed, put the error in the trace.
Stepper.evm (pushTrace (ErrorTrace err)) >> (pure (True, vm'))
Stepper.evm (pushTrace (ErrorTrace err)) >> pure (True, vm')
Just (VMSuccess _) -> do
postVm <- checkSymFailures opts
pure (False, postVm)
-- calls to failed() contain reverting branches since https://github.com/dapphub/ds-test/pull/30
case view result postVm of
Just (VMSuccess _) -> pure (False, postVm)
Just (VMFailure _) -> pure (True, postVm)
r -> error $ "unexpected return value after call to failed(): " ++ show r
Nothing -> error "Internal Error: execSymTest: vm has not completed execution!"

checkSymFailures :: UnitTestOptions -> Stepper VM
Expand Down

0 comments on commit 2b031e9

Please sign in to comment.