mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
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:
@@ -9,7 +9,7 @@ environment = { path = "../../lighthouse/environment" }
|
||||
beacon_node = { path = "../../beacon_node" }
|
||||
types = { path = "../../consensus/types" }
|
||||
eth2_config = { path = "../../common/eth2_config" }
|
||||
tempdir = "0.3.7"
|
||||
tempfile = "3.1.0"
|
||||
reqwest = { version = "0.10.8", features = ["native-tls-vendored"] }
|
||||
url = "2.1.1"
|
||||
serde = "1.0.116"
|
||||
|
||||
@@ -11,7 +11,7 @@ use eth2::{
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use tempdir::TempDir;
|
||||
use tempfile::{Builder as TempBuilder, TempDir};
|
||||
use types::EthSpec;
|
||||
use validator_client::ProductionValidatorClient;
|
||||
use validator_dir::insecure_keys::build_deterministic_validator_dirs;
|
||||
@@ -42,7 +42,9 @@ impl<E: EthSpec> LocalBeaconNode<E> {
|
||||
mut client_config: ClientConfig,
|
||||
) -> Result<Self, String> {
|
||||
// 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");
|
||||
|
||||
client_config.data_dir = datadir.path().into();
|
||||
@@ -125,10 +127,14 @@ pub struct ValidatorFiles {
|
||||
impl ValidatorFiles {
|
||||
/// Creates temporary data and secrets dirs.
|
||||
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))?;
|
||||
|
||||
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))?;
|
||||
|
||||
Ok(Self {
|
||||
|
||||
@@ -14,7 +14,7 @@ remote_signer_consumer = { path = "../../common/remote_signer_consumer" }
|
||||
reqwest = { version = "0.10.8", features = ["blocking", "json"] }
|
||||
serde = { version = "1.0.116", features = ["derive"] }
|
||||
serde_json = "1.0.58"
|
||||
tempdir = "0.3.7"
|
||||
tempfile = "3.1.0"
|
||||
tokio = { version = "0.3.5", features = ["time"] }
|
||||
types = { path = "../../consensus/types" }
|
||||
tokio-compat-02 = "0.1"
|
||||
|
||||
@@ -5,7 +5,7 @@ pub use local_signer_test_data::*;
|
||||
use remote_signer_client::Client;
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::{Builder as TempBuilder, TempDir};
|
||||
use types::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) {
|
||||
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![
|
||||
"this_test",
|
||||
"--port",
|
||||
|
||||
@@ -11,7 +11,7 @@ use std::io::Write;
|
||||
use std::net::IpAddr::{V4, V6};
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::path::Path;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::TempDir;
|
||||
use types::{
|
||||
AggregateSignature, Attestation, AttestationData, AttesterSlashing, BeaconBlock,
|
||||
BeaconBlockHeader, BitList, Checkpoint, Deposit, DepositData, Epoch, EthSpec, FixedVector,
|
||||
|
||||
Reference in New Issue
Block a user