Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Fix deps
Browse files Browse the repository at this point in the history
  • Loading branch information
adria0 committed Jun 26, 2020
1 parent e1c9b76 commit cf78a15
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
4 changes: 2 additions & 2 deletions ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ unexpected = { path = "../util/unexpected" }
using_queue = { path = "../miner/using-queue" }
verification = { path = "./verification" }
vm = { path = "vm" }
walkdir = "2.3.1"
walkdir = { version = "2.3.1", optional = true }

[dev-dependencies]
account-db = { path = "account-db" }
Expand Down Expand Up @@ -115,7 +115,7 @@ evm-debug-tests = ["evm-debug", "evm/evm-debug-tests"]
# EVM debug traces are printed.
slow-blocks = []
# Run JSON consensus tests.
json-tests = ["env_logger", "test-helpers", "lazy_static", "machine/test-helpers", "common-types/test-helpers"]
json-tests = ["env_logger", "test-helpers", "walkdir", "machine/test-helpers", "common-types/test-helpers"]
# Run memory/cpu heavy tests.
test-heavy = []
# Compile test helpers
Expand Down
2 changes: 1 addition & 1 deletion ethcore/res/ethereum/tests
Submodule tests updated 13763 files
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod test_common;
mod transaction;
mod trie;
mod difficulty;
pub mod runner;
mod runner;

pub use self::executive::run_test_path as run_executive_test_path;
pub use self::executive::run_test_file as run_executive_test_file;
Expand Down
36 changes: 23 additions & 13 deletions ethcore/src/json_tests/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,44 @@

// You should have received a copy of the GNU General Public License
// along with Open Ethereum. If not, see <http://www.gnu.org/licenses/>.
#![allow(dead_code)]

use ethjson::test_helpers::ethspec::{
ChainTests, DifficultyTests, EthereumTestSuite, ExecutiveTests, StateTests, TestChainSpec,
TestTrieSpec, TransactionTests, TrieTests,
};
use globset::Glob;
use log::{info, warn};
use log::info;
use rayon::prelude::*;
use std::path::{Path, PathBuf};
use tempfile::tempdir;
use trie::TrieSpec;
use walkdir::{DirEntry, WalkDir};

/// Result of tests execution
pub struct TestResult {
/// Number of success execution
pub success: usize,
/// Number of success execution
pub failed: Vec<String>,
}

impl TestResult {
/// Creates a new TestResult without results
pub fn zero() -> Self {
TestResult {
success: 0,
failed: Vec::new(),
}
}
/// Creates a new success TestResult
pub fn success() -> Self {
TestResult {
success: 1,
failed: Vec::new(),
}
}
/// Creates a new failed TestResult
pub fn failed(name: &str) -> Self {
TestResult {
success: 0,
Expand Down Expand Up @@ -73,13 +80,15 @@ impl std::ops::AddAssign for TestResult {
pub struct TestRunner(EthereumTestSuite);

impl TestRunner {
/// Loads a new JSON Test suite
pub fn load<R>(reader: R) -> Result<Self, serde_json::Error>
where
R: std::io::Read,
{
Ok(TestRunner(serde_json::from_reader(reader)?))
}

/// Run the tests with one thread
pub fn run_without_par(&self) -> TestResult {
let pool = rayon::ThreadPoolBuilder::new()
.num_threads(1)
Expand All @@ -88,6 +97,7 @@ impl TestRunner {
pool.install(|| self.run())
}

/// Run the tests
pub fn run(&self) -> TestResult {
let mut res = TestResult::zero();
for t in &self.0.chain {
Expand Down Expand Up @@ -120,10 +130,6 @@ impl TestRunner {
.collect::<Vec<PathBuf>>()
}

fn report_failed_tests(path: &Path, list: &Vec<String>) {
warn!("FAILED TESTS FOR {:?}: {:?} ", path, list);
}

fn run1<T, F>(test: &T, base_path: &str, f: F) -> TestResult
where
T: Send + Sync,
Expand All @@ -149,7 +155,7 @@ impl TestRunner {
result
}

pub fn in_set(path: &Path, exprs: &[String]) -> bool {
fn in_set(path: &Path, exprs: &[String]) -> bool {
for pathexp in exprs {
let glob = Glob::new(&pathexp)
.expect(&format!("cannot parse expression {}", pathexp))
Expand All @@ -161,7 +167,7 @@ impl TestRunner {
false
}

pub fn run_chain_tests(test: &ChainTests) -> TestResult {
fn run_chain_tests(test: &ChainTests) -> TestResult {
Self::run1(
test,
&test.path,
Expand All @@ -176,7 +182,8 @@ impl TestRunner {
},
)
}
pub fn run_state_tests(test: &StateTests) -> TestResult {

fn run_state_tests(test: &StateTests) -> TestResult {
Self::run1(
test,
&test.path,
Expand All @@ -191,7 +198,8 @@ impl TestRunner {
},
)
}
pub fn run_difficuly_tests(test: &DifficultyTests) -> TestResult {

fn run_difficuly_tests(test: &DifficultyTests) -> TestResult {
let mut acc = TestResult::zero();
for path in &test.path {
acc += Self::run1(
Expand All @@ -213,7 +221,7 @@ impl TestRunner {
acc
}

pub fn run_executive_tests(test: &ExecutiveTests) -> TestResult {
fn run_executive_tests(test: &ExecutiveTests) -> TestResult {
Self::run1(
test,
&test.path,
Expand All @@ -222,16 +230,18 @@ impl TestRunner {
},
)
}
pub fn run_transaction_tests(test: &TransactionTests) -> TestResult {

fn run_transaction_tests(test: &TransactionTests) -> TestResult {
Self::run1(
test,
&test.path,
|test: &TransactionTests, path: &Path, json: &[u8]| {
|_: &TransactionTests, path: &Path, json: &[u8]| {
super::transaction::do_json_test(&path, &json, &mut |_, _| {})
},
)
}
pub fn run_trie_tests(test: &TrieTests) -> TestResult {

fn run_trie_tests(test: &TrieTests) -> TestResult {
let mut acc = TestResult::zero();
for path in &test.path {
acc += Self::run1(test, &path, |test: &TrieTests, path: &Path, json: &[u8]| {
Expand Down
10 changes: 8 additions & 2 deletions ethcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ extern crate ethcore_miner;
extern crate ethereum_types;
extern crate executive_state;
extern crate futures;
extern crate globset;
extern crate hash_db;
extern crate itertools;
extern crate journaldb;
Expand All @@ -52,14 +51,21 @@ extern crate serde;
extern crate snapshot;
extern crate spec;
extern crate state_db;
extern crate tempfile;
extern crate trace;
extern crate trie_vm_factories;
extern crate triehash_ethereum as triehash;
extern crate unexpected;
extern crate using_queue;
extern crate verification;
extern crate vm;

#[cfg(feature = "json-tests")]
extern crate globset;

#[cfg(feature = "json-tests")]
extern crate tempfile;

#[cfg(feature = "json-tests")]
extern crate walkdir;

#[cfg(test)]
Expand Down

0 comments on commit cf78a15

Please sign in to comment.