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) 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`. `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) ## Usage (as a library)
Echidna is actively being developed with relatively little regard for stability. 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. 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. ## 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. 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.Foldable (toList)
import Data.List (find, partition) import Data.List (find, partition)
import Data.Map () import Data.Map ()
import Data.Maybe (isNothing) import Data.Maybe (isNothing, fromMaybe)
import Data.Monoid ((<>)) import Data.Monoid ((<>))
import Data.Text (Text, isPrefixOf, split, pack, unpack) import Data.Text (Text, isPrefixOf, unpack)
import System.Process (readProcess) import System.Process (readProcess)
import System.IO.Temp (writeSystemTempFile) import System.IO.Temp (writeSystemTempFile)
@ -41,11 +41,9 @@ instance Exception EchidnaException
-- | parses additional solc arguments -- | parses additional solc arguments
solcArguments :: FilePath -> Maybe Text -> [String] solcArguments :: FilePath -> Maybe Text -> [String]
solcArguments filePath argStr = map unpack (args <> additional) solcArguments filePath argStr = args <> fromMaybe [] additional
where args = ["--combined-json=bin-runtime,bin,srcmap,srcmap-runtime,abi,ast", pack filePath] where args = ["--combined-json=bin-runtime,bin,srcmap,srcmap-runtime,abi,ast", filePath]
additional = case argStr of additional = words . unpack <$> argStr
Nothing -> []
(Just a) -> split (==' ') a
-- | reads all contracts within the solidity file at `filepath` and passes optional solc params to compiler -- | 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] readContracts :: (MonadIO m, MonadThrow m) => FilePath -> Maybe Text -> m [SolcContract]

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

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

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

Loading…
Cancel
Save