diff --git a/mythril/disassembler/asm.py b/mythril/disassembler/asm.py index 8eca0c8e..6308b5d8 100644 --- a/mythril/disassembler/asm.py +++ b/mythril/disassembler/asm.py @@ -42,7 +42,7 @@ def get_opcode_from_name(operation_name): 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 :param pattern: The pattern to look for. diff --git a/tests/disassembler/__init__.py b/tests/disassembler/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/disassembler/asm.py b/tests/disassembler/asm.py new file mode 100644 index 00000000..4eaada3f --- /dev/null +++ b/tests/disassembler/asm.py @@ -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)