From 124cfcc11ef1a170a609c261ab0bf6fb5c016b16 Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Thu, 21 Jan 2016 16:08:09 +0100 Subject: [PATCH] Possibility to declare "heavy tests" --- Cargo.toml | 3 ++- src/evm/interpreter.rs | 6 +++--- src/null_engine.rs | 2 +- src/tests/executive.rs | 5 ++--- src/tests/state.rs | 10 +++++----- src/tests/test_common.rs | 38 ++++++++++++++++++++++++-------------- src/tests/transaction.rs | 4 ++-- 7 files changed, 39 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 04c4bf956..5123ec977 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,8 @@ num_cpus = "0.2" [features] jit = ["evmjit"] -evm_debug = [] +test-heavy = [] +evm-debug = [] [[bin]] name = "client" diff --git a/src/evm/interpreter.rs b/src/evm/interpreter.rs index 88823cbea..a384f3791 100644 --- a/src/evm/interpreter.rs +++ b/src/evm/interpreter.rs @@ -7,19 +7,19 @@ use super::instructions::Instruction; use std::marker::Copy; use evm::{MessageCallResult, ContractCreateResult}; -#[cfg(not(feature = "evm_debug"))] +#[cfg(not(feature = "evm-debug"))] macro_rules! evm_debug { ($x: expr) => {} } -#[cfg(feature = "evm_debug")] +#[cfg(feature = "evm-debug")] macro_rules! evm_debug { ($x: expr) => { $x } } -#[cfg(feature = "evm_debug")] +#[cfg(feature = "evm-debug")] fn color(instruction: Instruction, name: &'static str) -> String { let c = instruction as usize % 6; let colors = [31, 34, 33, 32, 35, 36]; diff --git a/src/null_engine.rs b/src/null_engine.rs index 3b03508a2..3c829606c 100644 --- a/src/null_engine.rs +++ b/src/null_engine.rs @@ -11,7 +11,7 @@ pub struct NullEngine { } impl NullEngine { - /// TODO [Tomusdrw] Please document me + /// Returns new instance of NullEngine with default VM Factory pub fn new_boxed(spec: Spec) -> Box { Box::new(NullEngine{ spec: spec, diff --git a/src/tests/executive.rs b/src/tests/executive.rs index fe428e199..6281b3eeb 100644 --- a/src/tests/executive.rs +++ b/src/tests/executive.rs @@ -277,11 +277,10 @@ fn do_json_test_for(vm: &VMType, json_data: &[u8]) -> Vec { declare_test!{ExecutiveTests_vmArithmeticTest, "VMTests/vmArithmeticTest"} declare_test!{ExecutiveTests_vmBitwiseLogicOperationTest, "VMTests/vmBitwiseLogicOperationTest"} // this one crashes with some vm internal error. Separately they pass. -declare_test_ignore!{ExecutiveTests_vmBlockInfoTest, "VMTests/vmBlockInfoTest"} +declare_test!{ignore => ExecutiveTests_vmBlockInfoTest, "VMTests/vmBlockInfoTest"} declare_test!{ExecutiveTests_vmEnvironmentalInfoTest, "VMTests/vmEnvironmentalInfoTest"} declare_test!{ExecutiveTests_vmIOandFlowOperationsTest, "VMTests/vmIOandFlowOperationsTest"} -// this one take way too long. -declare_test_ignore!{ExecutiveTests_vmInputLimits, "VMTests/vmInputLimits"} +declare_test!{heavy => ExecutiveTests_vmInputLimits, "VMTests/vmInputLimits"} declare_test!{ExecutiveTests_vmLogTest, "VMTests/vmLogTest"} declare_test!{ExecutiveTests_vmPerformanceTest, "VMTests/vmPerformanceTest"} declare_test!{ExecutiveTests_vmPushDupSwapTest, "VMTests/vmPushDupSwapTest"} diff --git a/src/tests/state.rs b/src/tests/state.rs index 119e7037a..03a5e05e1 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -73,7 +73,7 @@ fn do_json_test(json_data: &[u8]) -> Vec { declare_test!{StateTests_stBlockHashTest, "StateTests/stBlockHashTest"} declare_test!{StateTests_stCallCodes, "StateTests/stCallCodes"} -declare_test_ignore!{StateTests_stCallCreateCallCodeTest, "StateTests/stCallCreateCallCodeTest"} //<< Out of stack +declare_test!{ignore => StateTests_stCallCreateCallCodeTest, "StateTests/stCallCreateCallCodeTest"} //<< Out of stack declare_test!{StateTests_stDelegatecallTest, "StateTests/stDelegatecallTest"} //<< FAIL - gas too high declare_test!{StateTests_stExample, "StateTests/stExample"} declare_test!{StateTests_stInitCodeTest, "StateTests/stInitCodeTest"} @@ -81,12 +81,12 @@ declare_test!{StateTests_stLogTests, "StateTests/stLogTests"} declare_test!{StateTests_stMemoryStressTest, "StateTests/stMemoryStressTest"} declare_test!{StateTests_stMemoryTest, "StateTests/stMemoryTest"} declare_test!{StateTests_stPreCompiledContracts, "StateTests/stPreCompiledContracts"} -declare_test_ignore!{StateTests_stQuadraticComplexityTest, "StateTests/stQuadraticComplexityTest"} //<< Too long -declare_test_ignore!{StateTests_stRecursiveCreate, "StateTests/stRecursiveCreate"} //<< Out of stack +declare_test!{heavy => StateTests_stQuadraticComplexityTest, "StateTests/stQuadraticComplexityTest"} //<< Too long +declare_test!{ignore => StateTests_stRecursiveCreate, "StateTests/stRecursiveCreate"} //<< Out of stack declare_test!{StateTests_stRefundTest, "StateTests/stRefundTest"} declare_test!{StateTests_stSolidityTest, "StateTests/stSolidityTest"} -declare_test_ignore!{StateTests_stSpecialTest, "StateTests/stSpecialTest"} //<< Signal 11 -declare_test_ignore!{StateTests_stSystemOperationsTest, "StateTests/stSystemOperationsTest"} //<< Signal 11 +declare_test!{ignore => StateTests_stSpecialTest, "StateTests/stSpecialTest"} //<< Signal 11 +declare_test!{ignore => StateTests_stSystemOperationsTest, "StateTests/stSystemOperationsTest"} //<< Signal 11 declare_test!{StateTests_stTransactionTest, "StateTests/stTransactionTest"} declare_test!{StateTests_stTransitionTest, "StateTests/stTransitionTest"} declare_test!{StateTests_stWalletTest, "StateTests/stWalletTest"} diff --git a/src/tests/test_common.rs b/src/tests/test_common.rs index 15c5364c4..548158fb8 100644 --- a/src/tests/test_common.rs +++ b/src/tests/test_common.rs @@ -1,24 +1,34 @@ pub use common::*; +macro_rules! test { + ($name: expr) => { + assert!(do_json_test(include_bytes!(concat!("../../res/ethereum/tests/", $name, ".json"))).len() == 0); + } +} + #[macro_export] macro_rules! declare_test { - ($id: ident, $name: expr) => { - #[test] - #[allow(non_snake_case)] - fn $id() { - assert!(do_json_test(include_bytes!(concat!("../../res/ethereum/tests/", $name, ".json"))).len() == 0); - } - }; -} - -#[macro_export] -macro_rules! declare_test_ignore { - ($id: ident, $name: expr) => { - #[test] + (ignore => $id: ident, $name: expr) => { #[ignore] + #[test] #[allow(non_snake_case)] fn $id() { - assert!(do_json_test(include_bytes!(concat!("../../res/ethereum/tests/", $name, ".json"))).len() == 0); + test!($name); } }; + (heavy => $id: ident, $name: expr) => { + #[cfg(feature = "test-heavy")] + #[test] + #[allow(non_snake_case)] + fn $id() { + test!($name); + } + }; + ($id: ident, $name: expr) => { + #[test] + #[allow(non_snake_case)] + fn $id() { + test!($name); + } + } } diff --git a/src/tests/transaction.rs b/src/tests/transaction.rs index d4836ca84..1603ad55a 100644 --- a/src/tests/transaction.rs +++ b/src/tests/transaction.rs @@ -70,9 +70,9 @@ declare_test!{TransactionTests/Homestead/ttWrongRLPTransaction} declare_test!{TransactionTests/RandomTests/tr201506052141PYTHON}*/ declare_test!{TransactionTests_ttTransactionTest, "TransactionTests/ttTransactionTest"} -declare_test_ignore!{TransactionTests_tt10mbDataField, "TransactionTests/tt10mbDataField"} +declare_test!{ignore => TransactionTests_tt10mbDataField, "TransactionTests/tt10mbDataField"} declare_test!{TransactionTests_ttWrongRLPTransaction, "TransactionTests/ttWrongRLPTransaction"} declare_test!{TransactionTests_Homestead_ttTransactionTest, "TransactionTests/Homestead/ttTransactionTest"} -declare_test_ignore!{TransactionTests_Homestead_tt10mbDataField, "TransactionTests/Homestead/tt10mbDataField"} +declare_test!{ignore => TransactionTests_Homestead_tt10mbDataField, "TransactionTests/Homestead/tt10mbDataField"} declare_test!{TransactionTests_Homestead_ttWrongRLPTransaction, "TransactionTests/Homestead/ttWrongRLPTransaction"} declare_test!{TransactionTests_RandomTests_tr201506052141PYTHON, "TransactionTests/RandomTests/tr201506052141PYTHON"}