From 124cfcc11ef1a170a609c261ab0bf6fb5c016b16 Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Thu, 21 Jan 2016 16:08:09 +0100 Subject: [PATCH 1/5] 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"} From b07cbcd8cdd47e140778e01afb3bbef4fd4a2261 Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Thu, 21 Jan 2016 19:32:48 +0100 Subject: [PATCH 2/5] Changing some tests from ignore to heavy --- src/tests/transaction.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tests/transaction.rs b/src/tests/transaction.rs index 1603ad55a..967738c91 100644 --- a/src/tests/transaction.rs +++ b/src/tests/transaction.rs @@ -65,14 +65,14 @@ declare_test!{TransactionTests/ttTransactionTest} declare_test!{TransactionTests/tt10mbDataField} declare_test!{TransactionTests/ttWrongRLPTransaction} declare_test!{TransactionTests/Homestead/ttTransactionTest} -declare_test!{TransactionTests/Homestead/tt10mbDataField} +declare_test!{heavy => TransactionTests/Homestead/tt10mbDataField} 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!{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!{heavy => TransactionTests_Homestead_tt10mbDataField, "TransactionTests/Homestead/tt10mbDataField"} declare_test!{TransactionTests_Homestead_ttWrongRLPTransaction, "TransactionTests/Homestead/ttWrongRLPTransaction"} declare_test!{TransactionTests_RandomTests_tr201506052141PYTHON, "TransactionTests/RandomTests/tr201506052141PYTHON"} From bb4e31b22438756a4ff9b8c9a91dba5fede91374 Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Fri, 22 Jan 2016 08:04:52 +0100 Subject: [PATCH 3/5] Marking test as heavy / ignored --- src/tests/state.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tests/state.rs b/src/tests/state.rs index 03a5e05e1..6b7561142 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -74,19 +74,19 @@ 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!{StateTests_stDelegatecallTest, "StateTests/stDelegatecallTest"} //<< FAIL - gas too high +declare_test!{StateTests_stDelegatecallTest, "StateTests/stDelegatecallTest"} declare_test!{StateTests_stExample, "StateTests/stExample"} declare_test!{StateTests_stInitCodeTest, "StateTests/stInitCodeTest"} 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!{heavy => 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"} //<< Out of Stack +declare_test!{ignore => StateTests_stSystemOperationsTest, "StateTests/stSystemOperationsTest"} //<< Out of stack declare_test!{StateTests_stTransactionTest, "StateTests/stTransactionTest"} declare_test!{StateTests_stTransitionTest, "StateTests/stTransitionTest"} declare_test!{StateTests_stWalletTest, "StateTests/stWalletTest"} From b00e4b9d95a348c6500a1d9a82762777dc4fbe32 Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Fri, 22 Jan 2016 08:07:53 +0100 Subject: [PATCH 4/5] Marking more tests as 'heavy' --- src/tests/state.rs | 4 ++-- src/tests/transaction.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tests/state.rs b/src/tests/state.rs index 6b7561142..d768d1bb8 100644 --- a/src/tests/state.rs +++ b/src/tests/state.rs @@ -78,8 +78,8 @@ declare_test!{StateTests_stDelegatecallTest, "StateTests/stDelegatecallTest"} declare_test!{StateTests_stExample, "StateTests/stExample"} declare_test!{StateTests_stInitCodeTest, "StateTests/stInitCodeTest"} declare_test!{StateTests_stLogTests, "StateTests/stLogTests"} -declare_test!{StateTests_stMemoryStressTest, "StateTests/stMemoryStressTest"} -declare_test!{StateTests_stMemoryTest, "StateTests/stMemoryTest"} +declare_test!{heavy => StateTests_stMemoryStressTest, "StateTests/stMemoryStressTest"} +declare_test!{heavy => StateTests_stMemoryTest, "StateTests/stMemoryTest"} declare_test!{StateTests_stPreCompiledContracts, "StateTests/stPreCompiledContracts"} declare_test!{heavy => StateTests_stQuadraticComplexityTest, "StateTests/stQuadraticComplexityTest"} //<< Too long declare_test!{ignore => StateTests_stRecursiveCreate, "StateTests/stRecursiveCreate"} //<< Out of stack diff --git a/src/tests/transaction.rs b/src/tests/transaction.rs index 967738c91..cd378c35f 100644 --- a/src/tests/transaction.rs +++ b/src/tests/transaction.rs @@ -70,7 +70,7 @@ declare_test!{TransactionTests/Homestead/ttWrongRLPTransaction} declare_test!{TransactionTests/RandomTests/tr201506052141PYTHON}*/ declare_test!{TransactionTests_ttTransactionTest, "TransactionTests/ttTransactionTest"} -declare_test!{TransactionTests_tt10mbDataField, "TransactionTests/tt10mbDataField"} +declare_test!{heavy => TransactionTests_tt10mbDataField, "TransactionTests/tt10mbDataField"} declare_test!{TransactionTests_ttWrongRLPTransaction, "TransactionTests/ttWrongRLPTransaction"} declare_test!{TransactionTests_Homestead_ttTransactionTest, "TransactionTests/Homestead/ttTransactionTest"} declare_test!{heavy => TransactionTests_Homestead_tt10mbDataField, "TransactionTests/Homestead/tt10mbDataField"} From 1970d79337a7f22ce5187107a3cad8d7f6426cc2 Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Fri, 22 Jan 2016 08:09:16 +0100 Subject: [PATCH 5/5] Adding git hook --- hook.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 hook.sh diff --git a/hook.sh b/hook.sh new file mode 100755 index 000000000..a82f926b9 --- /dev/null +++ b/hook.sh @@ -0,0 +1,3 @@ +#!/bin/sh +echo "#!/bin/sh\ncargo test" >> ./.git/hooks/pre-push +chmod +x ./.git/hooks/pre-push