dev/test tools to separate crate

This commit is contained in:
Nikolay Volf
2016-02-19 17:18:20 +03:00
parent 1866174327
commit fed90c126e
18 changed files with 809 additions and 74 deletions

View File

@@ -22,6 +22,9 @@ clippy = { version = "0.0.42", optional = true }
crossbeam = "0.1.5"
lazy_static = "0.1"
[dev-dependencies]
ethcore-devtools = { path = "../devtools" }
[features]
jit = ["evmjit"]
evm-debug = []

View File

@@ -664,6 +664,7 @@ mod tests {
use util::hash::*;
use blockchain::*;
use tests::helpers::*;
use devtools::*;
#[test]
fn valid_tests_extra32() {
@@ -679,7 +680,7 @@ mod tests {
assert_eq!(bc.best_block_hash(), genesis_hash.clone());
assert_eq!(bc.block_hash(0), Some(genesis_hash.clone()));
assert_eq!(bc.block_hash(1), None);
let first = "f90285f90219a03caa2203f3d7c136c0295ed128a7d31cea520b1ca5e27afe17d0853331798942a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0bac6177a79e910c98d86ec31a09ae37ac2de15b754fd7bed1ba52362c49416bfa0d45893a296c1490a978e0bd321b5f2635d8280365c1fe9f693d65f233e791344a0c7778a7376099ee2e5c455791c1885b5c361b95713fddcbe32d97fd01334d296b90100000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000400000000000000000000000000000000000000000000000000000008302000001832fefd882560b845627cb99a00102030405060708091011121314151617181920212223242526272829303132a08ccb2837fb2923bd97e8f2d08ea32012d6e34be018c73e49a0f98843e8f47d5d88e53be49fec01012ef866f864800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d8785012a05f200801ba0cb088b8d2ff76a7b2c6616c9d02fb6b7a501afbf8b69d7180b09928a1b80b5e4a06448fe7476c606582039bb72a9f6f4b4fad18507b8dfbd00eebbe151cc573cd2c0".from_hex().unwrap();
bc.insert_block(&first);
@@ -855,7 +856,7 @@ mod tests {
let temp = RandomTempPath::new();
let bc = BlockChain::new(&genesis, temp.as_path());
bc.insert_block(&b1);
let transactions = bc.transactions(&b1_hash).unwrap();
assert_eq!(transactions.len(), 7);
for t in transactions {

View File

@@ -20,6 +20,7 @@ use pod_state::*;
use block::Block;
use ethereum;
use tests::helpers::*;
use devtools::*;
pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
init_log();

View File

@@ -92,6 +92,7 @@ extern crate env_logger;
extern crate num_cpus;
extern crate crossbeam;
#[cfg(test)] extern crate ethcore_devtools as devtools;
#[cfg(feature = "jit" )] extern crate evmjit;
pub mod block;

View File

@@ -163,7 +163,7 @@ impl State {
/// Mutate storage of account `address` so that it is `value` for `key`.
pub fn storage_at(&self, address: &Address, key: &H256) -> H256 {
self.get(address, false).as_ref().map_or(H256::new(), |a|a.storage_at(&AccountDB::new(&self.db, address), key))
self.get(address, false).as_ref().map_or(H256::new(), |a|a.storage_at(&AccountDB::new(&self.db, address), key))
}
/// Mutate storage of account `a` so that it is `value` for `key`.
@@ -341,6 +341,7 @@ use util::rlp::*;
use util::uint::*;
use account::*;
use tests::helpers::*;
use devtools::*;
#[test]
fn code_from_database() {

View File

@@ -17,6 +17,7 @@
use client::{BlockChainClient, Client, BlockId};
use tests::helpers::*;
use common::*;
use devtools::*;
#[test]
fn created() {

View File

@@ -15,17 +15,15 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use client::{BlockChainClient, Client};
use std::env;
use common::*;
use std::path::PathBuf;
use spec::*;
use std::fs::{remove_dir_all};
use blockchain::{BlockChain};
use state::*;
use rocksdb::*;
use evm::{Schedule, Factory};
use engine::*;
use ethereum;
use devtools::*;
#[cfg(feature = "json-tests")]
pub enum ChainEra {
@@ -33,36 +31,6 @@ pub enum ChainEra {
Homestead,
}
pub struct RandomTempPath {
path: PathBuf
}
impl RandomTempPath {
pub fn new() -> RandomTempPath {
let mut dir = env::temp_dir();
dir.push(H32::random().hex());
RandomTempPath {
path: dir.clone()
}
}
pub fn as_path(&self) -> &PathBuf {
&self.path
}
pub fn as_str(&self) -> &str {
self.path.to_str().unwrap()
}
}
impl Drop for RandomTempPath {
fn drop(&mut self) {
if let Err(e) = remove_dir_all(self.as_path()) {
panic!("failed to remove temp directory, probably something failed to destroyed ({})", e);
}
}
}
#[cfg(test)]
pub struct GuardedTempResult<T> {
result: Option<T>,