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

@@ -13,7 +13,7 @@ use tokio::runtime::Runtime;
use types::{ChainSpec, EnrForkId, MinimalEthSpec};
type E = MinimalEthSpec;
use tempdir::TempDir;
use tempfile::Builder as TempBuilder;
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 {
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.discovery_port = port; // udp port