Use fmap and clarify readme

pull/37/head
Connor Christie 7 years ago
parent 04d20b37e5
commit 581f78d6e4
  1. 10
      README.md
  2. 12
      lib/Echidna/Solidity.hs
  3. 24
      package.yaml
  4. 8
      src/Main.hs
  5. 2
      stack.yaml

@ -58,6 +58,11 @@ For each unit test it finds, it will execute a fuzzing campaign to try and find
An example contract with tests can be found [solidity/cli.sol](solidity/cli.sol)
`echidna-test solidity/cli.sol` should find a call sequence such that `echidna_sometimesfalse` fails, but be unable to do so for `echidna_alwaystrue`.
Support for multiple contracts in a single file along with importing files from an unsupported directory has bee added by using the following optional command line arguments:
```
echidna-test solidity/cli.sol Test2 --solc-args="--allow-paths=/echidna/solidity"
```
## Usage (as a library)
Echidna is actively being developed with relatively little regard for stability.
@ -140,11 +145,6 @@ The [state machine example](examples/state-machine/StateMachine.hs) is a pretty
This module provides `loadSolidity`, which takes a solidity source file and provides a VM with the first contract therein loaded as well as a `fuzz`-compatible ABI definition.
Support for multiple contracts in a single file along with importing files from an unsupported directory has bee added by using the following optional command line arguments:
```
echidna-test solidity/cli.sol Test2 --solc-args="--allow-paths=/Users/connor/Documents/echidna/solidity"
```
## Questions/complaints/etc.
Join us in #ethereum on the [Empire Hacking Slack](https://empireslacking.herokuapp.com), or email [JP Smith](mailto:jp@trailofbits.com) (the lead author) directly.

@ -12,9 +12,9 @@ import Control.Monad.State.Strict (execState, runState)
import Data.Foldable (toList)
import Data.List (find, partition)
import Data.Map ()
import Data.Maybe (isNothing)
import Data.Maybe (isNothing, fromMaybe)
import Data.Monoid ((<>))
import Data.Text (Text, isPrefixOf, split, pack, unpack)
import Data.Text (Text, isPrefixOf, unpack)
import System.Process (readProcess)
import System.IO.Temp (writeSystemTempFile)
@ -41,11 +41,9 @@ instance Exception EchidnaException
-- | parses additional solc arguments
solcArguments :: FilePath -> Maybe Text -> [String]
solcArguments filePath argStr = map unpack (args <> additional)
where args = ["--combined-json=bin-runtime,bin,srcmap,srcmap-runtime,abi,ast", pack filePath]
additional = case argStr of
Nothing -> []
(Just a) -> split (==' ') a
solcArguments filePath argStr = args <> fromMaybe [] additional
where args = ["--combined-json=bin-runtime,bin,srcmap,srcmap-runtime,abi,ast", filePath]
additional = words . unpack <$> argStr
-- | reads all contracts within the solidity file at `filepath` and passes optional solc params to compiler
readContracts :: (MonadIO m, MonadThrow m) => FilePath -> Maybe Text -> m [SolcContract]

@ -9,24 +9,24 @@ ghc-options: -Wall
dependencies:
- base
- ansi-terminal
- bytestring >= 0.10.8 && < 0.11
- containers >= 0.5.7 && < 0.6
- data-dword >= 0.3.1 && < 0.4
- bytestring >= 0.10.8 && < 0.11
- containers >= 0.5.7 && < 0.6
- data-dword >= 0.3.1 && < 0.4
- directory
- exceptions >= 0.8.1 && < 0.9
- exceptions >= 0.8.1 && < 0.9
- hedgehog
- hevm
- lens >= 4.15.1 && < 4.16
- mtl >= 2.2.1 && < 2.3
- multiset >= 0.3 && < 0.4
- process >= 1.4.3 && < 1.5
- lens >= 4.15.1 && < 4.16
- mtl >= 2.2.1 && < 2.3
- multiset >= 0.3 && < 0.4
- optparse-applicative >= 0.12.0 && < 0.14
- process >= 1.4.3 && < 1.5
- stm
- temporary >= 1.2.1 && < 1.3
- text >= 1.2.2 && < 1.3
- temporary >= 1.2.1 && < 1.3
- text >= 1.2.2 && < 1.3
- transformers
- vector >= 0.11.0 && < 0.13
- vector >= 0.11.0 && < 0.13
- wl-pprint-annotated
- optparse-applicative >= 0.12.0 && < 0.14
default-extensions:
- OverloadedStrings

@ -5,7 +5,7 @@ module Main where
import Control.Concurrent.MVar (takeMVar, newMVar)
import Data.MultiSet (distinctSize)
import Data.Text (Text, pack)
import Data.Text (pack)
import Data.Semigroup ((<>))
import Echidna.Exec
@ -33,10 +33,6 @@ options = Options
( long "solc-args"
<> help "Optional solidity compiler arguments" ))
maybePack :: Maybe String -> Maybe Text
maybePack (Just s) = Just (pack s)
maybePack Nothing = Nothing
opts :: ParserInfo Options
opts = info (options <**> helper)
( fullDesc
@ -46,7 +42,7 @@ opts = info (options <**> helper)
main :: IO ()
main = do
(Options f c s) <- execParser opts
(v,a,ts) <- loadSolidity f (maybePack c) (maybePack s)
(v,a,ts) <- loadSolidity f (pack <$> c) (pack <$> s)
r <- newMVar (mempty :: Coverage)
let prop t = (PropertyName $ show t
, ePropertySeqCoverage r (flip checkETest t) a v 10

@ -14,6 +14,7 @@ extra-deps:
- HSH-2.1.3
- ipprint-0.6
- megaparsec-6.4.0
- optparse-applicative-0.13.2.0
- parser-combinators-0.4.0
- restless-git-0.5.0
- rosezipper-0.2
@ -22,4 +23,3 @@ extra-deps:
- tree-view-0.5
- vty-5.16
- word-wrap-0.4.1
- optparse-applicative-0.13.2.0

Loading…
Cancel
Save