Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
Merge #3166
Browse files Browse the repository at this point in the history
3166: Replace deprecated `tempdir` with `tempfile` r=thomaseizinger a=D4nte

See https://rustsec.org/advisories/RUSTSEC-2018-0017.html

Co-authored-by: Franck Royer <franck@coblox.tech>
  • Loading branch information
bors[bot] and Franck Royer committed Sep 14, 2020
2 parents d6ce8ba + cf9c0b8 commit b0c4325
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 28 deletions.
12 changes: 1 addition & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nectar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ base64 = "0.12"
proptest = "0.10"
quickcheck = "0.9"
quickcheck_async = "0.1"
tempdir = "0.3"
tempfile = "3"
testcontainers = "0.9"

[features]
Expand Down
4 changes: 2 additions & 2 deletions nectar/src/bitcoin/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ mod docker_tests {
path::Path,
process::{Command, Stdio},
};
use tempdir::TempDir;
use tempfile::TempDir;
use testcontainers::clients;

#[tokio::test]
Expand Down Expand Up @@ -311,7 +311,7 @@ mod docker_tests {

let _ = wallet.dump(wif_path_docker).await.unwrap();

let tmp_dir = TempDir::new("nectar_test").unwrap();
let tmp_dir = TempDir::new().unwrap();
let path = tmp_dir.path().join("wallet.wif");

Command::new("docker")
Expand Down
2 changes: 1 addition & 1 deletion nectar/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ mod tests {

#[test]
fn read_config_uses_default_path() {
let tmp_dir = tempdir::TempDir::new("nectar_test").unwrap();
let tmp_dir = tempfile::TempDir::new().unwrap();
let default_path = tmp_dir.path().join("config.toml");

let mut file = fs::File::create(default_path.clone()).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions nectar/src/config/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ mod tests {
};
use spectral::prelude::*;
use std::{io::Write, path::PathBuf};
use tempdir::TempDir;
use tempfile::TempDir;

#[derive(serde::Deserialize, PartialEq, Debug)]
struct LoggingOnlyConfig {
Expand Down Expand Up @@ -224,7 +224,7 @@ local_dai_contract_address = "0x6A9865aDE2B6207dAAC49f8bCba9705dEB0B0e6D"
}),
};

let tmp_dir = TempDir::new("nectar_test").unwrap();
let tmp_dir = TempDir::new().unwrap();
let file_path = tmp_dir.path().join("config.toml");

let mut file = std::fs::File::create(&file_path).unwrap();
Expand Down
12 changes: 3 additions & 9 deletions nectar/src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,11 @@ impl History {
mod tests {
use super::*;
use std::io::Read;
use tempdir::TempDir;
use tempfile::TempDir;

#[test]
fn write_two_trades_with_headers() {
let temp_file = TempDir::new("nectar_test")
.unwrap()
.path()
.join("history.csv");
let temp_file = TempDir::new().unwrap().path().join("history.csv");
let trade_1 = Trade::new_1();
let trade_2 = Trade::new_2();
let mut history = History::new(&temp_file).unwrap();
Expand All @@ -240,10 +237,7 @@ mod tests {

#[test]
fn re_use_existing_file_without_losing_data_or_re_writing_headers() {
let temp_file = TempDir::new("nectar_test")
.unwrap()
.path()
.join("history.csv");
let temp_file = TempDir::new().unwrap().path().join("history.csv");
let trade_1 = Trade::new_1();
let trade_2 = Trade::new_2();
let mut history = History::new(&temp_file).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions nectar/src/swap/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub trait Save<T>: Send + Sync + 'static {
pub struct Database {
db: sled::Db,
#[cfg(test)]
tmp_dir: tempdir::TempDir,
tmp_dir: tempfile::TempDir,
}

impl Database {
Expand Down Expand Up @@ -57,7 +57,7 @@ impl Database {

#[cfg(test)]
pub fn new_test() -> anyhow::Result<Self> {
let tmp_dir = tempdir::TempDir::new("nectar_test").unwrap();
let tmp_dir = tempfile::TempDir::new().unwrap();
let db = sled::open(tmp_dir.path()).context(format!(
"Could not open the DB at {}",
tmp_dir.path().display()
Expand Down

0 comments on commit b0c4325

Please sign in to comment.