Add boolean opcodes & other

- Add boolean opcodes
- Add jump_dest validity check
- Add tests for opcode exceptions
- Update calldataload opcode logic
- Add stack.peek()
This commit is contained in:
arnaucube
2021-09-25 18:42:44 +02:00
parent 9a4abfdf6e
commit dac8a29e7e
4 changed files with 119 additions and 6 deletions

View File

@@ -215,9 +215,29 @@ fn execute_opcodes_9() {
let mut s = Stack::new();
s.execute(&code, &calldata, false).unwrap();
assert_eq!(s.gas, 9999974988);
// assert_eq!(s.gas, 9999977788); // TODO WIP geth reported gas
assert_eq!(s.gas, 9999974988);
assert_eq!(s.pc, 10);
assert_eq!(s.stack.len(), 0);
assert_eq!(s.storage.len(), 1);
}
#[test]
fn execute_opcodes_10() {
let code = hex::decode(
"606060405260e060020a6000350463a5f3c23b8114601a575b005b60243560043501600055601856",
)
.unwrap();
let calldata = hex::decode("a5f3c23b00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000004").unwrap();
println!("LEN {:?}", calldata.len());
let mut s = Stack::new();
s.execute(&code, &calldata, true).unwrap();
// assert_eq!(s.gas, 9999977752); // WIP correct sstore gas computation
assert_eq!(s.gas, 9999979852);
assert_eq!(s.pc, 25);
assert_eq!(s.stack.len(), 1);
assert_eq!(s.storage.len(), 1);
}