|
|
|
|
@@ -19,17 +19,22 @@ use std::str::FromStr;
|
|
|
|
|
use std::hash::Hash;
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
use std::collections::{HashMap, HashSet};
|
|
|
|
|
use rustc_hex::FromHex;
|
|
|
|
|
use ethereum_types::{U256, H256, Address};
|
|
|
|
|
use vm::{self, ActionParams, ActionValue, Ext};
|
|
|
|
|
use vm::tests::{FakeExt, FakeCall, FakeCallType, test_finalize};
|
|
|
|
|
use factory::Factory;
|
|
|
|
|
use vmtype::VMType;
|
|
|
|
|
use hex_literal::hex;
|
|
|
|
|
|
|
|
|
|
evm_test!{test_add: test_add_int}
|
|
|
|
|
fn test_add(factory: super::Factory) {
|
|
|
|
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
|
|
|
|
let code = "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01600055".from_hex().unwrap();
|
|
|
|
|
// 7f PUSH32 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
|
|
|
|
// 7f PUSH32 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
|
|
|
|
|
// 01 ADD
|
|
|
|
|
// 60 00 PUSH 0
|
|
|
|
|
// 55 SSTORE
|
|
|
|
|
let code = hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.address = address.clone();
|
|
|
|
|
@@ -49,7 +54,12 @@ fn test_add(factory: super::Factory) {
|
|
|
|
|
evm_test!{test_sha3: test_sha3_int}
|
|
|
|
|
fn test_sha3(factory: super::Factory) {
|
|
|
|
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
|
|
|
|
let code = "6000600020600055".from_hex().unwrap();
|
|
|
|
|
// 60 00 PUSH 0
|
|
|
|
|
// 60 00 PUSH 0
|
|
|
|
|
// 20 SHA3
|
|
|
|
|
// 60 00 PUSH 0
|
|
|
|
|
// 55 SSTORE
|
|
|
|
|
let code = hex!("6000600020600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.address = address.clone();
|
|
|
|
|
@@ -69,7 +79,10 @@ fn test_sha3(factory: super::Factory) {
|
|
|
|
|
evm_test!{test_address: test_address_int}
|
|
|
|
|
fn test_address(factory: super::Factory) {
|
|
|
|
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
|
|
|
|
let code = "30600055".from_hex().unwrap();
|
|
|
|
|
// 30 ADDRESS
|
|
|
|
|
// 60 00 PUSH 0
|
|
|
|
|
// 55 SSTORE
|
|
|
|
|
let code = hex!("30600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.address = address.clone();
|
|
|
|
|
@@ -90,7 +103,10 @@ evm_test!{test_origin: test_origin_int}
|
|
|
|
|
fn test_origin(factory: super::Factory) {
|
|
|
|
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
|
|
|
|
let origin = Address::from_str("cd1722f2947def4cf144679da39c4c32bdc35681").unwrap();
|
|
|
|
|
let code = "32600055".from_hex().unwrap();
|
|
|
|
|
// 32 ORIGIN
|
|
|
|
|
// 60 00 PUSH 0
|
|
|
|
|
// 55 SSTORE
|
|
|
|
|
let code = hex!("32600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.address = address.clone();
|
|
|
|
|
@@ -112,7 +128,10 @@ evm_test!{test_sender: test_sender_int}
|
|
|
|
|
fn test_sender(factory: super::Factory) {
|
|
|
|
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
|
|
|
|
let sender = Address::from_str("cd1722f2947def4cf144679da39c4c32bdc35681").unwrap();
|
|
|
|
|
let code = "33600055".from_hex().unwrap();
|
|
|
|
|
// 33 CALLER
|
|
|
|
|
// 60 00 PUSH 0
|
|
|
|
|
// 55 SSTORE
|
|
|
|
|
let code = hex!("33600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.address = address.clone();
|
|
|
|
|
@@ -130,6 +149,27 @@ fn test_sender(factory: super::Factory) {
|
|
|
|
|
assert_store(&ext, 0, "000000000000000000000000cd1722f2947def4cf144679da39c4c32bdc35681");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
evm_test!{test_chain_id: test_chain_id_int}
|
|
|
|
|
fn test_chain_id(factory: super::Factory) {
|
|
|
|
|
// 46 CHAINID
|
|
|
|
|
// 60 00 PUSH 0
|
|
|
|
|
// 55 SSTORE
|
|
|
|
|
let code = hex!("46 60 00 55").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
params.code = Some(Arc::new(code));
|
|
|
|
|
let mut ext = FakeExt::new_istanbul().with_chain_id(9);
|
|
|
|
|
|
|
|
|
|
let gas_left = {
|
|
|
|
|
let vm = factory.create(params, ext.schedule(), ext.depth());
|
|
|
|
|
test_finalize(vm.exec(&mut ext).ok().unwrap()).unwrap()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
assert_eq!(gas_left, U256::from(79_995));
|
|
|
|
|
assert_store(&ext, 0, "0000000000000000000000000000000000000000000000000000000000000009");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
evm_test!{test_extcodecopy: test_extcodecopy_int}
|
|
|
|
|
fn test_extcodecopy(factory: super::Factory) {
|
|
|
|
|
// 33 - sender
|
|
|
|
|
@@ -145,8 +185,8 @@ fn test_extcodecopy(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
|
|
|
|
let sender = Address::from_str("cd1722f2947def4cf144679da39c4c32bdc35681").unwrap();
|
|
|
|
|
let code = "333b60006000333c600051600055".from_hex().unwrap();
|
|
|
|
|
let sender_code = "6005600055".from_hex().unwrap();
|
|
|
|
|
let code = hex!("333b60006000333c600051600055").to_vec();
|
|
|
|
|
let sender_code = hex!("6005600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.address = address.clone();
|
|
|
|
|
@@ -168,7 +208,7 @@ fn test_extcodecopy(factory: super::Factory) {
|
|
|
|
|
evm_test!{test_log_empty: test_log_empty_int}
|
|
|
|
|
fn test_log_empty(factory: super::Factory) {
|
|
|
|
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
|
|
|
|
let code = "60006000a0".from_hex().unwrap();
|
|
|
|
|
let code = hex!("60006000a0").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.address = address.clone();
|
|
|
|
|
@@ -199,7 +239,7 @@ fn test_log_sender(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
|
|
|
|
let sender = Address::from_str("cd1722f3947def4cf144679da39c4c32bdc35681").unwrap();
|
|
|
|
|
let code = "60ff6000533360206000a1".from_hex().unwrap();
|
|
|
|
|
let code = hex!("60ff6000533360206000a1").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.address = address.clone();
|
|
|
|
|
@@ -217,13 +257,13 @@ fn test_log_sender(factory: super::Factory) {
|
|
|
|
|
assert_eq!(ext.logs.len(), 1);
|
|
|
|
|
assert_eq!(ext.logs[0].topics.len(), 1);
|
|
|
|
|
assert_eq!(ext.logs[0].topics[0], H256::from_str("000000000000000000000000cd1722f3947def4cf144679da39c4c32bdc35681").unwrap());
|
|
|
|
|
assert_eq!(ext.logs[0].data, "ff00000000000000000000000000000000000000000000000000000000000000".from_hex().unwrap());
|
|
|
|
|
assert_eq!(ext.logs[0].data, hex!("ff00000000000000000000000000000000000000000000000000000000000000").to_vec());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
evm_test!{test_blockhash: test_blockhash_int}
|
|
|
|
|
fn test_blockhash(factory: super::Factory) {
|
|
|
|
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
|
|
|
|
let code = "600040600055".from_hex().unwrap();
|
|
|
|
|
let code = hex!("600040600055").to_vec();
|
|
|
|
|
let blockhash = H256::from_str("123400000000000000000000cd1722f2947def4cf144679da39c4c32bdc35681").unwrap();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
@@ -245,8 +285,8 @@ fn test_blockhash(factory: super::Factory) {
|
|
|
|
|
evm_test!{test_calldataload: test_calldataload_int}
|
|
|
|
|
fn test_calldataload(factory: super::Factory) {
|
|
|
|
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
|
|
|
|
let code = "600135600055".from_hex().unwrap();
|
|
|
|
|
let data = "0123ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff23".from_hex().unwrap();
|
|
|
|
|
let code = hex!("600135600055").to_vec();
|
|
|
|
|
let data = hex!("0123ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff23").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.address = address.clone();
|
|
|
|
|
@@ -267,7 +307,7 @@ fn test_calldataload(factory: super::Factory) {
|
|
|
|
|
evm_test!{test_author: test_author_int}
|
|
|
|
|
fn test_author(factory: super::Factory) {
|
|
|
|
|
let author = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
|
|
|
|
let code = "41600055".from_hex().unwrap();
|
|
|
|
|
let code = hex!("41600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -287,7 +327,7 @@ fn test_author(factory: super::Factory) {
|
|
|
|
|
evm_test!{test_timestamp: test_timestamp_int}
|
|
|
|
|
fn test_timestamp(factory: super::Factory) {
|
|
|
|
|
let timestamp = 0x1234;
|
|
|
|
|
let code = "42600055".from_hex().unwrap();
|
|
|
|
|
let code = hex!("42600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -307,7 +347,7 @@ fn test_timestamp(factory: super::Factory) {
|
|
|
|
|
evm_test!{test_number: test_number_int}
|
|
|
|
|
fn test_number(factory: super::Factory) {
|
|
|
|
|
let number = 0x1234;
|
|
|
|
|
let code = "43600055".from_hex().unwrap();
|
|
|
|
|
let code = hex!("43600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -327,7 +367,7 @@ fn test_number(factory: super::Factory) {
|
|
|
|
|
evm_test!{test_difficulty: test_difficulty_int}
|
|
|
|
|
fn test_difficulty(factory: super::Factory) {
|
|
|
|
|
let difficulty = U256::from(0x1234);
|
|
|
|
|
let code = "44600055".from_hex().unwrap();
|
|
|
|
|
let code = hex!("44600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -347,7 +387,7 @@ fn test_difficulty(factory: super::Factory) {
|
|
|
|
|
evm_test!{test_gas_limit: test_gas_limit_int}
|
|
|
|
|
fn test_gas_limit(factory: super::Factory) {
|
|
|
|
|
let gas_limit = U256::from(0x1234);
|
|
|
|
|
let code = "45600055".from_hex().unwrap();
|
|
|
|
|
let code = hex!("45600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -366,7 +406,7 @@ fn test_gas_limit(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_mul: test_mul_int}
|
|
|
|
|
fn test_mul(factory: super::Factory) {
|
|
|
|
|
let code = "65012365124623626543219002600055".from_hex().unwrap();
|
|
|
|
|
let code = hex!("65012365124623626543219002600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -384,7 +424,7 @@ fn test_mul(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_sub: test_sub_int}
|
|
|
|
|
fn test_sub(factory: super::Factory) {
|
|
|
|
|
let code = "65012365124623626543219003600055".from_hex().unwrap();
|
|
|
|
|
let code = hex!("65012365124623626543219003600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -402,7 +442,7 @@ fn test_sub(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_div: test_div_int}
|
|
|
|
|
fn test_div(factory: super::Factory) {
|
|
|
|
|
let code = "65012365124623626543219004600055".from_hex().unwrap();
|
|
|
|
|
let code = hex!("65012365124623626543219004600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -420,7 +460,7 @@ fn test_div(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_div_zero: test_div_zero_int}
|
|
|
|
|
fn test_div_zero(factory: super::Factory) {
|
|
|
|
|
let code = "6501236512462360009004600055".from_hex().unwrap();
|
|
|
|
|
let code = hex!("6501236512462360009004600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -438,7 +478,7 @@ fn test_div_zero(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_mod: test_mod_int}
|
|
|
|
|
fn test_mod(factory: super::Factory) {
|
|
|
|
|
let code = "650123651246236265432290066000556501236512462360009006600155".from_hex().unwrap();
|
|
|
|
|
let code = hex!("650123651246236265432290066000556501236512462360009006600155").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -457,7 +497,7 @@ fn test_mod(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_smod: test_smod_int}
|
|
|
|
|
fn test_smod(factory: super::Factory) {
|
|
|
|
|
let code = "650123651246236265432290076000556501236512462360009007600155".from_hex().unwrap();
|
|
|
|
|
let code = hex!("650123651246236265432290076000556501236512462360009007600155").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -476,7 +516,7 @@ fn test_smod(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_sdiv: test_sdiv_int}
|
|
|
|
|
fn test_sdiv(factory: super::Factory) {
|
|
|
|
|
let code = "650123651246236265432290056000556501236512462360009005600155".from_hex().unwrap();
|
|
|
|
|
let code = hex!("650123651246236265432290056000556501236512462360009005600155").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -495,7 +535,7 @@ fn test_sdiv(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_exp: test_exp_int}
|
|
|
|
|
fn test_exp(factory: super::Factory) {
|
|
|
|
|
let code = "6016650123651246230a6000556001650123651246230a6001556000650123651246230a600255".from_hex().unwrap();
|
|
|
|
|
let code = hex!("6016650123651246230a6000556001650123651246230a6001556000650123651246230a600255").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -515,7 +555,7 @@ fn test_exp(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_comparison: test_comparison_int}
|
|
|
|
|
fn test_comparison(factory: super::Factory) {
|
|
|
|
|
let code = "601665012365124623818181811060005511600155146002556415235412358014600355".from_hex().unwrap();
|
|
|
|
|
let code = hex!("601665012365124623818181811060005511600155146002556415235412358014600355").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -536,7 +576,7 @@ fn test_comparison(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_signed_comparison: test_signed_comparison_int}
|
|
|
|
|
fn test_signed_comparison(factory: super::Factory) {
|
|
|
|
|
let code = "60106000036010818112600055136001556010601060000381811260025513600355".from_hex().unwrap();
|
|
|
|
|
let code = hex!("60106000036010818112600055136001556010601060000381811260025513600355").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -557,7 +597,7 @@ fn test_signed_comparison(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_bitops: test_bitops_int}
|
|
|
|
|
fn test_bitops(factory: super::Factory) {
|
|
|
|
|
let code = "60ff610ff08181818116600055176001551860025560008015600355198015600455600555".from_hex().unwrap();
|
|
|
|
|
let code = hex!("60ff610ff08181818116600055176001551860025560008015600355198015600455600555").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(150_000);
|
|
|
|
|
@@ -580,7 +620,7 @@ fn test_bitops(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_addmod_mulmod: test_addmod_mulmod_int}
|
|
|
|
|
fn test_addmod_mulmod(factory: super::Factory) {
|
|
|
|
|
let code = "60ff60f060108282820860005509600155600060f0601082828208196002550919600355".from_hex().unwrap();
|
|
|
|
|
let code = hex!("60ff60f060108282820860005509600155600060f0601082828208196002550919600355").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -601,7 +641,7 @@ fn test_addmod_mulmod(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_byte: test_byte_int}
|
|
|
|
|
fn test_byte(factory: super::Factory) {
|
|
|
|
|
let code = "60f061ffff1a600055610fff601f1a600155".from_hex().unwrap();
|
|
|
|
|
let code = hex!("60f061ffff1a600055610fff601f1a600155").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -620,7 +660,7 @@ fn test_byte(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_signextend: test_signextend_int}
|
|
|
|
|
fn test_signextend(factory: super::Factory) {
|
|
|
|
|
let code = "610fff60020b60005560ff60200b600155".from_hex().unwrap();
|
|
|
|
|
let code = hex!("610fff60020b60005560ff60200b600155").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -640,7 +680,7 @@ fn test_signextend(factory: super::Factory) {
|
|
|
|
|
#[test] // JIT just returns out of gas
|
|
|
|
|
fn test_badinstruction_int() {
|
|
|
|
|
let factory = super::Factory::new(VMType::Interpreter, 1024 * 32);
|
|
|
|
|
let code = "af".from_hex().unwrap();
|
|
|
|
|
let code = hex!("af").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -660,7 +700,7 @@ fn test_badinstruction_int() {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_pop: test_pop_int}
|
|
|
|
|
fn test_pop(factory: super::Factory) {
|
|
|
|
|
let code = "60f060aa50600055".from_hex().unwrap();
|
|
|
|
|
let code = hex!("60f060aa50600055").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(100_000);
|
|
|
|
|
@@ -678,7 +718,7 @@ fn test_pop(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_extops: test_extops_int}
|
|
|
|
|
fn test_extops(factory: super::Factory) {
|
|
|
|
|
let code = "5a6001555836553a600255386003553460045560016001526016590454600555".from_hex().unwrap();
|
|
|
|
|
let code = hex!("5a6001555836553a600255386003553460045560016001526016590454600555").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(150_000);
|
|
|
|
|
@@ -703,7 +743,7 @@ fn test_extops(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_jumps: test_jumps_int}
|
|
|
|
|
fn test_jumps(factory: super::Factory) {
|
|
|
|
|
let code = "600160015560066000555b60016000540380806000551560245760015402600155600a565b".from_hex().unwrap();
|
|
|
|
|
let code = hex!("600160015560066000555b60016000540380806000551560245760015402600155600a565b").to_vec();
|
|
|
|
|
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
params.gas = U256::from(150_000);
|
|
|
|
|
@@ -723,7 +763,7 @@ fn test_jumps(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_calls: test_calls_int}
|
|
|
|
|
fn test_calls(factory: super::Factory) {
|
|
|
|
|
let code = "600054602d57600160005560006000600060006050610998610100f160006000600060006050610998610100f25b".from_hex().unwrap();
|
|
|
|
|
let code = hex!("600054602d57600160005560006000600060006050610998610100f160006000600060006050610998610100f25b").to_vec();
|
|
|
|
|
|
|
|
|
|
let address = Address::from_low_u64_be(0x155);
|
|
|
|
|
let code_address = Address::from_low_u64_be(0x998);
|
|
|
|
|
@@ -769,7 +809,7 @@ fn test_calls(factory: super::Factory) {
|
|
|
|
|
|
|
|
|
|
evm_test!{test_create_in_staticcall: test_create_in_staticcall_int}
|
|
|
|
|
fn test_create_in_staticcall(factory: super::Factory) {
|
|
|
|
|
let code = "600060006064f000".from_hex().unwrap();
|
|
|
|
|
let code = hex!("600060006064f000").to_vec();
|
|
|
|
|
|
|
|
|
|
let address = Address::from_low_u64_be(0x155);
|
|
|
|
|
let mut params = ActionParams::default();
|
|
|
|
|
@@ -793,68 +833,68 @@ fn test_shl(factory: super::Factory) {
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1b,
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001",
|
|
|
|
|
"00",
|
|
|
|
|
hex!("0000000000000000000000000000000000000000000000000000000000000001").to_vec(),
|
|
|
|
|
hex!("00").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1b,
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001",
|
|
|
|
|
"01",
|
|
|
|
|
hex!("0000000000000000000000000000000000000000000000000000000000000001").to_vec(),
|
|
|
|
|
hex!("01").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000002");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1b,
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001",
|
|
|
|
|
"ff",
|
|
|
|
|
hex!("0000000000000000000000000000000000000000000000000000000000000001").to_vec(),
|
|
|
|
|
hex!("ff").to_vec(),
|
|
|
|
|
"8000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1b,
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001",
|
|
|
|
|
"0100",
|
|
|
|
|
hex!("0000000000000000000000000000000000000000000000000000000000000001").to_vec(),
|
|
|
|
|
hex!("0100").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1b,
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001",
|
|
|
|
|
"0101",
|
|
|
|
|
hex!("0000000000000000000000000000000000000000000000000000000000000001").to_vec(),
|
|
|
|
|
hex!("0101").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1b,
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"00",
|
|
|
|
|
hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("00").to_vec(),
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1b,
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"01",
|
|
|
|
|
hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("01").to_vec(),
|
|
|
|
|
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1b,
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"ff",
|
|
|
|
|
hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("ff").to_vec(),
|
|
|
|
|
"8000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1b,
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"0100",
|
|
|
|
|
hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("0100").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1b,
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000",
|
|
|
|
|
"01",
|
|
|
|
|
hex!("0000000000000000000000000000000000000000000000000000000000000000").to_vec(),
|
|
|
|
|
hex!("01").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1b,
|
|
|
|
|
"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"01",
|
|
|
|
|
hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("01").to_vec(),
|
|
|
|
|
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -863,68 +903,68 @@ fn test_shr(factory: super::Factory) {
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1c,
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001",
|
|
|
|
|
"00",
|
|
|
|
|
hex!("0000000000000000000000000000000000000000000000000000000000000001").to_vec(),
|
|
|
|
|
hex!("00").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1c,
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001",
|
|
|
|
|
"01",
|
|
|
|
|
hex!("0000000000000000000000000000000000000000000000000000000000000001").to_vec(),
|
|
|
|
|
hex!("01").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1c,
|
|
|
|
|
"8000000000000000000000000000000000000000000000000000000000000000",
|
|
|
|
|
"01",
|
|
|
|
|
hex!("8000000000000000000000000000000000000000000000000000000000000000").to_vec(),
|
|
|
|
|
hex!("01").to_vec(),
|
|
|
|
|
"4000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1c,
|
|
|
|
|
"8000000000000000000000000000000000000000000000000000000000000000",
|
|
|
|
|
"ff",
|
|
|
|
|
hex!("8000000000000000000000000000000000000000000000000000000000000000").to_vec(),
|
|
|
|
|
hex!("ff").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1c,
|
|
|
|
|
"8000000000000000000000000000000000000000000000000000000000000000",
|
|
|
|
|
"0100",
|
|
|
|
|
hex!("8000000000000000000000000000000000000000000000000000000000000000").to_vec(),
|
|
|
|
|
hex!("0100").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1c,
|
|
|
|
|
"8000000000000000000000000000000000000000000000000000000000000000",
|
|
|
|
|
"0101",
|
|
|
|
|
hex!("8000000000000000000000000000000000000000000000000000000000000000").to_vec(),
|
|
|
|
|
hex!("0101").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1c,
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"00",
|
|
|
|
|
hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("00").to_vec(),
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1c,
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"01",
|
|
|
|
|
hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("01").to_vec(),
|
|
|
|
|
"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1c,
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"ff",
|
|
|
|
|
hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("ff").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1c,
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"0100",
|
|
|
|
|
hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("0100").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1c,
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000",
|
|
|
|
|
"01",
|
|
|
|
|
hex!("0000000000000000000000000000000000000000000000000000000000000000").to_vec(),
|
|
|
|
|
hex!("01").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -933,104 +973,102 @@ fn test_sar(factory: super::Factory) {
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001",
|
|
|
|
|
"00",
|
|
|
|
|
hex!("0000000000000000000000000000000000000000000000000000000000000001").to_vec(),
|
|
|
|
|
hex!("00").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001",
|
|
|
|
|
"01",
|
|
|
|
|
hex!("0000000000000000000000000000000000000000000000000000000000000001").to_vec(),
|
|
|
|
|
hex!("01").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"8000000000000000000000000000000000000000000000000000000000000000",
|
|
|
|
|
"01",
|
|
|
|
|
hex!("8000000000000000000000000000000000000000000000000000000000000000").to_vec(),
|
|
|
|
|
hex!("01").to_vec(),
|
|
|
|
|
"c000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"8000000000000000000000000000000000000000000000000000000000000000",
|
|
|
|
|
"ff",
|
|
|
|
|
hex!("8000000000000000000000000000000000000000000000000000000000000000").to_vec(),
|
|
|
|
|
hex!("ff").to_vec(),
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"8000000000000000000000000000000000000000000000000000000000000000",
|
|
|
|
|
"0100",
|
|
|
|
|
hex!("8000000000000000000000000000000000000000000000000000000000000000").to_vec(),
|
|
|
|
|
hex!("0100").to_vec(),
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"8000000000000000000000000000000000000000000000000000000000000000",
|
|
|
|
|
"0101",
|
|
|
|
|
hex!("8000000000000000000000000000000000000000000000000000000000000000").to_vec(),
|
|
|
|
|
hex!("0101").to_vec(),
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"00",
|
|
|
|
|
hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("00").to_vec(),
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"01",
|
|
|
|
|
hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("01").to_vec(),
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"ff",
|
|
|
|
|
hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("ff").to_vec(),
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"0100",
|
|
|
|
|
hex!("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("0100").to_vec(),
|
|
|
|
|
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000",
|
|
|
|
|
"01",
|
|
|
|
|
hex!("0000000000000000000000000000000000000000000000000000000000000000").to_vec(),
|
|
|
|
|
hex!("01").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"4000000000000000000000000000000000000000000000000000000000000000",
|
|
|
|
|
"fe",
|
|
|
|
|
hex!("4000000000000000000000000000000000000000000000000000000000000000").to_vec(),
|
|
|
|
|
hex!("fe").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"f8",
|
|
|
|
|
hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("f8").to_vec(),
|
|
|
|
|
"000000000000000000000000000000000000000000000000000000000000007f");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"fe",
|
|
|
|
|
hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("fe").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000001");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"ff",
|
|
|
|
|
hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("ff").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
push_two_pop_one_constantinople_test(
|
|
|
|
|
&factory,
|
|
|
|
|
0x1d,
|
|
|
|
|
"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
|
|
|
"0100",
|
|
|
|
|
hex!("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").to_vec(),
|
|
|
|
|
hex!("0100").to_vec(),
|
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000000");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn push_two_pop_one_constantinople_test(factory: &super::Factory, opcode: u8, push1: &str, push2: &str, result: &str) {
|
|
|
|
|
let mut push1 = push1.from_hex().unwrap();
|
|
|
|
|
let mut push2 = push2.from_hex().unwrap();
|
|
|
|
|
fn push_two_pop_one_constantinople_test(factory: &super::Factory, opcode: u8, mut push1: Vec<u8>, mut push2: Vec<u8>, result: &str) {
|
|
|
|
|
assert!(push1.len() <= 32 && push1.len() != 0);
|
|
|
|
|
assert!(push2.len() <= 32 && push2.len() != 0);
|
|
|
|
|
|
|
|
|
|
|