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:
Arthur Woimbée
2021-01-06 06:36:11 +00:00
parent 7e4b190df0
commit 851a4dca3c
21 changed files with 64 additions and 74 deletions

View File

@@ -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);