コード例 #1
0
    def test_insert_check_end(self):
        instructions = self.evmcode.disassemble()

        instructions.insert(0, registry.create_instruction(name="JUMPDEST"))

        for idx in range(len(instructions)):
            instructions.insert(-idx,
                                registry.create_instruction(name="JUMPDEST"))
        self._check_address_linear(instructions)

        for _ in range(len(instructions)):
            idx = random.randint(0, len(instructions) - 1)
            instructions.insert(idx,
                                registry.create_instruction(name="JUMPDEST"))
        self._check_address_linear(instructions)
コード例 #2
0
ファイル: test_instruction.py プロジェクト: paulyc/evmdasm
    def test_instruction_set_operand_bytes(self):
        value = b'\xc0\xfe\xfe'
        push = registry.create_instruction("PUSH%d" % len(value))
        push.operand_bytes = value

        self.assertEqual(push.operand, utils.bytes_to_str(value, prefix=""))
        self.assertEqual(push.operand_bytes, value)
        self.assertEqual(push.operand_length, len(value))
コード例 #3
0
ファイル: test_instruction.py プロジェクト: paulyc/evmdasm
    def test_instruction_set_operand(self):
        value = "c0fefe"
        push = registry.create_instruction("PUSH%d" % len(value))
        push.operand = value

        self.assertEqual(push.operand, value)
        self.assertEqual(push.operand_bytes, utils.str_to_bytes(value))
        self.assertEqual(push.operand_length, len(value))
コード例 #4
0
    def test_append_check_end_no_fix_address(self):
        instructions = self.evmcode.disassemble()
        instructions._fix_addresses = False

        for _ in range(4000):
            instructions.append(registry.create_instruction(name="JUMPDEST"))

        error = False
        pc = instructions[0].address
        for instr in instructions:
            if not instr.address == pc:
                error = True
                break
            pc += len(instr)
        self.assertTrue(error)
コード例 #5
0
 def test_append_check_end_getitem(self):
     instructions = self.evmcode.disassemble()
     for _ in range(4000):
         instructions.append(registry.create_instruction(name="JUMPDEST"))
     self._check_address_linear_getitem(instructions)
     self._check_address_linear_getitem(instructions)
コード例 #6
0
 def test_create_instruction(self):
     self.assertEqual(registry.instruction.JUMP,
                      registry.INSTRUCTIONS_BY_NAME["JUMP"])
     self.assertNotEqual(registry.instruction.JUMP,
                         registry.create_instruction(name="JUMP"))