Add cli tests for error

pull/1033/head
Nikhil Parasaram 6 years ago
parent 7611d2b01a
commit 2eb3d33b23
  1. 6
      mythril/interfaces/cli.py
  2. 13
      tests/cli_tests/cmd_line_test.py

@ -215,12 +215,6 @@ def create_leveldb_parser(parser: argparse.ArgumentParser):
) )
def create_version_parser(hash_parser: argparse.ArgumentParser):
hash_parser.add_argument(
"version", help="print the Mythril version number and exit", metavar="VERSION"
)
def create_func_to_hash_parser(hash_parser: argparse.ArgumentParser): def create_func_to_hash_parser(hash_parser: argparse.ArgumentParser):
hash_parser.add_argument( hash_parser.add_argument(
"func_name", help="calculate function signature hash", metavar="SIGNATURE" "func_name", help="calculate function signature hash", metavar="SIGNATURE"

@ -27,6 +27,19 @@ class CommandLineToolTestCase(BaseTestCase):
command = "python3 {} function-to-hash 'setOwner(address)'".format(MYTH) command = "python3 {} function-to-hash 'setOwner(address)'".format(MYTH)
self.assertIn("0x13af4035\n", output_of(command)) self.assertIn("0x13af4035\n", output_of(command))
def test_failure_json(self):
command = "python3 {} analyze doesnt_exist.sol -o json".format(MYTH)
print(output_of(command))
self.assertIn(""""success": false""", output_of(command))
def test_failure_text(self):
command = "python3 {} analyze doesnt_exist.sol".format(MYTH)
assert output_of(command) == ""
def test_failure_jsonv2(self):
command = "python3 {} analyze doesnt_exist.sol -o jsonv2".format(MYTH)
self.assertIn(""""level": "error""" "", output_of(command))
class TruffleTestCase(BaseTestCase): class TruffleTestCase(BaseTestCase):
def test_analysis_truffle_project(self): def test_analysis_truffle_project(self):

Loading…
Cancel
Save