Skip to content

Commit

Permalink
Merge pull request #124 from ethereum/summary
Browse files Browse the repository at this point in the history
Add summary to HEVM output
  • Loading branch information
kjekac authored Aug 27, 2021
2 parents fbdd73d + 30cf040 commit 4e3b661
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
35 changes: 23 additions & 12 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import System.IO (hPutStrLn, stderr, stdout)
import Data.SBV hiding (preprocess, sym, prove)
import Data.Text (pack, unpack)
import Data.List
import Data.Either (lefts)
import Data.Maybe
import Data.Tree
import qualified EVM.Solidity as Solidity
Expand Down Expand Up @@ -217,18 +218,28 @@ hevm spec' soljson' solver' smttimeout' smtdebug' = do
passes <- forM specs $ \behv -> do
res <- runSMTWithTimeOut solver' smttimeout' smtdebug' $ proveBehaviour sources behv
case res of
Qed posts -> do
putStrLn $ "Successfully proved " <> (_name behv) <> "(" <> show (_mode behv) <> ")"
<> ", " <> show (length $ last $ levels posts) <> " cases."
return True
Cex _ -> do
putStrLn $ "Failed to prove " <> (_name behv) <> "(" <> show (_mode behv) <> ")"
return False
Timeout _ -> do
putStrLn $ "Solver timeout when attempting to prove " <> (_name behv) <> "(" <> show (_mode behv) <> ")"
return False
unless (and passes) exitFailure

Qed posts -> let msg = "Successfully proved " <> showBehv behv <> ", "
<> show (length $ last $ levels posts) <> " cases."
in putStrLn msg >> return (Right msg)
Cex _ -> let msg = "Failed to prove " <> showBehv behv
in putStrLn msg >> return (Left msg)
Timeout _ -> let msg = "Solver timeout when attempting to prove " <> showBehv behv
in putStrLn msg >> return (Left msg)
let failures = lefts passes

putStrLn . unlines $
if null failures
then [ "==== SUCCESS ===="
, "All behaviours implemented as specified ∎."
]
else [ "==== FAILURE ===="
, show (length failures) <> " out of " <> show (length passes) <> " claims unproven:"
, ""
]
<> zipWith (\i msg -> show (i::Int) <> "\t" <> msg) [1..] failures
unless (null failures) exitFailure
where
showBehv behv = _name behv <> "(" <> show (_mode behv) <> ")"

-------------------
-- *** Util *** ---
Expand Down
6 changes: 5 additions & 1 deletion src/act.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ common deps
build-depends: base >= 4.9 && < 5,
aeson >= 1.0,
containers >= 0.5,
hevm >= 0.47.1,
hevm >= 0.47.1 && < 0.48,
-- hevm version has an ugly upper bound to
-- force usage of version from nix-shell,
-- which avoids weird missing deps when
-- pulling it from hackage.
lens >= 4.17.1,
text >= 1.2,
array >= 0.5.3.0,
Expand Down

0 comments on commit 4e3b661

Please sign in to comment.