Skip to content

Commit 80dfb3a

Browse files
authored
Merge pull request #1378 from crytic/fix-1321
shrink: consider empty reproducers when removing reverts
2 parents 4ccf67a + 1f368cf commit 80dfb3a

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

lib/Echidna/Shrink.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ removeUselessNoCalls = mapMaybe f
7272
-- If a transaction reverts, replace it by a "NoCall" with the same parameters as the original call
7373
-- (e.g. same block increment timestamp and number)
7474
removeReverts :: (MonadIO m, MonadReader Env m, MonadThrow m) => VM Concrete RealWorld -> [Tx] -> m [Tx]
75+
removeReverts _ [] = return []
7576
removeReverts vm txs = do
7677
let (itxs, le) = (init txs, last txs)
7778
ftxs <- removeReverts' vm itxs []

src/test/Tests/Optimization.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ optimizationTests = testGroup "Optimization-based Integration Testing"
99
[
1010
testContract "optimize/linear.sol" (Just "optimize/config.yaml")
1111
[ ("Max value found in echidna_opt_linear", optimized "echidna_opt_linear" 4000)
12+
],
13+
testContract "optimize/zero.sol" (Just "optimize/config.yaml")
14+
[ ("Max value found in echidna_opt_zero", optimized "echidna_opt_zero" 0)
1215
]
1316
]

tests/solidity/optimize/zero.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
contract Test {
2+
function echidna_opt_zero() public returns (int256) {
3+
return 0;
4+
}
5+
}

0 commit comments

Comments
 (0)