eth/tracers/js: fix isPush for push0

This commit is contained in:
Sina Mahmoodi 2023-11-13 19:35:31 +03:00
parent f265cc24b4
commit 50c8e8c7bc
2 changed files with 19 additions and 1 deletions

View file

@ -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

View file

@ -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.