diff --git a/examples/solidity/basic/memory-reset.sol b/examples/solidity/basic/memory-reset.sol new file mode 100644 index 00000000..5f782c30 --- /dev/null +++ b/examples/solidity/basic/memory-reset.sol @@ -0,0 +1,11 @@ +contract ShouldNotRevert { + function f() public { } + + function echidna_should_not_revert() public returns (bool) { + bool[] memory includeMap = new bool[](1); + if (includeMap[0]) { + revert(); + } + return true; + } +} diff --git a/lib/Echidna/Transaction.hs b/lib/Echidna/Transaction.hs index da4e203c..bffd7edf 100644 --- a/lib/Echidna/Transaction.hs +++ b/lib/Echidna/Transaction.hs @@ -115,7 +115,7 @@ liftSH = S.state . runState . zoom hasLens -- 'Transaction's \"on-chain\". setupTx :: (MonadState x m, Has VM x) => Tx -> m () setupTx (Tx c s r v) = S.state . runState . zoom hasLens . sequence_ $ - [ result .= Nothing, state . pc .= 0, state . stack .= mempty, state . gas .= 0xffffffff + [ result .= Nothing, state . pc .= 0, state . stack .= mempty, state . memory .= mempty, state . gas .= 0xffffffff , env . origin .= s, state . caller .= s, state . callvalue .= v, setup] where setup = case c of Left cd -> loadContract r >> state . calldata .= encode cd diff --git a/src/test/Spec.hs b/src/test/Spec.hs index b986ff69..7a37f4c1 100644 --- a/src/test/Spec.hs +++ b/src/test/Spec.hs @@ -93,6 +93,8 @@ integrationTests = testGroup "Solidity Integration Testing" ] ++ (["s1", "s2", "s3"] <&> \n -> ("echidna_all_sender solved without " ++ unpack n, solvedWith (n, []) "echidna_all_sender")) + , testContract "basic/memory-reset.sol" Nothing + [ ("echidna_should_not_revert failed", passed "echidna_should_not_revert") ] , testContract "basic/contractAddr.sol" Nothing [ ("echidna_address failed", solved "echidna_address") ] , testContract "basic/contractAddr.sol" (Just "basic/contractAddr.yaml")