-
Notifications
You must be signed in to change notification settings - Fork 372
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
Code cleanup #906
Code cleanup #906
Conversation
@@ -12,21 +12,18 @@ import System.Directory (createDirectoryIfMissing, makeRelativeToCurrentDirector | |||
import Echidna.Types.Tx | |||
import Echidna.Output.Utils | |||
|
|||
saveTxs :: Maybe FilePath -> [[Tx]] -> IO () | |||
saveTxs (Just d) txs = mapM_ saveTx txs where | |||
saveTxs :: FilePath -> [[Tx]] -> IO () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change correct? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe is now matched earlier:
-- save corpus
case cfg._cConf._corpusDir of
Nothing -> pure ()
Just dir -> do
saveTxs (dir </> "reproducers") (filter (not . null) $ (.testReproducer) <$> cpg._tests)
saveTxs (dir </> "coverage") (snd <$> Set.toList cpg._corpus)
@@ -104,16 +106,18 @@ removeJsonFiles dir = | |||
let path = dir </> file | |||
whenM (doesFileExist path) $ removeFile path | |||
|
|||
addresses :: SolConf -> NE.NonEmpty AbiValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NonEmpty has different properties than Set, so I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish there were a non-empty set, but Set is better for what we do here as we pick random elements and list/non-empty list has slow random access. We would need to convert lists to sets, that takes linear time which kills the performance during fuzzing.
I'm getting this error when trying to save a corpus:
|
Fixed. Apparently, I got confused by the variable names so fixed them too. |
This PR features various cleanup and simplifications in the entirety of code:
OverloadedRecordDot
as much as possible</>
operator for path joiningSet
s instead of (NE)lists. This is good for generating random data as picking random elements from a largeSet
is way faster than listsgeneric-lens
oroptics-core
in the future.