Skip to content

Commit

Permalink
fix(evm): dont panic on unknown opcode
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-Becker committed Nov 17, 2023
1 parent 9985590 commit 06ab7ae
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions common/src/ether/evm/core/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl Opcode {
0xfd => Opcode { code, name: "REVERT", mingas: 0, inputs: 2, outputs: 0 },
0xfe => Opcode { code, name: "INVALID", mingas: 0, inputs: 0, outputs: 0 },
0xff => Opcode { code, name: "SELFDESTRUCT", mingas: 5000, inputs: 1, outputs: 0 },
_ => panic!("Invalid opcode: {}", code),
_ => Opcode { code, name: "unknown", mingas: 0, inputs: 0, outputs: 0 },
}
}
}
Expand Down Expand Up @@ -256,9 +256,8 @@ mod tests {

#[test]
fn test_get_unknown_opcode() {
let unknown_opcode = Opcode::new(0x00);
assert_eq!(unknown_opcode.code, 0x00);
assert_eq!(unknown_opcode.name, "INVALID");
let unknown_opcode = Opcode::new(0xee);
assert_eq!(unknown_opcode.name, "unknown");
}

#[test]
Expand Down

0 comments on commit 06ab7ae

Please sign in to comment.