Skip to content

Commit

Permalink
Better error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
msooseth committed Oct 31, 2024
1 parent da695e3 commit fed5b2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/EVM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2381,10 +2381,10 @@ finishFrame how = do
push 0

-- Case 3: Error during a call?
FrameErrored _ -> do
FrameErrored e -> do
revertContracts
revertSubstate
assign (#state % #returndata) mempty
assign (#state % #returndata) (ConcreteBuf (BS8.pack $ show e))
push 0
-- Or were we creating?
CreationContext _ _ reversion subState' -> do
Expand Down
8 changes: 7 additions & 1 deletion src/EVM/UnitTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import EVM.Transaction (initTx)
import EVM.Stepper (Stepper)
import EVM.Stepper qualified as Stepper

import Control.Monad (void, when, forM, forM_)
import Control.Monad (void, when, forM, forM_, unless)
import Control.Monad.ST (RealWorld, ST, stToIO)
import Control.Monad.State.Strict (execState, get, put, liftIO)
import Optics.Core
Expand Down Expand Up @@ -227,6 +227,12 @@ symRun opts@UnitTestOptions{..} vm (Sig testName types) = do
-- check postconditions against vm
(e, results) <- verify solvers (makeVeriOpts opts) (symbolify vm') (Just postcondition)
let allReverts = not . (any Expr.isSuccess) . flattenExpr $ e
let fails = filter (Expr.isFailure) $ flattenExpr e
unless (null fails) $ liftIO $ do
putStrLn $ " \x1b[33mWARNING\x1b[0m: hevm was only able to partially explore the test " <> Text.unpack testName <> " due to: ";
forM_ (fails) $ \case
(Failure _ _ err) -> putStrLn $ " -> " <> show err
_ -> internalError "unexpected failure"
when (any isUnknown results || any isError results) $ liftIO $ do
putStrLn $ " \x1b[33mWARNING\x1b[0m: hevm was only able to partially explore the test " <> Text.unpack testName <> " due to: ";
forM_ (groupIssues (filter isError results)) $ \(num, str) -> putStrLn $ " " <> show num <> "x -> " <> str
Expand Down

0 comments on commit fed5b2a

Please sign in to comment.