replace tempdir by tempfile (#2143)
## Issue Addressed Fixes #2141 Remove [tempdir](https://docs.rs/tempdir/0.3.7/tempdir/) in favor of [tempfile](https://docs.rs/tempfile/3.1.0/tempfile/). ## Proposed Changes `tempfile` has a slightly different api that makes creating temp folders with a name prefix a chore (`tempdir::TempDir::new("toto")` => `tempfile::Builder::new().prefix("toto").tempdir()`). So I removed temp folder name prefix where I deemed it not useful. Otherwise, the functionality is the same.
This commit is contained in:
parent
7e4b190df0
commit
851a4dca3c
38
Cargo.lock
generated
38
Cargo.lock
generated
@ -2011,7 +2011,7 @@ dependencies = [
|
|||||||
"smallvec",
|
"smallvec",
|
||||||
"snap",
|
"snap",
|
||||||
"task_executor",
|
"task_executor",
|
||||||
"tempdir",
|
"tempfile",
|
||||||
"tiny-keccak 2.0.2",
|
"tiny-keccak 2.0.2",
|
||||||
"tokio 0.3.6",
|
"tokio 0.3.6",
|
||||||
"tokio-io-timeout",
|
"tokio-io-timeout",
|
||||||
@ -2030,7 +2030,7 @@ dependencies = [
|
|||||||
"eth2_ssz",
|
"eth2_ssz",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
"tempdir",
|
"tempfile",
|
||||||
"types",
|
"types",
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
@ -3800,7 +3800,7 @@ name = "lockfile"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fs2",
|
"fs2",
|
||||||
"tempdir",
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -4261,7 +4261,7 @@ dependencies = [
|
|||||||
"genesis",
|
"genesis",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"tempdir",
|
"tempfile",
|
||||||
"types",
|
"types",
|
||||||
"url",
|
"url",
|
||||||
"validator_client",
|
"validator_client",
|
||||||
@ -4994,19 +4994,6 @@ version = "0.5.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8"
|
checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand"
|
|
||||||
version = "0.4.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
|
|
||||||
dependencies = [
|
|
||||||
"fuchsia-cprng",
|
|
||||||
"libc",
|
|
||||||
"rand_core 0.3.1",
|
|
||||||
"rdrand",
|
|
||||||
"winapi 0.3.9",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand"
|
name = "rand"
|
||||||
version = "0.6.5"
|
version = "0.6.5"
|
||||||
@ -5269,7 +5256,7 @@ dependencies = [
|
|||||||
"remote_signer_test",
|
"remote_signer_test",
|
||||||
"slog",
|
"slog",
|
||||||
"sloggers",
|
"sloggers",
|
||||||
"tempdir",
|
"tempfile",
|
||||||
"types",
|
"types",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
@ -5317,7 +5304,7 @@ dependencies = [
|
|||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tempdir",
|
"tempfile",
|
||||||
"tokio 0.3.6",
|
"tokio 0.3.6",
|
||||||
"tokio-compat-02",
|
"tokio-compat-02",
|
||||||
"types",
|
"types",
|
||||||
@ -5897,7 +5884,7 @@ dependencies = [
|
|||||||
"serde_derive",
|
"serde_derive",
|
||||||
"slog",
|
"slog",
|
||||||
"sloggers",
|
"sloggers",
|
||||||
"tempdir",
|
"tempfile",
|
||||||
"tree_hash",
|
"tree_hash",
|
||||||
"tree_hash_derive",
|
"tree_hash_derive",
|
||||||
"types",
|
"types",
|
||||||
@ -6354,16 +6341,6 @@ dependencies = [
|
|||||||
"tokio-compat-02",
|
"tokio-compat-02",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tempdir"
|
|
||||||
version = "0.3.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
|
|
||||||
dependencies = [
|
|
||||||
"rand 0.4.6",
|
|
||||||
"remove_dir_all",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempfile"
|
name = "tempfile"
|
||||||
version = "3.1.0"
|
version = "3.1.0"
|
||||||
@ -7155,7 +7132,6 @@ dependencies = [
|
|||||||
"slog-async",
|
"slog-async",
|
||||||
"slog-term",
|
"slog-term",
|
||||||
"slot_clock",
|
"slot_clock",
|
||||||
"tempdir",
|
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tokio 0.3.6",
|
"tokio 0.3.6",
|
||||||
"tokio-compat-02",
|
"tokio-compat-02",
|
||||||
|
@ -24,7 +24,7 @@ fnv = "1.0.7"
|
|||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
lighthouse_metrics = { path = "../../common/lighthouse_metrics" }
|
lighthouse_metrics = { path = "../../common/lighthouse_metrics" }
|
||||||
smallvec = "1.4.2"
|
smallvec = "1.4.2"
|
||||||
tokio-io-timeout = "0.5.0"
|
tokio-io-timeout = "0.5.0"
|
||||||
lru = "0.6.0"
|
lru = "0.6.0"
|
||||||
parking_lot = "0.11.0"
|
parking_lot = "0.11.0"
|
||||||
sha2 = "0.9.1"
|
sha2 = "0.9.1"
|
||||||
@ -50,7 +50,7 @@ features = ["websocket", "identify", "mplex", "yamux", "noise", "gossipsub", "dn
|
|||||||
tokio = { version = "0.3.2", features = ["full"] }
|
tokio = { version = "0.3.2", features = ["full"] }
|
||||||
slog-term = "2.6.0"
|
slog-term = "2.6.0"
|
||||||
slog-async = "2.5.0"
|
slog-async = "2.5.0"
|
||||||
tempdir = "0.3.7"
|
tempfile = "3.1.0"
|
||||||
exit-future = "0.2.0"
|
exit-future = "0.2.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -13,7 +13,7 @@ use tokio::runtime::Runtime;
|
|||||||
use types::{ChainSpec, EnrForkId, MinimalEthSpec};
|
use types::{ChainSpec, EnrForkId, MinimalEthSpec};
|
||||||
|
|
||||||
type E = MinimalEthSpec;
|
type E = MinimalEthSpec;
|
||||||
use tempdir::TempDir;
|
use tempfile::Builder as TempBuilder;
|
||||||
|
|
||||||
pub struct Libp2pInstance(LibP2PService<E>, exit_future::Signal);
|
pub struct Libp2pInstance(LibP2PService<E>, exit_future::Signal);
|
||||||
|
|
||||||
@ -76,7 +76,10 @@ pub fn unused_port(transport: &str) -> Result<u16, String> {
|
|||||||
|
|
||||||
pub fn build_config(port: u16, mut boot_nodes: Vec<Enr>) -> NetworkConfig {
|
pub fn build_config(port: u16, mut boot_nodes: Vec<Enr>) -> NetworkConfig {
|
||||||
let mut config = NetworkConfig::default();
|
let mut config = NetworkConfig::default();
|
||||||
let path = TempDir::new(&format!("libp2p_test{}", port)).unwrap();
|
let path = TempBuilder::new()
|
||||||
|
.prefix(&format!("libp2p_test{}", port))
|
||||||
|
.tempdir()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
config.libp2p_port = port; // tcp port
|
config.libp2p_port = port; // tcp port
|
||||||
config.discovery_port = port; // udp port
|
config.discovery_port = port; // udp port
|
||||||
|
@ -11,7 +11,7 @@ zip = "0.5.8"
|
|||||||
eth2_config = { path = "../eth2_config"}
|
eth2_config = { path = "../eth2_config"}
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempdir = "0.3.7"
|
tempfile = "3.1.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = "1.0.116"
|
serde = "1.0.116"
|
||||||
|
@ -239,7 +239,7 @@ impl Eth2NetworkConfig {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use ssz::Encode;
|
use ssz::Encode;
|
||||||
use tempdir::TempDir;
|
use tempfile::Builder as TempBuilder;
|
||||||
use types::{Eth1Data, Hash256, MainnetEthSpec, V012LegacyEthSpec, YamlConfig};
|
use types::{Eth1Data, Hash256, MainnetEthSpec, V012LegacyEthSpec, YamlConfig};
|
||||||
|
|
||||||
type E = V012LegacyEthSpec;
|
type E = V012LegacyEthSpec;
|
||||||
@ -301,7 +301,10 @@ mod tests {
|
|||||||
genesis_state: Option<BeaconState<E>>,
|
genesis_state: Option<BeaconState<E>>,
|
||||||
yaml_config: Option<YamlConfig>,
|
yaml_config: Option<YamlConfig>,
|
||||||
) {
|
) {
|
||||||
let temp_dir = TempDir::new("eth2_testnet_test").expect("should create temp dir");
|
let temp_dir = TempBuilder::new()
|
||||||
|
.prefix("eth2_testnet_test")
|
||||||
|
.tempdir()
|
||||||
|
.expect("should create temp dir");
|
||||||
let base_dir = temp_dir.path().join("my_testnet");
|
let base_dir = temp_dir.path().join("my_testnet");
|
||||||
let deposit_contract_deploy_block = 42;
|
let deposit_contract_deploy_block = 42;
|
||||||
|
|
||||||
|
@ -8,4 +8,4 @@ edition = "2018"
|
|||||||
fs2 = "0.4.3"
|
fs2 = "0.4.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempdir = "0.3.7"
|
tempfile = "3.1.0"
|
||||||
|
@ -72,14 +72,14 @@ impl Drop for Lockfile {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use tempdir::TempDir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::{fs::Permissions, os::unix::fs::PermissionsExt};
|
use std::{fs::Permissions, os::unix::fs::PermissionsExt};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn new_lock() {
|
fn new_lock() {
|
||||||
let temp = TempDir::new("lock_test").unwrap();
|
let temp = tempdir().unwrap();
|
||||||
let path = temp.path().join("lockfile");
|
let path = temp.path().join("lockfile");
|
||||||
|
|
||||||
let _lock = Lockfile::new(path.clone()).unwrap();
|
let _lock = Lockfile::new(path.clone()).unwrap();
|
||||||
@ -91,7 +91,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn relock_after_drop() {
|
fn relock_after_drop() {
|
||||||
let temp = TempDir::new("lock_test").unwrap();
|
let temp = tempdir().unwrap();
|
||||||
let path = temp.path().join("lockfile");
|
let path = temp.path().join("lockfile");
|
||||||
|
|
||||||
let lock1 = Lockfile::new(path.clone()).unwrap();
|
let lock1 = Lockfile::new(path.clone()).unwrap();
|
||||||
@ -105,7 +105,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lockfile_exists() {
|
fn lockfile_exists() {
|
||||||
let temp = TempDir::new("lock_test").unwrap();
|
let temp = tempdir().unwrap();
|
||||||
let path = temp.path().join("lockfile");
|
let path = temp.path().join("lockfile");
|
||||||
|
|
||||||
let _lockfile = File::create(&path).unwrap();
|
let _lockfile = File::create(&path).unwrap();
|
||||||
@ -117,7 +117,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn permission_denied_create() {
|
fn permission_denied_create() {
|
||||||
let temp = TempDir::new("lock_test").unwrap();
|
let temp = tempdir().unwrap();
|
||||||
let path = temp.path().join("lockfile");
|
let path = temp.path().join("lockfile");
|
||||||
|
|
||||||
let lockfile = File::create(&path).unwrap();
|
let lockfile = File::create(&path).unwrap();
|
||||||
|
@ -7,7 +7,7 @@ edition = "2018"
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
helpers = { path = "../../testing/remote_signer_test", package = "remote_signer_test" }
|
helpers = { path = "../../testing/remote_signer_test", package = "remote_signer_test" }
|
||||||
sloggers = "1.0.1"
|
sloggers = "1.0.1"
|
||||||
tempdir = "0.3.7"
|
tempfile = "3.1.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bls = { path = "../../crypto/bls" }
|
bls = { path = "../../crypto/bls" }
|
||||||
|
@ -88,12 +88,12 @@ pub mod tests_commons {
|
|||||||
pub use crate::Storage;
|
pub use crate::Storage;
|
||||||
use helpers::*;
|
use helpers::*;
|
||||||
use sloggers::{null::NullLoggerBuilder, Build};
|
use sloggers::{null::NullLoggerBuilder, Build};
|
||||||
use tempdir::TempDir;
|
use tempfile::{tempdir, TempDir};
|
||||||
|
|
||||||
type T = StorageRawDir;
|
type T = StorageRawDir;
|
||||||
|
|
||||||
pub fn new_storage_with_tmp_dir() -> (T, TempDir) {
|
pub fn new_storage_with_tmp_dir() -> (T, TempDir) {
|
||||||
let tmp_dir = TempDir::new("bls-remote-signer-test").unwrap();
|
let tmp_dir = tempdir().unwrap();
|
||||||
let storage = StorageRawDir::new(tmp_dir.path().to_str().unwrap()).unwrap();
|
let storage = StorageRawDir::new(tmp_dir.path().to_str().unwrap()).unwrap();
|
||||||
(storage, tmp_dir)
|
(storage, tmp_dir)
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ pub mod tests_commons {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_backend_for_get_keys() -> (Backend<T>, TempDir) {
|
pub fn new_backend_for_get_keys() -> (Backend<T>, TempDir) {
|
||||||
let tmp_dir = TempDir::new("bls-remote-signer-test").unwrap();
|
let tmp_dir = tempdir().unwrap();
|
||||||
|
|
||||||
let matches = set_matches(vec![
|
let matches = set_matches(vec![
|
||||||
"this_test",
|
"this_test",
|
||||||
@ -145,7 +145,7 @@ pub mod backend_new {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::tests_commons::*;
|
use crate::tests_commons::*;
|
||||||
use helpers::*;
|
use helpers::*;
|
||||||
use tempdir::TempDir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_storage_type_supplied() {
|
fn no_storage_type_supplied() {
|
||||||
@ -170,7 +170,7 @@ pub mod backend_new {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn given_inaccessible() {
|
fn given_inaccessible() {
|
||||||
let tmp_dir = TempDir::new("bls-remote-signer-test").unwrap();
|
let tmp_dir = tempdir().unwrap();
|
||||||
set_permissions(tmp_dir.path(), 0o40311);
|
set_permissions(tmp_dir.path(), 0o40311);
|
||||||
|
|
||||||
let matches = set_matches(vec![
|
let matches = set_matches(vec![
|
||||||
|
@ -28,7 +28,7 @@ types = { path = "../consensus/types" }
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
maplit = "1.0.2"
|
maplit = "1.0.2"
|
||||||
rayon = "1.3.0"
|
rayon = "1.3.0"
|
||||||
tempdir = "0.3.7"
|
tempfile = "3.1.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test_logger = []
|
test_logger = []
|
||||||
|
@ -6,7 +6,7 @@ use slasher::{
|
|||||||
Config, Slasher,
|
Config, Slasher,
|
||||||
};
|
};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use tempdir::TempDir;
|
use tempfile::tempdir;
|
||||||
use types::{AttesterSlashing, Epoch, IndexedAttestation};
|
use types::{AttesterSlashing, Epoch, IndexedAttestation};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -169,7 +169,7 @@ fn slasher_test(
|
|||||||
current_epoch: u64,
|
current_epoch: u64,
|
||||||
should_process_after: impl Fn(usize) -> bool,
|
should_process_after: impl Fn(usize) -> bool,
|
||||||
) {
|
) {
|
||||||
let tempdir = TempDir::new("slasher").unwrap();
|
let tempdir = tempdir().unwrap();
|
||||||
let config = Config::new(tempdir.path().into());
|
let config = Config::new(tempdir.path().into());
|
||||||
let slasher = Slasher::open(config, logger()).unwrap();
|
let slasher = Slasher::open(config, logger()).unwrap();
|
||||||
let current_epoch = Epoch::new(current_epoch);
|
let current_epoch = Epoch::new(current_epoch);
|
||||||
@ -196,7 +196,7 @@ fn parallel_slasher_test(
|
|||||||
expected_slashed_validators: HashSet<u64>,
|
expected_slashed_validators: HashSet<u64>,
|
||||||
current_epoch: u64,
|
current_epoch: u64,
|
||||||
) {
|
) {
|
||||||
let tempdir = TempDir::new("slasher").unwrap();
|
let tempdir = tempdir().unwrap();
|
||||||
let config = Config::new(tempdir.path().into());
|
let config = Config::new(tempdir.path().into());
|
||||||
let slasher = Slasher::open(config, logger()).unwrap();
|
let slasher = Slasher::open(config, logger()).unwrap();
|
||||||
let current_epoch = Epoch::new(current_epoch);
|
let current_epoch = Epoch::new(current_epoch);
|
||||||
|
@ -2,12 +2,12 @@ use slasher::{
|
|||||||
test_utils::{block as test_block, logger, E},
|
test_utils::{block as test_block, logger, E},
|
||||||
Config, Slasher,
|
Config, Slasher,
|
||||||
};
|
};
|
||||||
use tempdir::TempDir;
|
use tempfile::tempdir;
|
||||||
use types::{Epoch, EthSpec};
|
use types::{Epoch, EthSpec};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_pruning() {
|
fn empty_pruning() {
|
||||||
let tempdir = TempDir::new("slasher").unwrap();
|
let tempdir = tempdir().unwrap();
|
||||||
let config = Config::new(tempdir.path().into());
|
let config = Config::new(tempdir.path().into());
|
||||||
let slasher = Slasher::<E>::open(config.clone(), logger()).unwrap();
|
let slasher = Slasher::<E>::open(config.clone(), logger()).unwrap();
|
||||||
slasher.prune_database(Epoch::new(0)).unwrap();
|
slasher.prune_database(Epoch::new(0)).unwrap();
|
||||||
@ -17,7 +17,7 @@ fn empty_pruning() {
|
|||||||
fn block_pruning() {
|
fn block_pruning() {
|
||||||
let slots_per_epoch = E::slots_per_epoch();
|
let slots_per_epoch = E::slots_per_epoch();
|
||||||
|
|
||||||
let tempdir = TempDir::new("slasher").unwrap();
|
let tempdir = tempdir().unwrap();
|
||||||
let mut config = Config::new(tempdir.path().into());
|
let mut config = Config::new(tempdir.path().into());
|
||||||
config.chunk_size = 2;
|
config.chunk_size = 2;
|
||||||
config.history_length = 2;
|
config.history_length = 2;
|
||||||
|
@ -8,7 +8,7 @@ use slasher::{
|
|||||||
Config, Slasher,
|
Config, Slasher,
|
||||||
};
|
};
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use tempdir::TempDir;
|
use tempfile::tempdir;
|
||||||
use types::{Epoch, EthSpec};
|
use types::{Epoch, EthSpec};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -38,7 +38,7 @@ fn random_test(seed: u64, test_config: TestConfig) {
|
|||||||
println!("Running with seed {}", seed);
|
println!("Running with seed {}", seed);
|
||||||
let mut rng = StdRng::seed_from_u64(seed);
|
let mut rng = StdRng::seed_from_u64(seed);
|
||||||
|
|
||||||
let tempdir = TempDir::new("slasher").unwrap();
|
let tempdir = tempdir().unwrap();
|
||||||
|
|
||||||
let mut config = Config::new(tempdir.path().into());
|
let mut config = Config::new(tempdir.path().into());
|
||||||
config.validator_chunk_size = 1 << rng.gen_range(1, 4);
|
config.validator_chunk_size = 1 << rng.gen_range(1, 4);
|
||||||
|
@ -2,12 +2,12 @@ use slasher::{
|
|||||||
test_utils::{indexed_att, logger},
|
test_utils::{indexed_att, logger},
|
||||||
Config, Error, Slasher,
|
Config, Error, Slasher,
|
||||||
};
|
};
|
||||||
use tempdir::TempDir;
|
use tempfile::tempdir;
|
||||||
use types::Epoch;
|
use types::Epoch;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn attestation_pruning_empty_wrap_around() {
|
fn attestation_pruning_empty_wrap_around() {
|
||||||
let tempdir = TempDir::new("slasher").unwrap();
|
let tempdir = tempdir().unwrap();
|
||||||
let mut config = Config::new(tempdir.path().into());
|
let mut config = Config::new(tempdir.path().into());
|
||||||
config.validator_chunk_size = 1;
|
config.validator_chunk_size = 1;
|
||||||
config.chunk_size = 16;
|
config.chunk_size = 16;
|
||||||
@ -41,7 +41,7 @@ fn attestation_pruning_empty_wrap_around() {
|
|||||||
// Test that pruning can recover from a `MapFull` error
|
// Test that pruning can recover from a `MapFull` error
|
||||||
#[test]
|
#[test]
|
||||||
fn pruning_with_map_full() {
|
fn pruning_with_map_full() {
|
||||||
let tempdir = TempDir::new("slasher").unwrap();
|
let tempdir = tempdir().unwrap();
|
||||||
let mut config = Config::new(tempdir.path().into());
|
let mut config = Config::new(tempdir.path().into());
|
||||||
config.validator_chunk_size = 1;
|
config.validator_chunk_size = 1;
|
||||||
config.chunk_size = 16;
|
config.chunk_size = 16;
|
||||||
|
@ -9,7 +9,7 @@ environment = { path = "../../lighthouse/environment" }
|
|||||||
beacon_node = { path = "../../beacon_node" }
|
beacon_node = { path = "../../beacon_node" }
|
||||||
types = { path = "../../consensus/types" }
|
types = { path = "../../consensus/types" }
|
||||||
eth2_config = { path = "../../common/eth2_config" }
|
eth2_config = { path = "../../common/eth2_config" }
|
||||||
tempdir = "0.3.7"
|
tempfile = "3.1.0"
|
||||||
reqwest = { version = "0.10.8", features = ["native-tls-vendored"] }
|
reqwest = { version = "0.10.8", features = ["native-tls-vendored"] }
|
||||||
url = "2.1.1"
|
url = "2.1.1"
|
||||||
serde = "1.0.116"
|
serde = "1.0.116"
|
||||||
|
@ -11,7 +11,7 @@ use eth2::{
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
use tempdir::TempDir;
|
use tempfile::{Builder as TempBuilder, TempDir};
|
||||||
use types::EthSpec;
|
use types::EthSpec;
|
||||||
use validator_client::ProductionValidatorClient;
|
use validator_client::ProductionValidatorClient;
|
||||||
use validator_dir::insecure_keys::build_deterministic_validator_dirs;
|
use validator_dir::insecure_keys::build_deterministic_validator_dirs;
|
||||||
@ -42,7 +42,9 @@ impl<E: EthSpec> LocalBeaconNode<E> {
|
|||||||
mut client_config: ClientConfig,
|
mut client_config: ClientConfig,
|
||||||
) -> Result<Self, String> {
|
) -> Result<Self, String> {
|
||||||
// Creates a temporary directory that will be deleted once this `TempDir` is dropped.
|
// Creates a temporary directory that will be deleted once this `TempDir` is dropped.
|
||||||
let datadir = TempDir::new("lighthouse_node_test_rig")
|
let datadir = TempBuilder::new()
|
||||||
|
.prefix("lighthouse_node_test_rig")
|
||||||
|
.tempdir()
|
||||||
.expect("should create temp directory for client datadir");
|
.expect("should create temp directory for client datadir");
|
||||||
|
|
||||||
client_config.data_dir = datadir.path().into();
|
client_config.data_dir = datadir.path().into();
|
||||||
@ -125,10 +127,14 @@ pub struct ValidatorFiles {
|
|||||||
impl ValidatorFiles {
|
impl ValidatorFiles {
|
||||||
/// Creates temporary data and secrets dirs.
|
/// Creates temporary data and secrets dirs.
|
||||||
pub fn new() -> Result<Self, String> {
|
pub fn new() -> Result<Self, String> {
|
||||||
let datadir = TempDir::new("lighthouse-validator-client")
|
let datadir = TempBuilder::new()
|
||||||
|
.prefix("lighthouse-validator-client")
|
||||||
|
.tempdir()
|
||||||
.map_err(|e| format!("Unable to create VC data dir: {:?}", e))?;
|
.map_err(|e| format!("Unable to create VC data dir: {:?}", e))?;
|
||||||
|
|
||||||
let secrets_dir = TempDir::new("lighthouse-validator-client-secrets")
|
let secrets_dir = TempBuilder::new()
|
||||||
|
.prefix("lighthouse-validator-client-secrets")
|
||||||
|
.tempdir()
|
||||||
.map_err(|e| format!("Unable to create VC secrets dir: {:?}", e))?;
|
.map_err(|e| format!("Unable to create VC secrets dir: {:?}", e))?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
@ -14,7 +14,7 @@ remote_signer_consumer = { path = "../../common/remote_signer_consumer" }
|
|||||||
reqwest = { version = "0.10.8", features = ["blocking", "json"] }
|
reqwest = { version = "0.10.8", features = ["blocking", "json"] }
|
||||||
serde = { version = "1.0.116", features = ["derive"] }
|
serde = { version = "1.0.116", features = ["derive"] }
|
||||||
serde_json = "1.0.58"
|
serde_json = "1.0.58"
|
||||||
tempdir = "0.3.7"
|
tempfile = "3.1.0"
|
||||||
tokio = { version = "0.3.5", features = ["time"] }
|
tokio = { version = "0.3.5", features = ["time"] }
|
||||||
types = { path = "../../consensus/types" }
|
types = { path = "../../consensus/types" }
|
||||||
tokio-compat-02 = "0.1"
|
tokio-compat-02 = "0.1"
|
||||||
|
@ -5,7 +5,7 @@ pub use local_signer_test_data::*;
|
|||||||
use remote_signer_client::Client;
|
use remote_signer_client::Client;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use tempdir::TempDir;
|
use tempfile::{Builder as TempBuilder, TempDir};
|
||||||
use types::EthSpec;
|
use types::EthSpec;
|
||||||
|
|
||||||
pub struct ApiTestSigner<E: EthSpec> {
|
pub struct ApiTestSigner<E: EthSpec> {
|
||||||
@ -81,7 +81,10 @@ pub fn get_environment(is_log_active: bool) -> Environment<E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_up_api_test_signer_raw_dir() -> (ApiTestSigner<E>, TempDir) {
|
pub fn set_up_api_test_signer_raw_dir() -> (ApiTestSigner<E>, TempDir) {
|
||||||
let tmp_dir = TempDir::new("bls-remote-signer-test").unwrap();
|
let tmp_dir = TempBuilder::new()
|
||||||
|
.prefix("bls-remote-signer-test")
|
||||||
|
.tempdir()
|
||||||
|
.unwrap();
|
||||||
let arg_vec = vec![
|
let arg_vec = vec![
|
||||||
"this_test",
|
"this_test",
|
||||||
"--port",
|
"--port",
|
||||||
|
@ -11,7 +11,7 @@ use std::io::Write;
|
|||||||
use std::net::IpAddr::{V4, V6};
|
use std::net::IpAddr::{V4, V6};
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use tempdir::TempDir;
|
use tempfile::TempDir;
|
||||||
use types::{
|
use types::{
|
||||||
AggregateSignature, Attestation, AttestationData, AttesterSlashing, BeaconBlock,
|
AggregateSignature, Attestation, AttestationData, AttesterSlashing, BeaconBlock,
|
||||||
BeaconBlockHeader, BitList, Checkpoint, Deposit, DepositData, Epoch, EthSpec, FixedVector,
|
BeaconBlockHeader, BitList, Checkpoint, Deposit, DepositData, Epoch, EthSpec, FixedVector,
|
||||||
|
@ -10,7 +10,6 @@ path = "src/lib.rs"
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "0.3.2", features = ["time", "rt-multi-thread", "macros"] }
|
tokio = { version = "0.3.2", features = ["time", "rt-multi-thread", "macros"] }
|
||||||
tempfile = "3.1.0"
|
|
||||||
deposit_contract = { path = "../common/deposit_contract" }
|
deposit_contract = { path = "../common/deposit_contract" }
|
||||||
tokio-compat-02 = "0.1"
|
tokio-compat-02 = "0.1"
|
||||||
|
|
||||||
@ -46,7 +45,7 @@ hex = "0.4.2"
|
|||||||
deposit_contract = { path = "../common/deposit_contract" }
|
deposit_contract = { path = "../common/deposit_contract" }
|
||||||
bls = { path = "../crypto/bls" }
|
bls = { path = "../crypto/bls" }
|
||||||
eth2 = { path = "../common/eth2" }
|
eth2 = { path = "../common/eth2" }
|
||||||
tempdir = "0.3.7"
|
tempfile = "3.1.0"
|
||||||
rayon = "1.4.1"
|
rayon = "1.4.1"
|
||||||
validator_dir = { path = "../common/validator_dir" }
|
validator_dir = { path = "../common/validator_dir" }
|
||||||
clap_utils = { path = "../common/clap_utils" }
|
clap_utils = { path = "../common/clap_utils" }
|
||||||
|
@ -8,7 +8,7 @@ use slog::{crit, error, warn, Logger};
|
|||||||
use slot_clock::SlotClock;
|
use slot_clock::SlotClock;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tempdir::TempDir;
|
use tempfile::TempDir;
|
||||||
use types::{
|
use types::{
|
||||||
Attestation, BeaconBlock, ChainSpec, Domain, Epoch, EthSpec, Fork, Hash256, Keypair, PublicKey,
|
Attestation, BeaconBlock, ChainSpec, Domain, Epoch, EthSpec, Fork, Hash256, Keypair, PublicKey,
|
||||||
SelectionProof, Signature, SignedAggregateAndProof, SignedBeaconBlock, SignedRoot, Slot,
|
SelectionProof, Signature, SignedAggregateAndProof, SignedBeaconBlock, SignedRoot, Slot,
|
||||||
|
Loading…
Reference in New Issue
Block a user