diff --git a/core/asm/asm_test.go b/core/asm/asm_test.go index 92b26b67a5..87240f35ad 100644 --- a/core/asm/asm_test.go +++ b/core/asm/asm_test.go @@ -55,6 +55,24 @@ func TestInstructionIteratorInvalid(t *testing.T) { } } +// Tests disassembling the instructions for PUSH0 +func TestInstructionIteratorPUSH0(t *testing.T) { + cnt := 0 + script, _ := hex.DecodeString("5900") + + it := NewInstructionIterator(script) + for it.Next() { + cnt++ + } + + if err := it.Error(); err != nil { + t.Errorf("Expected 2, but encountered error %v instead.", err) + } + if cnt != 2 { + t.Errorf("Expected 2, but got %v instead.", cnt) + } +} + // Tests disassembling the instructions for empty evm code func TestInstructionIteratorEmpty(t *testing.T) { cnt := 0 diff --git a/core/vm/opcodes.go b/core/vm/opcodes.go index c7a3a163be..2b9231fe1a 100644 --- a/core/vm/opcodes.go +++ b/core/vm/opcodes.go @@ -25,7 +25,7 @@ type OpCode byte // IsPush specifies if an opcode is a PUSH opcode. func (op OpCode) IsPush() bool { - return PUSH1 <= op && op <= PUSH32 + return PUSH0 <= op && op <= PUSH32 } // 0x0 range - arithmetic ops.