Add more tests for storage slots and execution

pull/1033/head
Nikhil Parasaram 6 years ago
parent cbe5a656f0
commit 46c1b29528
  1. 14
      mythril/interfaces/cli.py
  2. 12
      tests/cmd_line_test.py

@ -397,17 +397,11 @@ def validate_args(args: Namespace):
"The --query-signature function requires the python package ethereum-input-decoder",
)
if args.enable_iprof:
if args.v < 4:
if args.enable_iprof and args.v < 4:
exit_with_error(
args.outform,
"--enable-iprof must be used with -v LOG_LEVEL where LOG_LEVEL >= 4",
)
elif not (args.graph or args.fire_lasers or args.statespace_json):
exit_with_error(
args.outform,
"--enable-iprof must be used with one of -g, --graph, -x, --fire-lasers, -j and --statespace-json",
)
def set_config(args: Namespace):
@ -512,12 +506,6 @@ def execute_command(
"""
if args.command == "read-storage":
if not args.address:
exit_with_error(
args.outform,
"To read storage, provide the address of a deployed contract with the -a option.",
)
storage = disassembler.get_state_variable_from_storage(
address=address,
params=[a.strip() for a in args.storage_slots.strip().split(",")],

@ -46,6 +46,18 @@ class CommandLineToolTestCase(BaseTestCase):
command = "python3 {} analyze {}".format(MYTH, solidity_file)
self.assertIn("111", output_of(command))
def test_analyze_bytecode(self):
solidity_file = str(TESTDATA / "inputs" / "origin.sol.o")
command = "python3 {} analyze --bin-runtime -f {}".format(MYTH, solidity_file)
self.assertIn("111", output_of(command))
def test_invalid_args_iprof(self):
solidity_file = str(TESTDATA / "input_contracts" / "origin.sol")
command = "python3 {} analyze {} --enable-iprof -o json".format(
MYTH, solidity_file
)
self.assertIn(""""success": false""", output_of(command))
class TruffleTestCase(BaseTestCase):
def test_analysis_truffle_project(self):

Loading…
Cancel
Save