Remove generator type and add asm get opcode tests

pull/603/head
Joran Honig 6 years ago
parent c161b90c86
commit 0fa27b8e21
  1. 2
      mythril/disassembler/asm.py
  2. 0
      tests/disassembler/__init__.py
  3. 20
      tests/disassembler/asm.py

@ -42,7 +42,7 @@ def get_opcode_from_name(operation_name):
raise RuntimeError("Unknown opcode") raise RuntimeError("Unknown opcode")
def find_op_code_sequence(pattern, instruction_list) -> Generator[int, None, None]: def find_op_code_sequence(pattern, instruction_list):
""" """
Returns all indices in instruction_list that point to instruction sequences following a pattern Returns all indices in instruction_list that point to instruction sequences following a pattern
:param pattern: The pattern to look for. :param pattern: The pattern to look for.

@ -0,0 +1,20 @@
from mythril.disassembler.asm import *
import pytest
valid_names = [("PUSH1", 0x60), ("STOP", 0x0), ("RETURN", 0xf3)]
@pytest.mark.parametrize("operation_name, hex_value", valid_names)
def test_get_opcode(operation_name: str, hex_value: int):
# Act
return_value = get_opcode_from_name(operation_name)
# Assert
assert return_value == hex_value
def test_get_unknown_opcode():
operation_name = "definitely unknown"
# Act
with pytest.raises(RuntimeError):
get_opcode_from_name(operation_name)
Loading…
Cancel
Save