Skip to content

Commit c1a8270

Browse files
authored
Merge pull request #668 from ethereum/fix-printing
Fix printing during tests, add proper asserts
2 parents f58463a + 7d5ee66 commit c1a8270

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3838
- Dumping of END states (.prop) files is now default for `--debug`
3939
- When cheatcode is missing, we produce a partial execution warning
4040
- Size of calldata can be up to 2**64, not 256. This is now reflected in the documentation
41+
- We now have less noise during test runs, and assert more about symbolic copyslice tests
4142

4243
## Changed
4344
- Warnings now lead printing FAIL. This way, users don't accidentally think that

src/EVM/SymExec.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ isError :: ProofResult a b c d -> Bool
7171
isError (EVM.SymExec.Error _) = True
7272
isError _ = False
7373

74+
getError :: ProofResult a b c String -> Maybe String
75+
getError (EVM.SymExec.Error e) = Just e
76+
getError _ = Nothing
77+
7478
isCex :: ProofResult a b c d -> Bool
7579
isCex (Cex _) = True
7680
isCex _ = False

test/test.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import Data.Maybe
2626
import Data.String.Here
2727
import Data.Text (Text)
2828
import Data.Text qualified as T
29-
import Data.Text.IO qualified as T
3029
import Data.Time (diffUTCTime, getCurrentTime)
3130
import Data.Tuple.Extra
3231
import Data.Tree (flatten)
@@ -274,9 +273,7 @@ tests = testGroup "hevm"
274273
}
275274
|]
276275
expr <- withDefaultSolver $ \s -> getExpr s c (Just (Sig "prove_mapping_access(address,address)" [AbiAddressType, AbiAddressType])) [] defaultVeriOpts
277-
putStrLnM $ T.unpack $ formatExpr expr
278276
let simpExpr = mapExprM Expr.decomposeStorage expr
279-
-- putStrLnM $ T.unpack $ formatExpr (fromJust simpExpr)
280277
assertEqualM "Decompose did not succeed." (isJust simpExpr) True
281278
, test "decompose-2" $ do
282279
Just c <- solcRuntime "MyContract"
@@ -1423,7 +1420,6 @@ tests = testGroup "hevm"
14231420
}
14241421
|]
14251422
Right e <- reachableUserAsserts c Nothing
1426-
liftIO $ T.putStrLn $ formatExpr e
14271423
assertBoolM "The expression is not partial" $ Expr.containsNode isPartial e
14281424
,
14291425
-- TODO: we can't deal with symbolic jump conditions
@@ -1528,7 +1524,10 @@ tests = testGroup "hevm"
15281524
|]
15291525
let sig = Just (Sig "fun(uint256,uint256)" [AbiUIntType 256, AbiUIntType 256])
15301526
(_, k) <- withDefaultSolver $ \s -> checkAssert s defaultPanicCodes c sig [] defaultVeriOpts
1531-
putStrLnM $ "Ret: " <> (show k)
1527+
let numErrs = sum $ map (fromEnum . isError) k
1528+
assertEqualM "number of errors (i.e. copySlice issues) is 1" 1 numErrs
1529+
let errStrings = mapMaybe EVM.SymExec.getError k
1530+
assertEqualM "All errors are from copyslice" True $ all ("CopySlice" `List.isInfixOf`) errStrings
15321531
]
15331532
, testGroup "Symbolic-Constructor-Args"
15341533
-- this produced some hard to debug failures. keeping it around since it seemed to exercise the contract creation code in interesting ways...

0 commit comments

Comments
 (0)