Skip to content

Commit 62b10b0

Browse files
sirabensamalws-tob
authored andcommitted
Make continuous fuzzing default
Fixes #477
1 parent b824e95 commit 62b10b0

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

Diff for: lib/Echidna/Campaign.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ runWorker
9191
-> Int -- ^ Worker id starting from 0
9292
-> [(FilePath, [Tx])]
9393
-- ^ Initial corpus of transactions
94-
-> Int -- ^ Test limit for this worker
94+
-> Maybe Int -- ^ Test limit for this worker
9595
-> m (WorkerStopReason, WorkerState)
9696
runWorker callback vm world dict workerId initialCorpus testLimit = do
9797
let
@@ -136,10 +136,10 @@ runWorker callback vm world dict workerId initialCorpus testLimit = do
136136
if | stopOnFail && any final tests ->
137137
lift callback >> pure FastFailed
138138

139-
| (null tests || any isOpen tests) && ncalls < testLimit ->
139+
| (null tests || any isOpen tests) && maybe True (ncalls <) testLimit ->
140140
fuzz >> continue
141141

142-
| ncalls >= testLimit && any (\t -> isOpen t && isOptimizationTest t) tests -> do
142+
| maybe False (ncalls >=) testLimit && any (\t -> isOpen t && isOptimizationTest t) tests -> do
143143
liftIO $ atomicModifyIORef' testsRef $ \sharedTests ->
144144
(closeOptimizationTest <$> sharedTests, ())
145145
continue

Diff for: lib/Echidna/Config.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ instance FromJSON EConfigWithUsage where
8484
pure $ TestConf classify (const psender)
8585

8686
campaignConfParser = CampaignConf
87-
<$> v ..:? "testLimit" ..!= defaultTestLimit
87+
<$> v ..:? "testLimit"
8888
<*> v ..:? "stopOnFail" ..!= False
8989
<*> v ..:? "estimateGas" ..!= False
9090
<*> v ..:? "seqLen" ..!= defaultSequenceLength

Diff for: lib/Echidna/Types/Campaign.hs

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Echidna.Types.Tx (Tx)
1414

1515
-- | Configuration for running an Echidna 'Campaign'.
1616
data CampaignConf = CampaignConf
17-
{ testLimit :: Int
17+
{ testLimit :: Maybe Int
1818
-- ^ Maximum number of function calls to execute while fuzzing
1919
, stopOnFail :: Bool
2020
-- ^ Whether to stop the campaign immediately if any property fails
@@ -148,9 +148,6 @@ initialWorkerState =
148148
, ncalls = 0
149149
}
150150

151-
defaultTestLimit :: Int
152-
defaultTestLimit = 50000
153-
154151
defaultSequenceLength :: Int
155152
defaultSequenceLength = 100
156153

Diff for: lib/Echidna/UI.hs

+4-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ ui vm world dict initialCorpus = do
7777

7878
-- Distribute over all workers, could be slightly bigger overall due to
7979
-- ceiling but this doesn't matter
80-
perWorkerTestLimit = ceiling
81-
(fromIntegral conf.campaignConf.testLimit / fromIntegral nworkers :: Double)
80+
perWorkerTestLimit =
81+
case conf.campaignConf.testLimit of
82+
Nothing -> Nothing
83+
Just t -> Just $ ceiling (fromIntegral t / fromIntegral nworkers :: Double)
8284

8385
chunkSize = ceiling
8486
(fromIntegral (length initialCorpus) / fromIntegral nworkers :: Double)

Diff for: lib/Echidna/UI/Widgets.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ summaryWidget env uiState =
169169
<=>
170170
perfWidget uiState
171171
<=>
172-
str ("Total calls: " <> progress (sum $ (.ncalls) <$> uiState.campaigns)
173-
env.cfg.campaignConf.testLimit)
172+
str ("Total calls: " <> maybe (show totalCalls) (progress totalCalls) env.cfg.campaignConf.testLimit)
173+
totalCalls = (sum $ (.ncalls) <$> uiState.campaigns)
174174
middle =
175175
padLeft (Pad 1) $
176176
str ("Unique instructions: " <> show uiState.coverage)

Diff for: src/Main.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ options = Options
175175
<> help "Timeout given in seconds.")
176176
<*> optional (option auto $ long "test-limit"
177177
<> metavar "INTEGER"
178-
<> help ("Number of sequences of transactions to generate during testing. Default is " ++ show defaultTestLimit))
178+
<> help "Number of sequences of transactions to generate during testing. Default is unbounded.")
179179
<*> optional (option auto $ long "rpc-block"
180180
<> metavar "BLOCK"
181181
<> help "Block number to use when fetching over RPC.")
@@ -239,7 +239,7 @@ overrideConfig config Options{..} = do
239239

240240
overrideCampaignConf campaignConf = campaignConf
241241
{ corpusDir = cliCorpusDir <|> campaignConf.corpusDir
242-
, testLimit = fromMaybe campaignConf.testLimit cliTestLimit
242+
, testLimit = cliTestLimit <|> campaignConf.testLimit
243243
, shrinkLimit = fromMaybe campaignConf.shrinkLimit cliShrinkLimit
244244
, seqLen = fromMaybe campaignConf.seqLen cliSeqLen
245245
, seed = cliSeed <|> campaignConf.seed

Diff for: src/test/Common.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ overrideQuiet conf =
6060

6161
overrideLimits :: EConfig -> EConfig
6262
overrideLimits conf =
63-
conf { campaignConf = conf.campaignConf { testLimit = 10000
63+
conf { campaignConf = conf.campaignConf { testLimit = Just 10000
6464
, shrinkLimit = 4000 }}
6565

6666
type SolcVersion = Version

Diff for: src/test/Tests/Seed.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ seedTests =
2222
where
2323
cfg s = defaultConfig
2424
{ campaignConf = CampaignConf
25-
{ testLimit = 600
25+
{ testLimit = Just 600
2626
, stopOnFail = False
2727
, estimateGas = False
2828
, seqLen = 20

Diff for: tests/solidity/research/ilf_crowdsale.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
maxValue: 10000000000000000000000000
22
testMode: assertion
3+
testLimit: 50000

0 commit comments

Comments
 (0)