util crates use tempdir crate instead of devtools to create temp path (#6807)
* use tempdir instead of devtools in kvdb-rocksdb * use tempdir instead of devtools in migration * use tempdir instead of devtools in ethcore-network * fixed wrong merge
This commit is contained in:
parent
7b14907f7f
commit
9228ce4bae
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -701,6 +701,7 @@ dependencies = [
|
|||||||
"serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"slab 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"slab 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"snappy 0.1.0",
|
"snappy 0.1.0",
|
||||||
|
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@ -769,7 +770,6 @@ dependencies = [
|
|||||||
"eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)",
|
"eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)",
|
||||||
"ethcore-bigint 0.1.3",
|
"ethcore-bigint 0.1.3",
|
||||||
"ethcore-bytes 0.1.0",
|
"ethcore-bytes 0.1.0",
|
||||||
"ethcore-devtools 1.9.0",
|
|
||||||
"ethcore-logger 1.9.0",
|
"ethcore-logger 1.9.0",
|
||||||
"hash 0.1.0",
|
"hash 0.1.0",
|
||||||
"hashdb 0.1.0",
|
"hashdb 0.1.0",
|
||||||
@ -1402,13 +1402,13 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ethcore-bigint 0.1.3",
|
"ethcore-bigint 0.1.3",
|
||||||
"ethcore-devtools 1.9.0",
|
|
||||||
"kvdb 0.1.0",
|
"kvdb 0.1.0",
|
||||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rlp 0.2.0",
|
"rlp 0.2.0",
|
||||||
"rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)",
|
"rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)",
|
||||||
|
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1563,11 +1563,11 @@ name = "migration"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ethcore-devtools 1.9.0",
|
|
||||||
"kvdb 0.1.0",
|
"kvdb 0.1.0",
|
||||||
"kvdb-rocksdb 0.1.0",
|
"kvdb-rocksdb 0.1.0",
|
||||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"macros 0.1.0",
|
"macros 0.1.0",
|
||||||
|
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -18,7 +18,6 @@ rlp = { path = "rlp" }
|
|||||||
heapsize = "0.4"
|
heapsize = "0.4"
|
||||||
hash = { path = "hash" }
|
hash = { path = "hash" }
|
||||||
clippy = { version = "0.0.103", optional = true}
|
clippy = { version = "0.0.103", optional = true}
|
||||||
ethcore-devtools = { path = "../devtools" }
|
|
||||||
libc = "0.2.7"
|
libc = "0.2.7"
|
||||||
target_info = "0.1"
|
target_info = "0.1"
|
||||||
ethcore-bigint = { path = "bigint", features = ["heapsizeof"] }
|
ethcore-bigint = { path = "bigint", features = ["heapsizeof"] }
|
||||||
|
@ -4,12 +4,14 @@ version = "0.1.0"
|
|||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.3"
|
|
||||||
elastic-array = "0.9"
|
elastic-array = "0.9"
|
||||||
ethcore-bigint = { path = "../bigint" }
|
ethcore-bigint = { path = "../bigint" }
|
||||||
ethcore-devtools = { path = "../../devtools" }
|
kvdb = { path = "../kvdb" }
|
||||||
|
log = "0.3"
|
||||||
parking_lot = "0.4"
|
parking_lot = "0.4"
|
||||||
regex = "0.2"
|
regex = "0.2"
|
||||||
rlp = { path = "../rlp" }
|
rlp = { path = "../rlp" }
|
||||||
rocksdb = { git = "https://github.com/paritytech/rust-rocksdb" }
|
rocksdb = { git = "https://github.com/paritytech/rust-rocksdb" }
|
||||||
kvdb = { path = "../kvdb" }
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempdir = "0.3"
|
||||||
|
@ -23,7 +23,6 @@ extern crate regex;
|
|||||||
extern crate rocksdb;
|
extern crate rocksdb;
|
||||||
|
|
||||||
extern crate ethcore_bigint as bigint;
|
extern crate ethcore_bigint as bigint;
|
||||||
extern crate ethcore_devtools as devtools;
|
|
||||||
extern crate kvdb;
|
extern crate kvdb;
|
||||||
extern crate rlp;
|
extern crate rlp;
|
||||||
|
|
||||||
@ -679,14 +678,16 @@ impl Drop for Database {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
extern crate tempdir;
|
||||||
|
|
||||||
|
use std::str::FromStr;
|
||||||
|
use self::tempdir::TempDir;
|
||||||
use bigint::hash::H256;
|
use bigint::hash::H256;
|
||||||
use super::*;
|
use super::*;
|
||||||
use devtools::*;
|
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
fn test_db(config: &DatabaseConfig) {
|
fn test_db(config: &DatabaseConfig) {
|
||||||
let path = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
let db = Database::open(config, path.as_path().to_str().unwrap()).unwrap();
|
let db = Database::open(config, tempdir.path().to_str().unwrap()).unwrap();
|
||||||
let key1 = H256::from_str("02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc").unwrap();
|
let key1 = H256::from_str("02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc").unwrap();
|
||||||
let key2 = H256::from_str("03c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc").unwrap();
|
let key2 = H256::from_str("03c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc").unwrap();
|
||||||
let key3 = H256::from_str("01c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc").unwrap();
|
let key3 = H256::from_str("01c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc").unwrap();
|
||||||
@ -739,8 +740,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn kvdb() {
|
fn kvdb() {
|
||||||
let path = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
let _ = Database::open_default(path.as_path().to_str().unwrap()).unwrap();
|
let _ = Database::open_default(tempdir.path().to_str().unwrap()).unwrap();
|
||||||
test_db(&DatabaseConfig::default());
|
test_db(&DatabaseConfig::default());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,11 +760,11 @@ mod tests {
|
|||||||
let config = DatabaseConfig::default();
|
let config = DatabaseConfig::default();
|
||||||
let config_5 = DatabaseConfig::with_columns(Some(5));
|
let config_5 = DatabaseConfig::with_columns(Some(5));
|
||||||
|
|
||||||
let path = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
|
|
||||||
// open empty, add 5.
|
// open empty, add 5.
|
||||||
{
|
{
|
||||||
let db = Database::open(&config, path.as_path().to_str().unwrap()).unwrap();
|
let db = Database::open(&config, tempdir.path().to_str().unwrap()).unwrap();
|
||||||
assert_eq!(db.num_columns(), 0);
|
assert_eq!(db.num_columns(), 0);
|
||||||
|
|
||||||
for i in 0..5 {
|
for i in 0..5 {
|
||||||
@ -774,7 +775,7 @@ mod tests {
|
|||||||
|
|
||||||
// reopen as 5.
|
// reopen as 5.
|
||||||
{
|
{
|
||||||
let db = Database::open(&config_5, path.as_path().to_str().unwrap()).unwrap();
|
let db = Database::open(&config_5, tempdir.path().to_str().unwrap()).unwrap();
|
||||||
assert_eq!(db.num_columns(), 5);
|
assert_eq!(db.num_columns(), 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -784,11 +785,11 @@ mod tests {
|
|||||||
let config = DatabaseConfig::default();
|
let config = DatabaseConfig::default();
|
||||||
let config_5 = DatabaseConfig::with_columns(Some(5));
|
let config_5 = DatabaseConfig::with_columns(Some(5));
|
||||||
|
|
||||||
let path = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
|
|
||||||
// open 5, remove all.
|
// open 5, remove all.
|
||||||
{
|
{
|
||||||
let db = Database::open(&config_5, path.as_path().to_str().unwrap()).unwrap();
|
let db = Database::open(&config_5, tempdir.path().to_str().unwrap()).unwrap();
|
||||||
assert_eq!(db.num_columns(), 5);
|
assert_eq!(db.num_columns(), 5);
|
||||||
|
|
||||||
for i in (0..5).rev() {
|
for i in (0..5).rev() {
|
||||||
@ -799,7 +800,7 @@ mod tests {
|
|||||||
|
|
||||||
// reopen as 0.
|
// reopen as 0.
|
||||||
{
|
{
|
||||||
let db = Database::open(&config, path.as_path().to_str().unwrap()).unwrap();
|
let db = Database::open(&config, tempdir.path().to_str().unwrap()).unwrap();
|
||||||
assert_eq!(db.num_columns(), 0);
|
assert_eq!(db.num_columns(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,7 @@ log = "0.3"
|
|||||||
macros = { path = "../macros" }
|
macros = { path = "../macros" }
|
||||||
kvdb = { path = "../kvdb" }
|
kvdb = { path = "../kvdb" }
|
||||||
kvdb-rocksdb = { path = "../kvdb-rocksdb" }
|
kvdb-rocksdb = { path = "../kvdb-rocksdb" }
|
||||||
ethcore-devtools = { path = "../../devtools" }
|
|
||||||
error-chain = "0.11.0"
|
error-chain = "0.11.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempdir = "0.3"
|
||||||
|
@ -25,7 +25,6 @@ extern crate macros;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate error_chain;
|
extern crate error_chain;
|
||||||
|
|
||||||
extern crate ethcore_devtools as devtools;
|
|
||||||
extern crate kvdb;
|
extern crate kvdb;
|
||||||
extern crate kvdb_rocksdb;
|
extern crate kvdb_rocksdb;
|
||||||
|
|
||||||
@ -38,10 +37,6 @@ use kvdb::DBTransaction;
|
|||||||
use kvdb_rocksdb::{CompactionProfile, Database, DatabaseConfig};
|
use kvdb_rocksdb::{CompactionProfile, Database, DatabaseConfig};
|
||||||
|
|
||||||
error_chain! {
|
error_chain! {
|
||||||
types {
|
|
||||||
Error, ErrorKind, ResultExt, Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
links {
|
links {
|
||||||
Db(kvdb::Error, kvdb::ErrorKind);
|
Db(kvdb::Error, kvdb::ErrorKind);
|
||||||
}
|
}
|
||||||
|
@ -18,17 +18,18 @@
|
|||||||
//! A random temp directory is created. A database is created within it, and migrations
|
//! A random temp directory is created. A database is created within it, and migrations
|
||||||
//! are performed in temp sub-directories.
|
//! are performed in temp sub-directories.
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
extern crate tempdir;
|
||||||
use std::sync::Arc;
|
|
||||||
use std::path::{Path, PathBuf};
|
|
||||||
use {Batch, Config, Error, SimpleMigration, Migration, Manager, ChangeColumns};
|
|
||||||
use kvdb_rocksdb::Database;
|
|
||||||
use devtools::RandomTempPath;
|
|
||||||
|
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::sync::Arc;
|
||||||
|
use self::tempdir::TempDir;
|
||||||
|
use kvdb_rocksdb::Database;
|
||||||
|
use {Batch, Config, Error, SimpleMigration, Migration, Manager, ChangeColumns};
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn db_path(path: &Path) -> PathBuf {
|
fn db_path(path: &Path) -> PathBuf {
|
||||||
let mut p = path.to_owned();
|
path.join("db")
|
||||||
p.push("db");
|
|
||||||
p
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize a database at the given directory with the given values.
|
// initialize a database at the given directory with the given values.
|
||||||
@ -109,8 +110,8 @@ impl Migration for AddsColumn {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn one_simple_migration() {
|
fn one_simple_migration() {
|
||||||
let dir = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
let db_path = db_path(dir.as_path());
|
let db_path = db_path(tempdir.path());
|
||||||
let mut manager = Manager::new(Config::default());
|
let mut manager = Manager::new(Config::default());
|
||||||
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
||||||
let expected = map![vec![0x11] => vec![0x22], vec![1, 0x11] => vec![1, 0x22]];
|
let expected = map![vec![0x11] => vec![0x22], vec![1, 0x11] => vec![1, 0x22]];
|
||||||
@ -124,8 +125,8 @@ fn one_simple_migration() {
|
|||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn no_migration_needed() {
|
fn no_migration_needed() {
|
||||||
let dir = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
let db_path = db_path(dir.as_path());
|
let db_path = db_path(tempdir.path());
|
||||||
let mut manager = Manager::new(Config::default());
|
let mut manager = Manager::new(Config::default());
|
||||||
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
||||||
|
|
||||||
@ -136,8 +137,8 @@ fn no_migration_needed() {
|
|||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn wrong_adding_order() {
|
fn wrong_adding_order() {
|
||||||
let dir = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
let db_path = db_path(dir.as_path());
|
let db_path = db_path(tempdir.path());
|
||||||
let mut manager = Manager::new(Config::default());
|
let mut manager = Manager::new(Config::default());
|
||||||
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
||||||
|
|
||||||
@ -147,8 +148,8 @@ fn wrong_adding_order() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn multiple_migrations() {
|
fn multiple_migrations() {
|
||||||
let dir = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
let db_path = db_path(dir.as_path());
|
let db_path = db_path(tempdir.path());
|
||||||
let mut manager = Manager::new(Config::default());
|
let mut manager = Manager::new(Config::default());
|
||||||
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
||||||
let expected = map![vec![0x11] => vec![], vec![1, 0x11] => vec![]];
|
let expected = map![vec![0x11] => vec![], vec![1, 0x11] => vec![]];
|
||||||
@ -162,8 +163,8 @@ fn multiple_migrations() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn second_migration() {
|
fn second_migration() {
|
||||||
let dir = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
let db_path = db_path(dir.as_path());
|
let db_path = db_path(tempdir.path());
|
||||||
let mut manager = Manager::new(Config::default());
|
let mut manager = Manager::new(Config::default());
|
||||||
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
||||||
let expected = map![vec![] => vec![], vec![1] => vec![]];
|
let expected = map![vec![] => vec![], vec![1] => vec![]];
|
||||||
@ -177,8 +178,8 @@ fn second_migration() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn first_and_noop_migration() {
|
fn first_and_noop_migration() {
|
||||||
let dir = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
let db_path = db_path(dir.as_path());
|
let db_path = db_path(tempdir.path());
|
||||||
let mut manager = Manager::new(Config::default());
|
let mut manager = Manager::new(Config::default());
|
||||||
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
||||||
let expected = map![vec![0x11] => vec![0x22], vec![1, 0x11] => vec![1, 0x22]];
|
let expected = map![vec![0x11] => vec![0x22], vec![1, 0x11] => vec![1, 0x22]];
|
||||||
@ -191,8 +192,8 @@ fn first_and_noop_migration() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn noop_and_second_migration() {
|
fn noop_and_second_migration() {
|
||||||
let dir = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
let db_path = db_path(dir.as_path());
|
let db_path = db_path(tempdir.path());
|
||||||
let mut manager = Manager::new(Config::default());
|
let mut manager = Manager::new(Config::default());
|
||||||
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
make_db(&db_path, map![vec![] => vec![], vec![1] => vec![1]]);
|
||||||
let expected = map![vec![] => vec![], vec![1] => vec![]];
|
let expected = map![vec![] => vec![], vec![1] => vec![]];
|
||||||
@ -219,8 +220,8 @@ fn pre_columns() {
|
|||||||
let mut manager = Manager::new(Config::default());
|
let mut manager = Manager::new(Config::default());
|
||||||
manager.add_migration(AddsColumn).unwrap();
|
manager.add_migration(AddsColumn).unwrap();
|
||||||
|
|
||||||
let dir = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
let db_path = db_path(dir.as_path());
|
let db_path = db_path(tempdir.path());
|
||||||
|
|
||||||
// this shouldn't fail to open the database even though it's one column
|
// this shouldn't fail to open the database even though it's one column
|
||||||
// short of the one before it.
|
// short of the one before it.
|
||||||
@ -238,8 +239,8 @@ fn change_columns() {
|
|||||||
version: 1,
|
version: 1,
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
|
|
||||||
let dir = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
let db_path = db_path(dir.as_path());
|
let db_path = db_path(tempdir.path());
|
||||||
|
|
||||||
let new_path = manager.execute(&db_path, 0).unwrap();
|
let new_path = manager.execute(&db_path, 0).unwrap();
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ ethcore-io = { path = "../io" }
|
|||||||
ethcore-util = { path = ".." }
|
ethcore-util = { path = ".." }
|
||||||
ethcore-bigint = { path = "../bigint" }
|
ethcore-bigint = { path = "../bigint" }
|
||||||
ethcore-bytes = { path = "../bytes" }
|
ethcore-bytes = { path = "../bytes" }
|
||||||
ethcore-devtools = { path = "../../devtools" }
|
|
||||||
ethkey = { path = "../../ethkey" }
|
ethkey = { path = "../../ethkey" }
|
||||||
ethcrypto = { path = "../../ethcrypto" }
|
ethcrypto = { path = "../../ethcrypto" }
|
||||||
rlp = { path = "../rlp" }
|
rlp = { path = "../rlp" }
|
||||||
@ -36,6 +35,10 @@ hash = { path = "../hash" }
|
|||||||
snappy = { path = "../snappy" }
|
snappy = { path = "../snappy" }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
ethcore-devtools = { path = "../../devtools" }
|
||||||
|
tempdir = "0.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
dev = ["clippy"]
|
dev = ["clippy"]
|
||||||
|
@ -512,7 +512,7 @@ mod tests {
|
|||||||
use mio::{Ready};
|
use mio::{Ready};
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use ethcore_bytes::Bytes;
|
use ethcore_bytes::Bytes;
|
||||||
use devtools::*;
|
use devtools::TestSocket;
|
||||||
use io::*;
|
use io::*;
|
||||||
|
|
||||||
impl GenericSocket for TestSocket {}
|
impl GenericSocket for TestSocket {}
|
||||||
|
@ -1267,11 +1267,12 @@ fn load_key(path: &Path) -> Option<Secret> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn key_save_load() {
|
fn key_save_load() {
|
||||||
use ::devtools::RandomTempPath;
|
use tempdir::TempDir;
|
||||||
let temp_path = RandomTempPath::create_dir();
|
|
||||||
|
let tempdir = TempDir::new("").unwrap();
|
||||||
let key = H256::random().into();
|
let key = H256::random().into();
|
||||||
save_key(temp_path.as_path(), &key);
|
save_key(tempdir.path(), &key);
|
||||||
let r = load_key(temp_path.as_path());
|
let r = load_key(tempdir.path());
|
||||||
assert_eq!(key, r.unwrap());
|
assert_eq!(key, r.unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +89,9 @@ extern crate log;
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
extern crate ethcore_devtools as devtools;
|
extern crate ethcore_devtools as devtools;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
extern crate tempdir;
|
||||||
|
|
||||||
mod host;
|
mod host;
|
||||||
mod connection;
|
mod connection;
|
||||||
mod handshake;
|
mod handshake;
|
||||||
|
@ -374,7 +374,7 @@ mod tests {
|
|||||||
use std::net::{SocketAddr, SocketAddrV4, Ipv4Addr};
|
use std::net::{SocketAddr, SocketAddrV4, Ipv4Addr};
|
||||||
use bigint::hash::H512;
|
use bigint::hash::H512;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use devtools::*;
|
use tempdir::TempDir;
|
||||||
use ipnetwork::IpNetwork;
|
use ipnetwork::IpNetwork;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -429,20 +429,20 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn table_save_load() {
|
fn table_save_load() {
|
||||||
let temp_path = RandomTempPath::create_dir();
|
let tempdir = TempDir::new("").unwrap();
|
||||||
let node1 = Node::from_str("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@22.99.55.44:7770").unwrap();
|
let node1 = Node::from_str("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@22.99.55.44:7770").unwrap();
|
||||||
let node2 = Node::from_str("enode://b979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@22.99.55.44:7770").unwrap();
|
let node2 = Node::from_str("enode://b979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@22.99.55.44:7770").unwrap();
|
||||||
let id1 = H512::from_str("a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c").unwrap();
|
let id1 = H512::from_str("a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c").unwrap();
|
||||||
let id2 = H512::from_str("b979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c").unwrap();
|
let id2 = H512::from_str("b979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c").unwrap();
|
||||||
{
|
{
|
||||||
let mut table = NodeTable::new(Some(temp_path.as_path().to_str().unwrap().to_owned()));
|
let mut table = NodeTable::new(Some(tempdir.path().to_str().unwrap().to_owned()));
|
||||||
table.add_node(node1);
|
table.add_node(node1);
|
||||||
table.add_node(node2);
|
table.add_node(node2);
|
||||||
table.note_failure(&id2);
|
table.note_failure(&id2);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let table = NodeTable::new(Some(temp_path.as_path().to_str().unwrap().to_owned()));
|
let table = NodeTable::new(Some(tempdir.path().to_str().unwrap().to_owned()));
|
||||||
let r = table.nodes(IpFilter::default());
|
let r = table.nodes(IpFilter::default());
|
||||||
assert_eq!(r[0][..], id1[..]);
|
assert_eq!(r[0][..], id1[..]);
|
||||||
assert_eq!(r[1][..], id2[..]);
|
assert_eq!(r[1][..], id2[..]);
|
||||||
|
@ -92,7 +92,6 @@ extern crate rocksdb;
|
|||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
extern crate secp256k1;
|
extern crate secp256k1;
|
||||||
extern crate elastic_array;
|
extern crate elastic_array;
|
||||||
extern crate ethcore_devtools as devtools;
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
extern crate target_info;
|
extern crate target_info;
|
||||||
extern crate ethcore_bigint as bigint;
|
extern crate ethcore_bigint as bigint;
|
||||||
|
Loading…
Reference in New Issue
Block a user