33import tempfile
44
55from .ascii_escapes import decode
6- from .client import JSONRPCError
76from .etheno import EthenoPlugin
87from .utils import ConstantTemporaryFile , format_hex_address
98
2827}
2928'''
3029
31- ECHIDNA_CONFIG = b'''outputRawTxs: True\n gasLimit: 0xfffff\n '''
30+ ECHIDNA_CONFIG = b'''outputRawTxs: true\n quiet: true\n dashboard: false\n gasLimit: 0xfffff\n '''
31+
3232
3333def echidna_exists ():
3434 return subprocess .call (['/usr/bin/env' , 'echidna-test' , '--help' ], stdout = subprocess .DEVNULL ) == 0
3535
36+
3637def stack_exists ():
3738 return subprocess .call (['/usr/bin/env' , 'stack' , '--help' ], stdout = subprocess .DEVNULL ) == 0
3839
40+
3941def git_exists ():
4042 return subprocess .call (['/usr/bin/env' , 'git' , '--version' ], stdout = subprocess .DEVNULL ) == 0
4143
44+
4245def install_echidna (allow_reinstall = False ):
4346 if not allow_reinstall and echidna_exists ():
4447 return
@@ -49,10 +52,11 @@ def install_echidna(allow_reinstall = False):
4952
5053 with tempfile .TemporaryDirectory () as path :
5154 subprocess .check_call (['/usr/bin/env' , 'git' , 'clone' , 'https://github.com/trailofbits/echidna.git' , path ])
52- # TODO: Once the `dev-no-hedgehog ` branch is merged into `master`, we can remove this:
53- subprocess .call (['/usr/bin/env' , 'git' , 'checkout' , 'dev-no-hedgehog ' ], cwd = path )
55+ # TODO: Once the `dev-etheno ` branch is merged into `master`, we can remove this:
56+ subprocess .call (['/usr/bin/env' , 'git' , 'checkout' , 'dev-etheno ' ], cwd = path )
5457 subprocess .check_call (['/usr/bin/env' , 'stack' , 'install' ], cwd = path )
55-
58+
59+
5660def decode_binary_json (text ):
5761 orig = text
5862 text = decode (text ).strip ()
@@ -73,6 +77,7 @@ def decode_binary_json(text):
7377 raise ValueError ("Malformed JSON list! Expected '%s' but instead got '%s' at offset %d" % ('"' , chr (text [- 1 ]), offset + len (text ) - 1 ))
7478 return text [:- 1 ]
7579
80+
7681class EchidnaPlugin (EthenoPlugin ):
7782 def __init__ (self , transaction_limit = None , contract_source = None ):
7883 self ._transaction = 0
@@ -93,6 +98,9 @@ def run(self):
9398 self .logger .info ("Etheno does not know about any accounts, so Echidna has nothing to do!" )
9499 self ._shutdown ()
95100 return
101+ elif self .contract_source is None :
102+ self .logger .error ("Error compiling source contract" )
103+ self ._shutdown ()
96104 # First, deploy the testing contract:
97105 self .logger .info ('Deploying Echidna test contract...' )
98106 self .contract_address = format_hex_address (self .etheno .deploy_contract (self .etheno .accounts [0 ], self .contract_bytecode ), True )
@@ -172,5 +180,6 @@ def emit_transaction(self, txn):
172180 self .logger .info ("Emitting Transaction %d" % self ._transaction )
173181 self .etheno .post (transaction )
174182
183+
175184if __name__ == '__main__' :
176- install_echidna (allow_reinstall = True )
185+ install_echidna (allow_reinstall = True )
0 commit comments