Adds basic disassemble test

pull/603/head
Joran Honig 6 years ago
parent c4c9e56c6a
commit 1ffa64ed09
  1. 6
      mythril/disassembler/asm.py
  2. 10
      tests/disassembler/asm.py

@ -99,8 +99,8 @@ def disassemble(bytecode: str) -> list:
current_instruction.argument = "0x" + argument_bytes.hex()
address += int(match.group(1))
# We use a to_dict() here for compatibility reasons
instruction_list.append(current_instruction.to_dict())
instruction_list.append(current_instruction)
address += 1
return instruction_list
# We use a to_dict() here for compatibility reasons
return list(map(lambda element: element.to_dict(), instruction_list))

@ -58,3 +58,13 @@ def test_find_op_code_sequence(pattern, instruction_list, expected_result):
# Assert
assert return_value == expected_result
def test_disassemble():
# Act
instruction_list = disassemble(b"\x00\x16\x06")
# Assert
assert instruction_list[0]["opcode"] == "STOP"
assert instruction_list[1]["opcode"] == "AND"
assert instruction_list[2]["opcode"] == "MOD"

Loading…
Cancel
Save