Merge branch 'master' of github.com:ethcore/parity into network
This commit is contained in:
commit
93d259e8cb
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -8,6 +8,7 @@ dependencies = [
|
|||||||
"docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)",
|
"docopt 0.6.78 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ethcore 0.9.99",
|
"ethcore 0.9.99",
|
||||||
|
"ethcore-devtools 0.9.99",
|
||||||
"ethcore-rpc 0.9.99",
|
"ethcore-rpc 0.9.99",
|
||||||
"ethcore-util 0.9.99",
|
"ethcore-util 0.9.99",
|
||||||
"ethsync 0.9.99",
|
"ethsync 0.9.99",
|
||||||
@ -173,6 +174,7 @@ dependencies = [
|
|||||||
"crossbeam 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ethash 0.9.99",
|
"ethash 0.9.99",
|
||||||
|
"ethcore-devtools 0.9.99",
|
||||||
"ethcore-util 0.9.99",
|
"ethcore-util 0.9.99",
|
||||||
"heapsize 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -184,6 +186,13 @@ dependencies = [
|
|||||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ethcore-devtools"
|
||||||
|
version = "0.9.99"
|
||||||
|
dependencies = [
|
||||||
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethcore-rpc"
|
name = "ethcore-rpc"
|
||||||
version = "0.9.99"
|
version = "0.9.99"
|
||||||
@ -212,6 +221,7 @@ dependencies = [
|
|||||||
"elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"eth-secp256k1 0.5.4 (git+https://github.com/arkpar/rust-secp256k1.git)",
|
"eth-secp256k1 0.5.4 (git+https://github.com/arkpar/rust-secp256k1.git)",
|
||||||
|
"ethcore-devtools 0.9.99",
|
||||||
"heapsize 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"heapsize 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"igd 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"igd 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"itertools 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"itertools 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -19,6 +19,7 @@ ethcore-rpc = { path = "rpc", optional = true }
|
|||||||
fdlimit = { path = "util/fdlimit" }
|
fdlimit = { path = "util/fdlimit" }
|
||||||
target_info = "0.1"
|
target_info = "0.1"
|
||||||
daemonize = "0.2"
|
daemonize = "0.2"
|
||||||
|
ethcore-devtools = { path = "devtools" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["rpc"]
|
default = ["rpc"]
|
||||||
|
16
devtools/Cargo.toml
Normal file
16
devtools/Cargo.toml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[package]
|
||||||
|
description = "Ethcore development/test/build tools"
|
||||||
|
homepage = "http://ethcore.io"
|
||||||
|
license = "GPL-3.0"
|
||||||
|
name = "ethcore-devtools"
|
||||||
|
version = "0.9.99"
|
||||||
|
authors = ["Ethcore <admin@ethcore.io>"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
rand = "0.3"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/lib.rs"
|
||||||
|
test = true
|
1
devtools/README.md
Normal file
1
devtools/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# ethcore dev tools
|
24
devtools/src/lib.rs
Normal file
24
devtools/src/lib.rs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Parity is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! dev-tools
|
||||||
|
|
||||||
|
|
||||||
|
extern crate rand;
|
||||||
|
|
||||||
|
pub mod random_path;
|
||||||
|
|
||||||
|
pub use random_path::*;
|
89
devtools/src/random_path.rs
Normal file
89
devtools/src/random_path.rs
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Parity is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Random path
|
||||||
|
|
||||||
|
use std::path::*;
|
||||||
|
use std::fs;
|
||||||
|
use std::env;
|
||||||
|
use rand::random;
|
||||||
|
|
||||||
|
pub struct RandomTempPath {
|
||||||
|
path: PathBuf
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn random_filename() -> String {
|
||||||
|
(0..8).map(|_| ((random::<f32>() * 26.0) as u8 + 97) as char).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RandomTempPath {
|
||||||
|
pub fn new() -> RandomTempPath {
|
||||||
|
let mut dir = env::temp_dir();
|
||||||
|
dir.push(random_filename());
|
||||||
|
RandomTempPath {
|
||||||
|
path: dir.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn create_dir() -> RandomTempPath {
|
||||||
|
let mut dir = env::temp_dir();
|
||||||
|
dir.push(random_filename());
|
||||||
|
fs::create_dir_all(dir.as_path()).unwrap();
|
||||||
|
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) = fs::remove_dir_all(self.as_path()) {
|
||||||
|
panic!("failed to remove temp directory, probably something failed to destroyed ({})", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn creates_dir() {
|
||||||
|
let temp = RandomTempPath::create_dir();
|
||||||
|
assert!(fs::metadata(temp.as_path()).unwrap().is_dir());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn destroys_dir() {
|
||||||
|
let path_buf = {
|
||||||
|
let temp = RandomTempPath::create_dir();
|
||||||
|
assert!(fs::metadata(temp.as_path()).unwrap().is_dir());
|
||||||
|
let path_buf = temp.as_path().to_path_buf();
|
||||||
|
path_buf
|
||||||
|
};
|
||||||
|
|
||||||
|
assert!(fs::metadata(&path_buf).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn provides_random() {
|
||||||
|
let temp = RandomTempPath::create_dir();
|
||||||
|
assert!(temp.as_path().to_str().is_some());
|
||||||
|
}
|
@ -21,6 +21,7 @@ num_cpus = "0.2"
|
|||||||
clippy = { version = "0.0.42", optional = true }
|
clippy = { version = "0.0.42", optional = true }
|
||||||
crossbeam = "0.1.5"
|
crossbeam = "0.1.5"
|
||||||
lazy_static = "0.1"
|
lazy_static = "0.1"
|
||||||
|
ethcore-devtools = { path = "../devtools" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
jit = ["evmjit"]
|
jit = ["evmjit"]
|
||||||
|
@ -664,6 +664,7 @@ mod tests {
|
|||||||
use util::hash::*;
|
use util::hash::*;
|
||||||
use blockchain::*;
|
use blockchain::*;
|
||||||
use tests::helpers::*;
|
use tests::helpers::*;
|
||||||
|
use devtools::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn valid_tests_extra32() {
|
fn valid_tests_extra32() {
|
||||||
@ -696,7 +697,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[allow(cyclomatic_complexity)]
|
#[cfg_attr(feature="dev", allow(cyclomatic_complexity))]
|
||||||
fn test_small_fork() {
|
fn test_small_fork() {
|
||||||
let genesis = "f901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a07dba07d6b448a186e9612e5f737d1c909dce473e53199901a302c00646d523c1a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8808454c98c8142a059262c330941f3fe2a34d16d6e3c7b30d2ceb37c6a0e9a994c494ee1a61d2410885aa4c8bf8e56e264c0c0".from_hex().unwrap();
|
let genesis = "f901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a07dba07d6b448a186e9612e5f737d1c909dce473e53199901a302c00646d523c1a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8808454c98c8142a059262c330941f3fe2a34d16d6e3c7b30d2ceb37c6a0e9a994c494ee1a61d2410885aa4c8bf8e56e264c0c0".from_hex().unwrap();
|
||||||
let b1 = "f90261f901f9a05716670833ec874362d65fea27a7cd35af5897d275b31a44944113111e4e96d2a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0cb52de543653d86ccd13ba3ddf8b052525b04231c6884a4db3188a184681d878a0e78628dd45a1f8dc495594d83b76c588a3ee67463260f8b7d4a42f574aeab29aa0e9244cf7503b79c03d3a099e07a80d2dbc77bb0b502d8a89d51ac0d68dd31313b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd882520884562791e580a051b3ecba4e3f2b49c11d42dd0851ec514b1be3138080f72a2b6e83868275d98f8877671f479c414b47f862f86080018304cb2f94095e7baea6a6c7c4c2dfeb977efac326af552d870a801ca09e2709d7ec9bbe6b1bbbf0b2088828d14cd5e8642a1fee22dc74bfa89761a7f9a04bd8813dee4be989accdb708b1c2e325a7e9c695a8024e30e89d6c644e424747c0".from_hex().unwrap();
|
let b1 = "f90261f901f9a05716670833ec874362d65fea27a7cd35af5897d275b31a44944113111e4e96d2a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0cb52de543653d86ccd13ba3ddf8b052525b04231c6884a4db3188a184681d878a0e78628dd45a1f8dc495594d83b76c588a3ee67463260f8b7d4a42f574aeab29aa0e9244cf7503b79c03d3a099e07a80d2dbc77bb0b502d8a89d51ac0d68dd31313b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd882520884562791e580a051b3ecba4e3f2b49c11d42dd0851ec514b1be3138080f72a2b6e83868275d98f8877671f479c414b47f862f86080018304cb2f94095e7baea6a6c7c4c2dfeb977efac326af552d870a801ca09e2709d7ec9bbe6b1bbbf0b2088828d14cd5e8642a1fee22dc74bfa89761a7f9a04bd8813dee4be989accdb708b1c2e325a7e9c695a8024e30e89d6c644e424747c0".from_hex().unwrap();
|
||||||
|
@ -25,7 +25,7 @@ struct FakeLogEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
#[allow(enum_variant_names)] // Common prefix is C ;)
|
#[cfg_attr(feature="dev", allow(enum_variant_names))] // Common prefix is C ;)
|
||||||
enum FakeCallType {
|
enum FakeCallType {
|
||||||
CALL, CREATE
|
CALL, CREATE
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ use pod_state::*;
|
|||||||
use block::Block;
|
use block::Block;
|
||||||
use ethereum;
|
use ethereum;
|
||||||
use tests::helpers::*;
|
use tests::helpers::*;
|
||||||
|
use devtools::*;
|
||||||
|
|
||||||
pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
|
pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
|
||||||
init_log();
|
init_log();
|
||||||
|
@ -92,6 +92,7 @@ extern crate env_logger;
|
|||||||
extern crate num_cpus;
|
extern crate num_cpus;
|
||||||
extern crate crossbeam;
|
extern crate crossbeam;
|
||||||
|
|
||||||
|
#[cfg(test)] extern crate ethcore_devtools as devtools;
|
||||||
#[cfg(feature = "jit" )] extern crate evmjit;
|
#[cfg(feature = "jit" )] extern crate evmjit;
|
||||||
|
|
||||||
pub mod block;
|
pub mod block;
|
||||||
|
@ -129,6 +129,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use tests::helpers::*;
|
use tests::helpers::*;
|
||||||
use util::network::*;
|
use util::network::*;
|
||||||
|
use devtools::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_can_be_started() {
|
fn it_can_be_started() {
|
||||||
|
@ -341,6 +341,7 @@ use util::rlp::*;
|
|||||||
use util::uint::*;
|
use util::uint::*;
|
||||||
use account::*;
|
use account::*;
|
||||||
use tests::helpers::*;
|
use tests::helpers::*;
|
||||||
|
use devtools::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn code_from_database() {
|
fn code_from_database() {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
use client::{BlockChainClient, Client, BlockId};
|
use client::{BlockChainClient, Client, BlockId};
|
||||||
use tests::helpers::*;
|
use tests::helpers::*;
|
||||||
use common::*;
|
use common::*;
|
||||||
|
use devtools::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn created() {
|
fn created() {
|
||||||
|
@ -15,17 +15,15 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use client::{BlockChainClient, Client};
|
use client::{BlockChainClient, Client};
|
||||||
use std::env;
|
|
||||||
use common::*;
|
use common::*;
|
||||||
use std::path::PathBuf;
|
|
||||||
use spec::*;
|
use spec::*;
|
||||||
use std::fs::{remove_dir_all};
|
|
||||||
use blockchain::{BlockChain};
|
use blockchain::{BlockChain};
|
||||||
use state::*;
|
use state::*;
|
||||||
use rocksdb::*;
|
use rocksdb::*;
|
||||||
use evm::{Schedule, Factory};
|
use evm::{Schedule, Factory};
|
||||||
use engine::*;
|
use engine::*;
|
||||||
use ethereum;
|
use ethereum;
|
||||||
|
use devtools::*;
|
||||||
|
|
||||||
#[cfg(feature = "json-tests")]
|
#[cfg(feature = "json-tests")]
|
||||||
pub enum ChainEra {
|
pub enum ChainEra {
|
||||||
@ -33,36 +31,6 @@ pub enum ChainEra {
|
|||||||
Homestead,
|
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)]
|
#[cfg(test)]
|
||||||
pub struct GuardedTempResult<T> {
|
pub struct GuardedTempResult<T> {
|
||||||
result: Option<T>,
|
result: Option<T>,
|
||||||
|
@ -30,6 +30,7 @@ clippy = { version = "0.0.42", optional = true }
|
|||||||
json-tests = { path = "json-tests" }
|
json-tests = { path = "json-tests" }
|
||||||
target_info = "0.1.0"
|
target_info = "0.1.0"
|
||||||
igd = "0.4.2"
|
igd = "0.4.2"
|
||||||
|
ethcore-devtools = { path = "../devtools" }
|
||||||
libc = "0.2.7"
|
libc = "0.2.7"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -635,7 +635,7 @@ mod tests {
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[allow(eq_op)]
|
#[cfg_attr(feature="dev", allow(eq_op))]
|
||||||
fn hash() {
|
fn hash() {
|
||||||
let h = H64([0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef]);
|
let h = H64([0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef]);
|
||||||
assert_eq!(H64::from_str("0123456789abcdef").unwrap(), h);
|
assert_eq!(H64::from_str("0123456789abcdef").unwrap(), h);
|
||||||
|
@ -1030,7 +1030,7 @@ mod file_tests {
|
|||||||
mod directory_tests {
|
mod directory_tests {
|
||||||
use super::{KeyDirectory, new_uuid, uuid_to_string, KeyFileContent, KeyFileCrypto, MAX_CACHE_USAGE_TRACK};
|
use super::{KeyDirectory, new_uuid, uuid_to_string, KeyFileContent, KeyFileCrypto, MAX_CACHE_USAGE_TRACK};
|
||||||
use common::*;
|
use common::*;
|
||||||
use tests::helpers::*;
|
use devtools::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn key_directory_locates_keys() {
|
fn key_directory_locates_keys() {
|
||||||
@ -1110,7 +1110,7 @@ mod directory_tests {
|
|||||||
mod specs {
|
mod specs {
|
||||||
use super::*;
|
use super::*;
|
||||||
use common::*;
|
use common::*;
|
||||||
use tests::helpers::*;
|
use devtools::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_initiate_key_directory() {
|
fn can_initiate_key_directory() {
|
||||||
|
@ -70,7 +70,7 @@ impl SecretStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn new_test(path: &::tests::helpers::RandomTempPath) -> SecretStore {
|
fn new_test(path: &::devtools::RandomTempPath) -> SecretStore {
|
||||||
SecretStore {
|
SecretStore {
|
||||||
directory: KeyDirectory::new(path.as_path())
|
directory: KeyDirectory::new(path.as_path())
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ mod vector_tests {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use tests::helpers::*;
|
use devtools::*;
|
||||||
use common::*;
|
use common::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -106,6 +106,7 @@ extern crate serde;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log as rlog;
|
extern crate log as rlog;
|
||||||
extern crate igd;
|
extern crate igd;
|
||||||
|
extern crate ethcore_devtools as devtools;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
pub mod standard;
|
pub mod standard;
|
||||||
@ -161,5 +162,3 @@ pub use network::*;
|
|||||||
pub use io::*;
|
pub use io::*;
|
||||||
pub use log::*;
|
pub use log::*;
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests;
|
|
||||||
|
@ -987,7 +987,7 @@ fn load_key(path: &Path) -> Option<Secret> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn key_save_load() {
|
fn key_save_load() {
|
||||||
use tests::helpers::RandomTempPath;
|
use ::devtools::RandomTempPath;
|
||||||
let temp_path = RandomTempPath::create_dir();
|
let temp_path = RandomTempPath::create_dir();
|
||||||
let key = H256::random();
|
let key = H256::random();
|
||||||
save_key(temp_path.as_path(), &key);
|
save_key(temp_path.as_path(), &key);
|
||||||
|
@ -344,7 +344,7 @@ mod tests {
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::net::*;
|
use std::net::*;
|
||||||
use hash::*;
|
use hash::*;
|
||||||
use tests::helpers::*;
|
use devtools::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn endpoint_parse() {
|
fn endpoint_parse() {
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
use std::any::Any;
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
/// Thread-safe closure for handling possible panics
|
/// Thread-safe closure for handling possible panics
|
||||||
@ -73,9 +72,8 @@ impl PanicHandler {
|
|||||||
/// Invoke closure and catch any possible panics.
|
/// Invoke closure and catch any possible panics.
|
||||||
/// In case of panic notifies all listeners about it.
|
/// In case of panic notifies all listeners about it.
|
||||||
#[cfg_attr(feature="dev", allow(deprecated))]
|
#[cfg_attr(feature="dev", allow(deprecated))]
|
||||||
// TODO [todr] catch_panic is deprecated but panic::recover has different bounds (not allowing mutex)
|
|
||||||
pub fn catch_panic<G, R>(&self, g: G) -> thread::Result<R> where G: FnOnce() -> R + Send + 'static {
|
pub fn catch_panic<G, R>(&self, g: G) -> thread::Result<R> where G: FnOnce() -> R + Send + 'static {
|
||||||
let guard = PanicGuard { handler: self };
|
let _guard = PanicGuard { handler: self };
|
||||||
let result = g();
|
let result = g();
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
@ -108,13 +106,6 @@ impl<F> OnPanicListener for F
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_to_string(t: &Box<Any + Send>) -> Option<String> {
|
|
||||||
let as_str = t.downcast_ref::<&'static str>().cloned().map(|t| t.to_owned());
|
|
||||||
let as_string = t.downcast_ref::<String>().cloned();
|
|
||||||
|
|
||||||
as_str.or(as_string)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore] // panic forwarding doesnt work on the same thread in beta
|
#[ignore] // panic forwarding doesnt work on the same thread in beta
|
||||||
fn should_notify_listeners_about_panic () {
|
fn should_notify_listeners_about_panic () {
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
use common::*;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::fs::{remove_dir_all};
|
|
||||||
use std::env;
|
|
||||||
|
|
||||||
pub struct RandomTempPath {
|
|
||||||
path: PathBuf
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RandomTempPath {
|
|
||||||
pub fn create_dir() -> RandomTempPath {
|
|
||||||
let mut dir = env::temp_dir();
|
|
||||||
dir.push(H32::random().hex());
|
|
||||||
fs::create_dir_all(dir.as_path()).unwrap();
|
|
||||||
RandomTempPath {
|
|
||||||
path: dir.clone()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn as_path(&self) -> &PathBuf {
|
|
||||||
&self.path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
pub mod helpers;
|
|
@ -991,7 +991,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[allow(eq_op)]
|
#[cfg_attr(feature="dev", allow(eq_op))]
|
||||||
pub fn uint256_comp_test() {
|
pub fn uint256_comp_test() {
|
||||||
let small = U256([10u64, 0, 0, 0]);
|
let small = U256([10u64, 0, 0, 0]);
|
||||||
let big = U256([0x8C8C3EE70C644118u64, 0x0209E7378231E632, 0, 0]);
|
let big = U256([0x8C8C3EE70C644118u64, 0x0209E7378231E632, 0, 0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user