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

@@ -20,7 +20,7 @@ criterion = "0.3"
hex-literal = "0.2.1"
rustc-hex = "2.1.0"
serde_json = "1.0"
tempdir = "0.3"
tempfile = "3.1"
[features]
default = []

View File

@@ -22,19 +22,19 @@ extern crate hex_literal;
extern crate common_types;
extern crate ethash;
extern crate tempdir;
extern crate tempfile;
use criterion::Criterion;
use ethash::progpow;
use tempdir::TempDir;
use tempfile::TempDir;
use ethash::NodeCacheBuilder;
use ethash::compute::light_compute;
use common_types::engines::OptimizeFor;
fn bench_hashimoto_light(c: &mut Criterion) {
let builder = NodeCacheBuilder::new(OptimizeFor::Memory, u64::max_value());
let tempdir = TempDir::new("").unwrap();
let tempdir = TempDir::new().unwrap();
let light = builder.light(&tempdir.path(), 1);
let h = hex!("c9149cc0386e689d789a1c2f3d5d169a61a6218ed30e74414dc736e442ef3d1f");
let mut hash = [0; 32];
@@ -47,7 +47,7 @@ fn bench_hashimoto_light(c: &mut Criterion) {
fn bench_progpow_light(c: &mut Criterion) {
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 h = hex!("c9149cc0386e689d789a1c2f3d5d169a61a6218ed30e74414dc736e442ef3d1f");
@@ -70,7 +70,7 @@ fn bench_progpow_light(c: &mut Criterion) {
fn bench_progpow_optimal_light(c: &mut Criterion) {
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 = progpow::generate_cdag(cache.as_ref());

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