mirror of
https://github.com/arnaucube/evm-rs.git
synced 2026-02-02 17:06:40 +01:00
Add jump_dest check, add opcode exceptions tests
This commit is contained in:
@@ -169,6 +169,29 @@ fn execute_opcodes_7() {
|
||||
assert_eq!(out, hex::decode("6005600401").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn execute_exceptions() {
|
||||
let mut s = Stack::new();
|
||||
let calldata = hex::decode("").unwrap();
|
||||
|
||||
let code = hex::decode("5f").unwrap();
|
||||
let out = s.execute(&code, &calldata, false);
|
||||
assert_eq!(out, Err(format!("invalid opcode 5f")));
|
||||
|
||||
let code = hex::decode("56").unwrap();
|
||||
let out = s.execute(&code, &calldata, false);
|
||||
assert_eq!(out, Err(format!("pop err")));
|
||||
|
||||
let code = hex::decode("600056").unwrap();
|
||||
let out = s.execute(&code, &calldata, false);
|
||||
assert_eq!(out, Err(format!("not valid dest: 00")));
|
||||
|
||||
s.gas = 1;
|
||||
let code = hex::decode("6000").unwrap();
|
||||
let out = s.execute(&code, &calldata, false);
|
||||
assert_eq!(out, Err(format!("out of gas")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn execute_opcodes_8() {
|
||||
let code = hex::decode("611000805151").unwrap();
|
||||
@@ -190,7 +213,7 @@ fn execute_opcodes_9() {
|
||||
let calldata = hex::decode("").unwrap();
|
||||
|
||||
let mut s = Stack::new();
|
||||
s.execute(&code, &calldata, true).unwrap();
|
||||
s.execute(&code, &calldata, false).unwrap();
|
||||
|
||||
assert_eq!(s.gas, 9999974988);
|
||||
// assert_eq!(s.gas, 9999977788); // TODO WIP geth reported gas
|
||||
|
||||
Reference in New Issue
Block a user