Replace deprecated tempdir dependency with tempfile (#11588)

`Tempdir` is deprecated, but the functionality has been merged into
another crate: `tempfile`. This commit removes all `tempdir` dependencies
and replaces them with `tempfile` and the equivalent bindings.

Fixes #11560
This commit is contained in:
marktoda
2020-03-29 13:31:17 -07:00
committed by GitHub
parent 4f26ffd447
commit 2a3217d8d8
76 changed files with 220 additions and 214 deletions

View File

@@ -329,7 +329,7 @@ pub fn calculate_dag_item(node_index: u32, cache: &[Node]) -> Node {
mod test {
use super::*;
use std::fs;
use tempdir::TempDir;
use tempfile::TempDir;
#[test]
fn test_get_cache_size() {
@@ -402,7 +402,7 @@ mod test {
];
let nonce = 0xd7b3ac70a301a249;
let tempdir = TempDir::new("").unwrap();
let tempdir = TempDir::new().unwrap();
// difficulty = 0x085657254bd9u64;
let light = NodeCacheBuilder::new(None, u64::max_value()).light(tempdir.path(), 486382);
let result = light_compute(&light, &hash, nonce);
@@ -412,7 +412,7 @@ mod test {
#[test]
fn test_drop_old_data() {
let tempdir = TempDir::new("").unwrap();
let tempdir = TempDir::new().unwrap();
let builder = NodeCacheBuilder::new(None, u64::max_value());
let first = builder.light(tempdir.path(), 0).to_file().unwrap().to_owned();

View File

@@ -37,7 +37,7 @@ extern crate rustc_hex;
extern crate serde_json;
#[cfg(test)]
extern crate tempdir;
extern crate tempfile;
#[cfg(feature = "bench")]
@@ -196,9 +196,9 @@ fn difficulty_to_boundary_aux<T: Into<U512>>(difficulty: T) -> ethereum_types::U
#[test]
fn test_lru() {
use tempdir::TempDir;
use tempfile::TempDir;
let tempdir = TempDir::new("").unwrap();
let tempdir = TempDir::new().unwrap();
let ethash = EthashManager::new(tempdir.path(), None, u64::max_value());
let hash = [0u8; 32];
ethash.compute_light(1, &hash, 1);

View File

@@ -420,7 +420,7 @@ pub fn generate_cdag(cache: &[Node]) -> CDag {
#[cfg(test)]
mod test {
use tempdir::TempDir;
use tempfile::TempDir;
use common_types::engines::OptimizeFor;
use cache::NodeCacheBuilder;
@@ -440,7 +440,7 @@ mod test {
#[test]
fn test_cdag() {
let builder = NodeCacheBuilder::new(OptimizeFor::Memory, u64::max_value());
let tempdir = TempDir::new("").unwrap();
let tempdir = TempDir::new().unwrap();
let cache = builder.new_cache(tempdir.into_path(), 0);
let c_dag = generate_cdag(cache.as_ref());
@@ -535,7 +535,7 @@ mod test {
#[test]
fn test_progpow_hash() {
let builder = NodeCacheBuilder::new(OptimizeFor::Memory, u64::max_value());
let tempdir = TempDir::new("").unwrap();
let tempdir = TempDir::new().unwrap();
let cache = builder.new_cache(tempdir.into_path(), 0);
let c_dag = generate_cdag(cache.as_ref());
@@ -596,7 +596,7 @@ mod test {
for test in tests {
let builder = NodeCacheBuilder::new(OptimizeFor::Memory, u64::max_value());
let tempdir = TempDir::new("").unwrap();
let tempdir = TempDir::new().unwrap();
let cache = builder.new_cache(tempdir.path().to_owned(), test.block_number);
let c_dag = generate_cdag(cache.as_ref());