From cbe5a656f0fd151f70e72373032b187b754fa17f Mon Sep 17 00:00:00 2001 From: Nikhil Parasaram Date: Fri, 17 May 2019 11:37:23 +0530 Subject: [PATCH] Add more tests and change docs --- mythril/interfaces/cli.py | 14 ++++++++------ tests/cmd_line_test.py | 6 ++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/mythril/interfaces/cli.py b/mythril/interfaces/cli.py index ddb1cb32..bfa5dd1d 100644 --- a/mythril/interfaces/cli.py +++ b/mythril/interfaces/cli.py @@ -119,7 +119,7 @@ def get_output_parser() -> ArgumentParser: def get_rpc_parser() -> ArgumentParser: """ Get parser which handles RPC flags - :return: c + :return: Parser which handles rpc inputs """ parser = argparse.ArgumentParser(add_help=False) parser.add_argument( @@ -137,7 +137,7 @@ def get_rpc_parser() -> ArgumentParser: def get_utilities_parser() -> ArgumentParser: """ Get parser which handles utilities flags - :return: Get parser which handles utility flags + :return: Parser which handles utility flags """ parser = argparse.ArgumentParser(add_help=False) parser.add_argument("--solc-args", help="Extra arguments for solc") @@ -163,21 +163,23 @@ def main() -> None: subparsers = parser.add_subparsers(dest="command", help="Commands") analyzer_parser = subparsers.add_parser( "analyze", - help="Triggers analysis of smart contract", + help="Triggers the analysis of the smart contract", parents=[rpc_parser, utilities_parser, input_parser, output_parser], ) disassemble_parser = subparsers.add_parser( "disassemble", - help="Disassembles smart contract", + help="Disassembles the smart contract", parents=[rpc_parser, utilities_parser, input_parser, output_parser], ) read_storage_parser = subparsers.add_parser( "read-storage", - help="Retrieves storage slots from rpc address", + help="Retrieves storage slots from a given address through rpc", parents=[rpc_parser, output_parser], ) leveldb_search_parser = subparsers.add_parser( - "leveldb-search", parents=[output_parser], help="Search code in local leveldb" + "leveldb-search", + parents=[output_parser], + help="Searches the code fragment in local leveldb", ) contract_func_to_hash = subparsers.add_parser( "function-to-hash", diff --git a/tests/cmd_line_test.py b/tests/cmd_line_test.py index 765e4022..528bbf9a 100644 --- a/tests/cmd_line_test.py +++ b/tests/cmd_line_test.py @@ -1,5 +1,6 @@ from subprocess import check_output from tests import BaseTestCase, TESTDATA, PROJECT_DIR, TESTS_DIR +from mock import patch MYTH = str(PROJECT_DIR / "myth") @@ -40,6 +41,11 @@ class CommandLineToolTestCase(BaseTestCase): command = "python3 {} analyze doesnt_exist.sol -o jsonv2".format(MYTH) self.assertIn(""""level": "error""" "", output_of(command)) + def test_analyze(self): + solidity_file = str(TESTDATA / "input_contracts" / "origin.sol") + command = "python3 {} analyze {}".format(MYTH, solidity_file) + self.assertIn("111", output_of(command)) + class TruffleTestCase(BaseTestCase): def test_analysis_truffle_project(self):