Skip to content

Commit f1cc47f

Browse files
authored
Merge pull request #718 from ethereum/add-test-case-for-printing
Add test case for robust printing
2 parents e7eb171 + 01171a7 commit f1cc47f

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

test/test.hs

+24-2
Original file line numberDiff line numberDiff line change
@@ -4356,8 +4356,30 @@ tests = testGroup "hevm"
43564356
assertEqualM "We must be able to remove all duplicates" (length $ nubOrd simp) (length $ List.nub simp)
43574357
]
43584358
, testGroup "calling-solvers"
4359-
[
4360-
testCase "correct-model-for-empty-buffer" $ runEnv (testEnv {config = testEnv.config {numCexFuzz = 0}}) $ do
4359+
[ test "no-error-on-large-buf" $ do
4360+
-- These two tests generates a very large buffer that previously would cause an internalError when
4361+
-- printed via "formatCex". We should be able to print it now.
4362+
Just c <- solcRuntime "MyContract" [i|
4363+
contract MyContract {
4364+
function fun(bytes calldata a) external pure {
4365+
if (a.length > 0x800000000000) {
4366+
assert(false);
4367+
}
4368+
}
4369+
} |]
4370+
(_, [Cex cex]) <- withDefaultSolver $ \s -> checkAssert s defaultPanicCodes c Nothing [] defaultVeriOpts
4371+
putStrLnM $ "Cex found:" <> T.unpack (formatCex (AbstractBuf "txdata") Nothing (snd cex))
4372+
, test "no-error-on-large-buf-pure-print" $ do
4373+
let bufs = Map.singleton (AbstractBuf "txdata")
4374+
(EVM.Types.Comp Write {byte = 1, idx = 0x27, next = Base {byte = 0x66, length = 0xffff000000000000000}})
4375+
let mycex = SMTCex {vars = mempty
4376+
, addrs = mempty
4377+
, buffers = bufs
4378+
, store = mempty
4379+
, blockContext = mempty
4380+
, txContext = Map.fromList [(TxValue,0x0)]}
4381+
putStrLnM $ "Cex found:" <> T.unpack (formatCex (AbstractBuf "txdata") Nothing mycex)
4382+
, testCase "correct-model-for-empty-buffer" $ runEnv (testEnv {config = testEnv.config {numCexFuzz = 0}}) $ do
43614383
withDefaultSolver $ \s -> do
43624384
let props = [(PEq (BufLength (AbstractBuf "b")) (Lit 0x0))]
43634385
(res, _) <- checkSatWithProps s props

0 commit comments

Comments
 (0)