mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 09:16:00 +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:
@@ -6,7 +6,7 @@ use slasher::{
|
||||
Config, Slasher,
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::tempdir;
|
||||
use types::{AttesterSlashing, Epoch, IndexedAttestation};
|
||||
|
||||
#[test]
|
||||
@@ -169,7 +169,7 @@ fn slasher_test(
|
||||
current_epoch: u64,
|
||||
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 slasher = Slasher::open(config, logger()).unwrap();
|
||||
let current_epoch = Epoch::new(current_epoch);
|
||||
@@ -196,7 +196,7 @@ fn parallel_slasher_test(
|
||||
expected_slashed_validators: HashSet<u64>,
|
||||
current_epoch: u64,
|
||||
) {
|
||||
let tempdir = TempDir::new("slasher").unwrap();
|
||||
let tempdir = tempdir().unwrap();
|
||||
let config = Config::new(tempdir.path().into());
|
||||
let slasher = Slasher::open(config, logger()).unwrap();
|
||||
let current_epoch = Epoch::new(current_epoch);
|
||||
|
||||
@@ -2,12 +2,12 @@ use slasher::{
|
||||
test_utils::{block as test_block, logger, E},
|
||||
Config, Slasher,
|
||||
};
|
||||
use tempdir::TempDir;
|
||||
use tempfile::tempdir;
|
||||
use types::{Epoch, EthSpec};
|
||||
|
||||
#[test]
|
||||
fn empty_pruning() {
|
||||
let tempdir = TempDir::new("slasher").unwrap();
|
||||
let tempdir = tempdir().unwrap();
|
||||
let config = Config::new(tempdir.path().into());
|
||||
let slasher = Slasher::<E>::open(config.clone(), logger()).unwrap();
|
||||
slasher.prune_database(Epoch::new(0)).unwrap();
|
||||
@@ -17,7 +17,7 @@ fn empty_pruning() {
|
||||
fn block_pruning() {
|
||||
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());
|
||||
config.chunk_size = 2;
|
||||
config.history_length = 2;
|
||||
|
||||
@@ -8,7 +8,7 @@ use slasher::{
|
||||
Config, Slasher,
|
||||
};
|
||||
use std::cmp::max;
|
||||
use tempdir::TempDir;
|
||||
use tempfile::tempdir;
|
||||
use types::{Epoch, EthSpec};
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -38,7 +38,7 @@ fn random_test(seed: u64, test_config: TestConfig) {
|
||||
println!("Running with seed {}", 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());
|
||||
config.validator_chunk_size = 1 << rng.gen_range(1, 4);
|
||||
|
||||
@@ -2,12 +2,12 @@ use slasher::{
|
||||
test_utils::{indexed_att, logger},
|
||||
Config, Error, Slasher,
|
||||
};
|
||||
use tempdir::TempDir;
|
||||
use tempfile::tempdir;
|
||||
use types::Epoch;
|
||||
|
||||
#[test]
|
||||
fn attestation_pruning_empty_wrap_around() {
|
||||
let tempdir = TempDir::new("slasher").unwrap();
|
||||
let tempdir = tempdir().unwrap();
|
||||
let mut config = Config::new(tempdir.path().into());
|
||||
config.validator_chunk_size = 1;
|
||||
config.chunk_size = 16;
|
||||
@@ -41,7 +41,7 @@ fn attestation_pruning_empty_wrap_around() {
|
||||
// Test that pruning can recover from a `MapFull` error
|
||||
#[test]
|
||||
fn pruning_with_map_full() {
|
||||
let tempdir = TempDir::new("slasher").unwrap();
|
||||
let tempdir = tempdir().unwrap();
|
||||
let mut config = Config::new(tempdir.path().into());
|
||||
config.validator_chunk_size = 1;
|
||||
config.chunk_size = 16;
|
||||
|
||||
Reference in New Issue
Block a user