Parametrized executive tests
This commit is contained in:
parent
f96e598f20
commit
48d3acfdea
@ -62,3 +62,18 @@ impl Factory {
|
|||||||
fn test_create_vm() {
|
fn test_create_vm() {
|
||||||
let _vm = Factory::default().create();
|
let _vm = Factory::default().create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! evm_test(
|
||||||
|
($name_test: ident: $name_jit: ident, $name_int: ident) => {
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "jit")]
|
||||||
|
fn $name_jit() {
|
||||||
|
$name_test(super::Factory::new(super::factory::VMType::Jit));
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn $name_int() {
|
||||||
|
$name_test(super::Factory::new(super::factory::VMType::Interpreter));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
pub mod ext;
|
pub mod ext;
|
||||||
pub mod evm;
|
pub mod evm;
|
||||||
pub mod interpreter;
|
pub mod interpreter;
|
||||||
|
#[macro_use]
|
||||||
pub mod factory;
|
pub mod factory;
|
||||||
pub mod schedule;
|
pub mod schedule;
|
||||||
mod instructions;
|
mod instructions;
|
||||||
|
@ -122,22 +122,8 @@ fn test_stack_underflow() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! evm_test(
|
|
||||||
($name_test: ident: $name_jit: ident, $name_int: ident) => {
|
|
||||||
#[test]
|
|
||||||
#[cfg(feature = "jit")]
|
|
||||||
fn $name_jit() {
|
|
||||||
$name_test(super::Factory::new(super::factory::VMType::Jit).create());
|
|
||||||
}
|
|
||||||
#[test]
|
|
||||||
fn $name_int() {
|
|
||||||
$name_test(super::Factory::new(super::factory::VMType::Interpreter).create());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
evm_test!{test_add: test_add_jit, test_add_int}
|
evm_test!{test_add: test_add_jit, test_add_int}
|
||||||
fn test_add(vm : Box<super::Evm>) {
|
fn test_add(factory: super::Factory) {
|
||||||
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
let code = "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01600055".from_hex().unwrap();
|
let code = "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01600055".from_hex().unwrap();
|
||||||
|
|
||||||
@ -148,6 +134,7 @@ fn test_add(vm : Box<super::Evm>) {
|
|||||||
let mut ext = FakeExt::new();
|
let mut ext = FakeExt::new();
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -156,7 +143,7 @@ fn test_add(vm : Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_sha3: test_sha3_jit, test_sha3_int}
|
evm_test!{test_sha3: test_sha3_jit, test_sha3_int}
|
||||||
fn test_sha3(vm: Box<super::Evm>) {
|
fn test_sha3(factory: super::Factory) {
|
||||||
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
let code = "6000600020600055".from_hex().unwrap();
|
let code = "6000600020600055".from_hex().unwrap();
|
||||||
|
|
||||||
@ -167,6 +154,7 @@ fn test_sha3(vm: Box<super::Evm>) {
|
|||||||
let mut ext = FakeExt::new();
|
let mut ext = FakeExt::new();
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -175,7 +163,7 @@ fn test_sha3(vm: Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_address: test_address_jit, test_address_int}
|
evm_test!{test_address: test_address_jit, test_address_int}
|
||||||
fn test_address(vm: Box<super::Evm>) {
|
fn test_address(factory: super::Factory) {
|
||||||
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
let code = "30600055".from_hex().unwrap();
|
let code = "30600055".from_hex().unwrap();
|
||||||
|
|
||||||
@ -186,6 +174,7 @@ fn test_address(vm: Box<super::Evm>) {
|
|||||||
let mut ext = FakeExt::new();
|
let mut ext = FakeExt::new();
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -194,7 +183,7 @@ fn test_address(vm: Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_origin: test_origin_jit, test_origin_int}
|
evm_test!{test_origin: test_origin_jit, test_origin_int}
|
||||||
fn test_origin(vm: Box<super::Evm>) {
|
fn test_origin(factory: super::Factory) {
|
||||||
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
let origin = Address::from_str("cd1722f2947def4cf144679da39c4c32bdc35681").unwrap();
|
let origin = Address::from_str("cd1722f2947def4cf144679da39c4c32bdc35681").unwrap();
|
||||||
let code = "32600055".from_hex().unwrap();
|
let code = "32600055".from_hex().unwrap();
|
||||||
@ -207,6 +196,7 @@ fn test_origin(vm: Box<super::Evm>) {
|
|||||||
let mut ext = FakeExt::new();
|
let mut ext = FakeExt::new();
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -215,7 +205,7 @@ fn test_origin(vm: Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_sender: test_sender_jit, test_sender_int}
|
evm_test!{test_sender: test_sender_jit, test_sender_int}
|
||||||
fn test_sender(vm: Box<super::Evm>) {
|
fn test_sender(factory: super::Factory) {
|
||||||
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
let sender = Address::from_str("cd1722f2947def4cf144679da39c4c32bdc35681").unwrap();
|
let sender = Address::from_str("cd1722f2947def4cf144679da39c4c32bdc35681").unwrap();
|
||||||
let code = "33600055".from_hex().unwrap();
|
let code = "33600055".from_hex().unwrap();
|
||||||
@ -228,6 +218,7 @@ fn test_sender(vm: Box<super::Evm>) {
|
|||||||
let mut ext = FakeExt::new();
|
let mut ext = FakeExt::new();
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -236,7 +227,7 @@ fn test_sender(vm: Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_extcodecopy: test_extcodecopy_jit, test_extcodecopy_int}
|
evm_test!{test_extcodecopy: test_extcodecopy_jit, test_extcodecopy_int}
|
||||||
fn test_extcodecopy(vm: Box<super::Evm>) {
|
fn test_extcodecopy(factory: super::Factory) {
|
||||||
// 33 - sender
|
// 33 - sender
|
||||||
// 3b - extcodesize
|
// 3b - extcodesize
|
||||||
// 60 00 - push 0
|
// 60 00 - push 0
|
||||||
@ -262,6 +253,7 @@ fn test_extcodecopy(vm: Box<super::Evm>) {
|
|||||||
ext.codes.insert(sender, sender_code);
|
ext.codes.insert(sender, sender_code);
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -270,7 +262,7 @@ fn test_extcodecopy(vm: Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_log_empty: test_log_empty_jit, test_log_empty_int}
|
evm_test!{test_log_empty: test_log_empty_jit, test_log_empty_int}
|
||||||
fn test_log_empty(vm: Box<super::Evm>) {
|
fn test_log_empty(factory: super::Factory) {
|
||||||
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
let code = "60006000a0".from_hex().unwrap();
|
let code = "60006000a0".from_hex().unwrap();
|
||||||
|
|
||||||
@ -281,6 +273,7 @@ fn test_log_empty(vm: Box<super::Evm>) {
|
|||||||
let mut ext = FakeExt::new();
|
let mut ext = FakeExt::new();
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -291,7 +284,7 @@ fn test_log_empty(vm: Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_log_sender: test_log_sender_jit, test_log_sender_int}
|
evm_test!{test_log_sender: test_log_sender_jit, test_log_sender_int}
|
||||||
fn test_log_sender(vm: Box<super::Evm>) {
|
fn test_log_sender(factory: super::Factory) {
|
||||||
// 60 ff - push ff
|
// 60 ff - push ff
|
||||||
// 60 00 - push 00
|
// 60 00 - push 00
|
||||||
// 53 - mstore
|
// 53 - mstore
|
||||||
@ -312,6 +305,7 @@ fn test_log_sender(vm: Box<super::Evm>) {
|
|||||||
let mut ext = FakeExt::new();
|
let mut ext = FakeExt::new();
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -323,7 +317,7 @@ fn test_log_sender(vm: Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_blockhash: test_blockhash_jit, test_blockhash_int}
|
evm_test!{test_blockhash: test_blockhash_jit, test_blockhash_int}
|
||||||
fn test_blockhash(vm: Box<super::Evm>) {
|
fn test_blockhash(factory: super::Factory) {
|
||||||
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
let code = "600040600055".from_hex().unwrap();
|
let code = "600040600055".from_hex().unwrap();
|
||||||
let blockhash = H256::from_str("123400000000000000000000cd1722f2947def4cf144679da39c4c32bdc35681").unwrap();
|
let blockhash = H256::from_str("123400000000000000000000cd1722f2947def4cf144679da39c4c32bdc35681").unwrap();
|
||||||
@ -336,6 +330,7 @@ fn test_blockhash(vm: Box<super::Evm>) {
|
|||||||
ext.blockhashes.insert(U256::zero(), blockhash.clone());
|
ext.blockhashes.insert(U256::zero(), blockhash.clone());
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -344,7 +339,7 @@ fn test_blockhash(vm: Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_calldataload: test_calldataload_jit, test_calldataload_int}
|
evm_test!{test_calldataload: test_calldataload_jit, test_calldataload_int}
|
||||||
fn test_calldataload(vm: Box<super::Evm>) {
|
fn test_calldataload(factory: super::Factory) {
|
||||||
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
let code = "600135600055".from_hex().unwrap();
|
let code = "600135600055".from_hex().unwrap();
|
||||||
let data = "0123ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff23".from_hex().unwrap();
|
let data = "0123ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff23".from_hex().unwrap();
|
||||||
@ -357,6 +352,7 @@ fn test_calldataload(vm: Box<super::Evm>) {
|
|||||||
let mut ext = FakeExt::new();
|
let mut ext = FakeExt::new();
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -366,7 +362,7 @@ fn test_calldataload(vm: Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_author: test_author_jit, test_author_int}
|
evm_test!{test_author: test_author_jit, test_author_int}
|
||||||
fn test_author(vm: Box<super::Evm>) {
|
fn test_author(factory: super::Factory) {
|
||||||
let author = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
let author = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
let code = "41600055".from_hex().unwrap();
|
let code = "41600055".from_hex().unwrap();
|
||||||
|
|
||||||
@ -377,6 +373,7 @@ fn test_author(vm: Box<super::Evm>) {
|
|||||||
ext.info.author = author;
|
ext.info.author = author;
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -385,7 +382,7 @@ fn test_author(vm: Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_timestamp: test_timestamp_jit, test_timestamp_int}
|
evm_test!{test_timestamp: test_timestamp_jit, test_timestamp_int}
|
||||||
fn test_timestamp(vm: Box<super::Evm>) {
|
fn test_timestamp(factory: super::Factory) {
|
||||||
let timestamp = 0x1234;
|
let timestamp = 0x1234;
|
||||||
let code = "42600055".from_hex().unwrap();
|
let code = "42600055".from_hex().unwrap();
|
||||||
|
|
||||||
@ -396,6 +393,7 @@ fn test_timestamp(vm: Box<super::Evm>) {
|
|||||||
ext.info.timestamp = timestamp;
|
ext.info.timestamp = timestamp;
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -404,7 +402,7 @@ fn test_timestamp(vm: Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_number: test_number_jit, test_number_int}
|
evm_test!{test_number: test_number_jit, test_number_int}
|
||||||
fn test_number(vm: Box<super::Evm>) {
|
fn test_number(factory: super::Factory) {
|
||||||
let number = 0x1234;
|
let number = 0x1234;
|
||||||
let code = "43600055".from_hex().unwrap();
|
let code = "43600055".from_hex().unwrap();
|
||||||
|
|
||||||
@ -415,6 +413,7 @@ fn test_number(vm: Box<super::Evm>) {
|
|||||||
ext.info.number = number;
|
ext.info.number = number;
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -423,7 +422,7 @@ fn test_number(vm: Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_difficulty: test_difficulty_jit, test_difficulty_int}
|
evm_test!{test_difficulty: test_difficulty_jit, test_difficulty_int}
|
||||||
fn test_difficulty(vm: Box<super::Evm>) {
|
fn test_difficulty(factory: super::Factory) {
|
||||||
let difficulty = U256::from(0x1234);
|
let difficulty = U256::from(0x1234);
|
||||||
let code = "44600055".from_hex().unwrap();
|
let code = "44600055".from_hex().unwrap();
|
||||||
|
|
||||||
@ -434,6 +433,7 @@ fn test_difficulty(vm: Box<super::Evm>) {
|
|||||||
ext.info.difficulty = difficulty;
|
ext.info.difficulty = difficulty;
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -442,7 +442,7 @@ fn test_difficulty(vm: Box<super::Evm>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evm_test!{test_gas_limit: test_gas_limit_jit, test_gas_limit_int}
|
evm_test!{test_gas_limit: test_gas_limit_jit, test_gas_limit_int}
|
||||||
fn test_gas_limit(vm: Box<super::Evm>) {
|
fn test_gas_limit(factory: super::Factory) {
|
||||||
let gas_limit = U256::from(0x1234);
|
let gas_limit = U256::from(0x1234);
|
||||||
let code = "45600055".from_hex().unwrap();
|
let code = "45600055".from_hex().unwrap();
|
||||||
|
|
||||||
@ -453,6 +453,7 @@ fn test_gas_limit(vm: Box<super::Evm>) {
|
|||||||
ext.info.gas_limit = gas_limit;
|
ext.info.gas_limit = gas_limit;
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
|
let vm = factory.create();
|
||||||
vm.exec(¶ms, &mut ext).unwrap()
|
vm.exec(¶ms, &mut ext).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -500,6 +500,7 @@ mod tests {
|
|||||||
use spec::*;
|
use spec::*;
|
||||||
use evm::Schedule;
|
use evm::Schedule;
|
||||||
use evm::Factory;
|
use evm::Factory;
|
||||||
|
use evm::factory::VMType;
|
||||||
|
|
||||||
struct TestEngine {
|
struct TestEngine {
|
||||||
spec: Spec,
|
spec: Spec,
|
||||||
@ -532,9 +533,24 @@ mod tests {
|
|||||||
assert_eq!(expected_address, contract_address(&address, &U256::from(88)));
|
assert_eq!(expected_address, contract_address(&address, &U256::from(88)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
// TODO [todr] this is copy-pasted for evm::factory
|
||||||
|
macro_rules! evm_test(
|
||||||
|
($name_test: ident: $name_jit: ident, $name_int: ident) => {
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "jit")]
|
||||||
|
fn $name_jit() {
|
||||||
|
$name_test(Factory::new(VMType::Jit));
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn $name_int() {
|
||||||
|
$name_test(Factory::new(VMType::Interpreter));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// TODO: replace params with transactions!
|
// TODO: replace params with transactions!
|
||||||
fn test_sender_balance() {
|
evm_test!{test_sender_balance: test_sender_balance_jit, test_sender_balance_int}
|
||||||
|
fn test_sender_balance(factory: Factory) {
|
||||||
let sender = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
let sender = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||||
let address = contract_address(&sender, &U256::zero());
|
let address = contract_address(&sender, &U256::zero());
|
||||||
let mut params = ActionParams::new();
|
let mut params = ActionParams::new();
|
||||||
@ -550,7 +566,6 @@ mod tests {
|
|||||||
let mut substate = Substate::new();
|
let mut substate = Substate::new();
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
let factory = Factory::default();
|
|
||||||
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
||||||
ex.create(¶ms, &mut substate).unwrap()
|
ex.create(¶ms, &mut substate).unwrap()
|
||||||
};
|
};
|
||||||
@ -565,8 +580,8 @@ mod tests {
|
|||||||
// TODO: just test state root.
|
// TODO: just test state root.
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
evm_test!{test_create_contract: test_create_contract_jit, test_create_contract_int}
|
||||||
fn test_create_contract() {
|
fn test_create_contract(factory: Factory) {
|
||||||
// code:
|
// code:
|
||||||
//
|
//
|
||||||
// 7c 601080600c6000396000f3006000355415600957005b60203560003555 - push 29 bytes?
|
// 7c 601080600c6000396000f3006000355415600957005b60203560003555 - push 29 bytes?
|
||||||
@ -609,7 +624,6 @@ mod tests {
|
|||||||
let mut substate = Substate::new();
|
let mut substate = Substate::new();
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
let factory = Factory::default();
|
|
||||||
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
||||||
ex.create(¶ms, &mut substate).unwrap()
|
ex.create(¶ms, &mut substate).unwrap()
|
||||||
};
|
};
|
||||||
@ -619,8 +633,8 @@ mod tests {
|
|||||||
assert_eq!(substate.contracts_created.len(), 0);
|
assert_eq!(substate.contracts_created.len(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
evm_test!{test_create_contract_value_too_high: test_create_contract_value_too_high_jit, test_create_contract_value_too_high_int}
|
||||||
fn test_create_contract_value_too_high() {
|
fn test_create_contract_value_too_high(factory: Factory) {
|
||||||
// code:
|
// code:
|
||||||
//
|
//
|
||||||
// 7c 601080600c6000396000f3006000355415600957005b60203560003555 - push 29 bytes?
|
// 7c 601080600c6000396000f3006000355415600957005b60203560003555 - push 29 bytes?
|
||||||
@ -663,7 +677,6 @@ mod tests {
|
|||||||
let mut substate = Substate::new();
|
let mut substate = Substate::new();
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
let factory = Factory::default();
|
|
||||||
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
||||||
ex.create(¶ms, &mut substate).unwrap()
|
ex.create(¶ms, &mut substate).unwrap()
|
||||||
};
|
};
|
||||||
@ -672,8 +685,8 @@ mod tests {
|
|||||||
assert_eq!(substate.contracts_created.len(), 0);
|
assert_eq!(substate.contracts_created.len(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
evm_test!{test_create_contract_without_max_depth: test_create_contract_without_max_depth_jit, test_create_contract_without_max_depth_int}
|
||||||
fn test_create_contract_without_max_depth() {
|
fn test_create_contract_without_max_depth(factory: Factory) {
|
||||||
// code:
|
// code:
|
||||||
//
|
//
|
||||||
// 7c 601080600c6000396000f3006000355415600957005b60203560003555 - push 29 bytes?
|
// 7c 601080600c6000396000f3006000355415600957005b60203560003555 - push 29 bytes?
|
||||||
@ -715,7 +728,6 @@ mod tests {
|
|||||||
let mut substate = Substate::new();
|
let mut substate = Substate::new();
|
||||||
|
|
||||||
{
|
{
|
||||||
let factory = Factory::default();
|
|
||||||
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
||||||
ex.create(¶ms, &mut substate).unwrap();
|
ex.create(¶ms, &mut substate).unwrap();
|
||||||
}
|
}
|
||||||
@ -724,8 +736,8 @@ mod tests {
|
|||||||
assert_eq!(substate.contracts_created[0], next_address);
|
assert_eq!(substate.contracts_created[0], next_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
evm_test!{test_aba_calls: test_aba_calls_jit, test_aba_calls_int}
|
||||||
fn test_aba_calls() {
|
fn test_aba_calls(factory: Factory) {
|
||||||
// 60 00 - push 0
|
// 60 00 - push 0
|
||||||
// 60 00 - push 0
|
// 60 00 - push 0
|
||||||
// 60 00 - push 0
|
// 60 00 - push 0
|
||||||
@ -774,7 +786,6 @@ mod tests {
|
|||||||
let mut substate = Substate::new();
|
let mut substate = Substate::new();
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
let factory = Factory::default();
|
|
||||||
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
||||||
ex.call(¶ms, &mut substate, BytesRef::Fixed(&mut [])).unwrap()
|
ex.call(¶ms, &mut substate, BytesRef::Fixed(&mut [])).unwrap()
|
||||||
};
|
};
|
||||||
@ -783,8 +794,8 @@ mod tests {
|
|||||||
assert_eq!(state.storage_at(&address_a, &H256::from(&U256::from(0x23))), H256::from(&U256::from(1)));
|
assert_eq!(state.storage_at(&address_a, &H256::from(&U256::from(0x23))), H256::from(&U256::from(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
evm_test!{test_recursive_bomb1: test_recursive_bomb1_jit, test_recursive_bomb1_int}
|
||||||
fn test_recursive_bomb1() {
|
fn test_recursive_bomb1(factory: Factory) {
|
||||||
// 60 01 - push 1
|
// 60 01 - push 1
|
||||||
// 60 00 - push 0
|
// 60 00 - push 0
|
||||||
// 54 - sload
|
// 54 - sload
|
||||||
@ -817,7 +828,6 @@ mod tests {
|
|||||||
let mut substate = Substate::new();
|
let mut substate = Substate::new();
|
||||||
|
|
||||||
let gas_left = {
|
let gas_left = {
|
||||||
let factory = Factory::default();
|
|
||||||
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
||||||
ex.call(¶ms, &mut substate, BytesRef::Fixed(&mut [])).unwrap()
|
ex.call(¶ms, &mut substate, BytesRef::Fixed(&mut [])).unwrap()
|
||||||
};
|
};
|
||||||
@ -827,8 +837,8 @@ mod tests {
|
|||||||
assert_eq!(state.storage_at(&address, &H256::from(&U256::one())), H256::from(&U256::from(1)));
|
assert_eq!(state.storage_at(&address, &H256::from(&U256::one())), H256::from(&U256::from(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
evm_test!{test_transact_simple: test_transact_simple_jit, test_transact_simple_int}
|
||||||
fn test_transact_simple() {
|
fn test_transact_simple(factory: Factory) {
|
||||||
let mut t = Transaction::new_create(U256::from(17), "3331600055".from_hex().unwrap(), U256::from(100_000), U256::zero(), U256::zero());
|
let mut t = Transaction::new_create(U256::from(17), "3331600055".from_hex().unwrap(), U256::from(100_000), U256::zero(), U256::zero());
|
||||||
let keypair = KeyPair::create().unwrap();
|
let keypair = KeyPair::create().unwrap();
|
||||||
t.sign(&keypair.secret());
|
t.sign(&keypair.secret());
|
||||||
@ -842,7 +852,6 @@ mod tests {
|
|||||||
let engine = TestEngine::new(0);
|
let engine = TestEngine::new(0);
|
||||||
|
|
||||||
let executed = {
|
let executed = {
|
||||||
let factory = Factory::default();
|
|
||||||
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
||||||
ex.transact(&t).unwrap()
|
ex.transact(&t).unwrap()
|
||||||
};
|
};
|
||||||
@ -860,8 +869,8 @@ mod tests {
|
|||||||
assert_eq!(state.storage_at(&contract, &H256::new()), H256::from(&U256::from(1)));
|
assert_eq!(state.storage_at(&contract, &H256::new()), H256::from(&U256::from(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
evm_test!{test_transact_invalid_sender: test_transact_invalid_sender_jit, test_transact_invalid_sender_int}
|
||||||
fn test_transact_invalid_sender() {
|
fn test_transact_invalid_sender(factory: Factory) {
|
||||||
let t = Transaction::new_create(U256::from(17), "3331600055".from_hex().unwrap(), U256::from(100_000), U256::zero(), U256::zero());
|
let t = Transaction::new_create(U256::from(17), "3331600055".from_hex().unwrap(), U256::from(100_000), U256::zero(), U256::zero());
|
||||||
|
|
||||||
let mut state = State::new_temp();
|
let mut state = State::new_temp();
|
||||||
@ -870,7 +879,6 @@ mod tests {
|
|||||||
let engine = TestEngine::new(0);
|
let engine = TestEngine::new(0);
|
||||||
|
|
||||||
let res = {
|
let res = {
|
||||||
let factory = Factory::default();
|
|
||||||
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
||||||
ex.transact(&t)
|
ex.transact(&t)
|
||||||
};
|
};
|
||||||
@ -881,8 +889,8 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
evm_test!{test_transact_invalid_nonce: test_transact_invalid_nonce_jit, test_transact_invalid_nonce_int}
|
||||||
fn test_transact_invalid_nonce() {
|
fn test_transact_invalid_nonce(factory: Factory) {
|
||||||
let mut t = Transaction::new_create(U256::from(17), "3331600055".from_hex().unwrap(), U256::from(100_000), U256::zero(), U256::one());
|
let mut t = Transaction::new_create(U256::from(17), "3331600055".from_hex().unwrap(), U256::from(100_000), U256::zero(), U256::one());
|
||||||
let keypair = KeyPair::create().unwrap();
|
let keypair = KeyPair::create().unwrap();
|
||||||
t.sign(&keypair.secret());
|
t.sign(&keypair.secret());
|
||||||
@ -895,7 +903,6 @@ mod tests {
|
|||||||
let engine = TestEngine::new(0);
|
let engine = TestEngine::new(0);
|
||||||
|
|
||||||
let res = {
|
let res = {
|
||||||
let factory = Factory::default();
|
|
||||||
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
||||||
ex.transact(&t)
|
ex.transact(&t)
|
||||||
};
|
};
|
||||||
@ -907,8 +914,8 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
evm_test!{test_transact_gas_limit_reached: test_transact_gas_limit_reached_jit, test_transact_gas_limit_reached_int}
|
||||||
fn test_transact_gas_limit_reached() {
|
fn test_transact_gas_limit_reached(factory: Factory) {
|
||||||
let mut t = Transaction::new_create(U256::from(17), "3331600055".from_hex().unwrap(), U256::from(80_001), U256::zero(), U256::zero());
|
let mut t = Transaction::new_create(U256::from(17), "3331600055".from_hex().unwrap(), U256::from(80_001), U256::zero(), U256::zero());
|
||||||
let keypair = KeyPair::create().unwrap();
|
let keypair = KeyPair::create().unwrap();
|
||||||
t.sign(&keypair.secret());
|
t.sign(&keypair.secret());
|
||||||
@ -922,7 +929,6 @@ mod tests {
|
|||||||
let engine = TestEngine::new(0);
|
let engine = TestEngine::new(0);
|
||||||
|
|
||||||
let res = {
|
let res = {
|
||||||
let factory = Factory::default();
|
|
||||||
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
||||||
ex.transact(&t)
|
ex.transact(&t)
|
||||||
};
|
};
|
||||||
@ -934,8 +940,8 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
evm_test!{test_not_enough_cash: test_not_enough_cash_jit, test_not_enough_cash_int}
|
||||||
fn test_not_enough_cash() {
|
fn test_not_enough_cash(factory: Factory) {
|
||||||
let mut t = Transaction::new_create(U256::from(18), "3331600055".from_hex().unwrap(), U256::from(100_000), U256::one(), U256::zero());
|
let mut t = Transaction::new_create(U256::from(18), "3331600055".from_hex().unwrap(), U256::from(100_000), U256::one(), U256::zero());
|
||||||
let keypair = KeyPair::create().unwrap();
|
let keypair = KeyPair::create().unwrap();
|
||||||
t.sign(&keypair.secret());
|
t.sign(&keypair.secret());
|
||||||
@ -948,7 +954,6 @@ mod tests {
|
|||||||
let engine = TestEngine::new(0);
|
let engine = TestEngine::new(0);
|
||||||
|
|
||||||
let res = {
|
let res = {
|
||||||
let factory = Factory::default();
|
|
||||||
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
|
||||||
ex.transact(&t)
|
ex.transact(&t)
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user