From 2eb3d33b23bf20b60f8594f1fcb5b1a44493cade Mon Sep 17 00:00:00 2001 From: Nikhil Parasaram Date: Thu, 16 May 2019 13:40:05 +0530 Subject: [PATCH] Add cli tests for error --- mythril/interfaces/cli.py | 6 ------ tests/cli_tests/cmd_line_test.py | 13 +++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/mythril/interfaces/cli.py b/mythril/interfaces/cli.py index 1fd1f140..6bbc4885 100644 --- a/mythril/interfaces/cli.py +++ b/mythril/interfaces/cli.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): hash_parser.add_argument( "func_name", help="calculate function signature hash", metavar="SIGNATURE" diff --git a/tests/cli_tests/cmd_line_test.py b/tests/cli_tests/cmd_line_test.py index d7ed5967..765e4022 100644 --- a/tests/cli_tests/cmd_line_test.py +++ b/tests/cli_tests/cmd_line_test.py @@ -27,6 +27,19 @@ class CommandLineToolTestCase(BaseTestCase): command = "python3 {} function-to-hash 'setOwner(address)'".format(MYTH) 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): def test_analysis_truffle_project(self):