Add new tests, fix an edge case and improve code and help messages

pull/1033/head
Nikhil Parasaram 5 years ago
parent 1b24009344
commit fd397ed232
  1. 9
      mythril/interfaces/cli.py
  2. 4
      tests/cmd_line_test.py

@ -538,9 +538,8 @@ def execute_command(
params=[a.strip() for a in args.storage_slots.strip().split(",")],
)
print(storage)
return
if args.command in DISASSEMBLE_LIST:
elif args.command in DISASSEMBLE_LIST:
if disassembler.contracts[0].code:
print("Runtime Disassembly: \n" + disassembler.contracts[0].get_easm())
if disassembler.contracts[0].creation_code:
@ -634,8 +633,6 @@ def parse_args_and_execute(parser: ArgumentParser, args: Namespace) -> None:
:param parser: The parser
:param args: The args
"""
if args.command not in COMMAND_LIST:
parser.print_usage()
if args.epic:
path = os.path.dirname(os.path.realpath(__file__))
@ -643,6 +640,10 @@ def parse_args_and_execute(parser: ArgumentParser, args: Namespace) -> None:
os.system(" ".join(sys.argv) + " | python3 " + path + "/epic.py")
sys.exit()
if args.command not in COMMAND_LIST or args.command is None:
parser.print_help()
sys.exit()
if args.command == "version":
if args.outform == "json":
print(json.dumps({"version_str": VERSION}))

@ -58,6 +58,10 @@ class CommandLineToolTestCase(BaseTestCase):
)
self.assertIn(""""success": false""", output_of(command))
def test_only_epic(self):
command = "python3 {}".format(MYTH)
self.assertIn("usage: ", output_of(command))
def test_storage(self):
solidity_file = str(TESTDATA / "input_contracts" / "origin.sol")
command = """python3 {} read-storage "438767356, 3" 0x76799f77587738bfeef09452df215b63d2cfb08a """.format(

Loading…
Cancel
Save