Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make continuous fuzzing an option #1064

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions asdf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
asdf
6 changes: 3 additions & 3 deletions lib/Echidna/Campaign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ runWorker
-> Int -- ^ Worker id starting from 0
-> [(FilePath, [Tx])]
-- ^ Initial corpus of transactions
-> Int -- ^ Test limit for this worker
-> Maybe Int -- ^ Test limit for this worker
-> m (WorkerStopReason, WorkerState)
runWorker callback vm world dict workerId initialCorpus testLimit = do
let
Expand Down Expand Up @@ -136,10 +136,10 @@ runWorker callback vm world dict workerId initialCorpus testLimit = do
if | stopOnFail && any final tests ->
lift callback >> pure FastFailed

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

| ncalls >= testLimit && any (\t -> isOpen t && isOptimizationTest t) tests -> do
| maybe False (ncalls >=) testLimit && any (\t -> isOpen t && isOptimizationTest t) tests -> do
liftIO $ atomicModifyIORef' testsRef $ \sharedTests ->
(closeOptimizationTest <$> sharedTests, ())
continue
Expand Down
2 changes: 1 addition & 1 deletion lib/Echidna/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ instance FromJSON EConfigWithUsage where
pure $ TestConf classify (const psender)

campaignConfParser = CampaignConf
<$> v ..:? "testLimit" ..!= defaultTestLimit
siraben marked this conversation as resolved.
Show resolved Hide resolved
<$> v ..:? "testLimit"
<*> v ..:? "stopOnFail" ..!= False
<*> v ..:? "estimateGas" ..!= False
<*> v ..:? "seqLen" ..!= defaultSequenceLength
Expand Down
5 changes: 1 addition & 4 deletions lib/Echidna/Types/Campaign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Echidna.Types.Tx (Tx)

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

defaultTestLimit :: Int
defaultTestLimit = 50000

defaultSequenceLength :: Int
defaultSequenceLength = 100

Expand Down
6 changes: 4 additions & 2 deletions lib/Echidna/UI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ ui vm world dict initialCorpus = do

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

chunkSize = ceiling
(fromIntegral (length initialCorpus) / fromIntegral nworkers :: Double)
Expand Down
4 changes: 2 additions & 2 deletions lib/Echidna/UI/Widgets.hs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ summaryWidget env uiState =
<=>
perfWidget uiState
<=>
str ("Total calls: " <> progress (sum $ (.ncalls) <$> uiState.campaigns)
env.cfg.campaignConf.testLimit)
str ("Total calls: " <> maybe (show totalCalls) (progress totalCalls) env.cfg.campaignConf.testLimit)
totalCalls = (sum $ (.ncalls) <$> uiState.campaigns)
middle =
padLeft (Pad 1) $
str ("Unique instructions: " <> show uiState.coverage)
Expand Down
4 changes: 2 additions & 2 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ options = Options
<> help "Timeout given in seconds.")
<*> optional (option auto $ long "test-limit"
<> metavar "INTEGER"
<> help ("Number of sequences of transactions to generate during testing. Default is " ++ show defaultTestLimit))
<> help "Number of sequences of transactions to generate during testing. Default is unbounded.")
<*> optional (option auto $ long "rpc-block"
<> metavar "BLOCK"
<> help "Block number to use when fetching over RPC.")
Expand Down Expand Up @@ -239,7 +239,7 @@ overrideConfig config Options{..} = do

overrideCampaignConf campaignConf = campaignConf
{ corpusDir = cliCorpusDir <|> campaignConf.corpusDir
, testLimit = fromMaybe campaignConf.testLimit cliTestLimit
, testLimit = cliTestLimit <|> campaignConf.testLimit
, shrinkLimit = fromMaybe campaignConf.shrinkLimit cliShrinkLimit
, seqLen = fromMaybe campaignConf.seqLen cliSeqLen
, seed = cliSeed <|> campaignConf.seed
Expand Down
2 changes: 1 addition & 1 deletion src/test/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ overrideQuiet conf =

overrideLimits :: EConfig -> EConfig
overrideLimits conf =
conf { campaignConf = conf.campaignConf { testLimit = 10000
conf { campaignConf = conf.campaignConf { testLimit = Just 10000
, shrinkLimit = 4000 }}

type SolcVersion = Version
Expand Down
2 changes: 1 addition & 1 deletion src/test/Tests/Seed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ seedTests =
where
cfg s = defaultConfig
{ campaignConf = CampaignConf
{ testLimit = 600
{ testLimit = Just 600
, stopOnFail = False
, estimateGas = False
, seqLen = 20
Expand Down
1 change: 1 addition & 0 deletions tests/solidity/research/ilf_crowdsale.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
maxValue: 10000000000000000000000000
testMode: assertion
testLimit: 50000
Loading