Skip to content

Commit

Permalink
Replace tempdir dependency with tempfile (#883)
Browse files Browse the repository at this point in the history
* Replace tempdir with tempfile

Signed-off-by: Thane Thomson <[email protected]>

* Update CHANGELOG

Signed-off-by: Thane Thomson <[email protected]>

* Replace deprecated tempdir with tempfile in proto-compiler

Signed-off-by: Thane Thomson <[email protected]>

* Add .changelog entry

Signed-off-by: Thane Thomson <[email protected]>
  • Loading branch information
thanethomson authored Jun 5, 2021
1 parent b032801 commit 5475e95
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .changelog/unreleased/improvements/851-tempdir.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* `[tendermint-light-client]` Replaced `tempdir` dev dependency (deprecated)
with `tempfile`
([#851](https://github.com/informalsystems/tendermint-rs/issues/851))

2 changes: 1 addition & 1 deletion light-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ tendermint-testgen = { path = "../testgen" }
serde_json = "1.0.51"
gumdrop = "0.8.0"
rand = "0.7.3"
tempdir = "0.3.7"
tempfile = "3.2.0"
proptest = "0.10.1"
4 changes: 2 additions & 2 deletions light-client/src/store/sled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl LightStore for SledStore {
#[cfg(test)]
mod tests {
use super::*;
use tempdir::TempDir;
use tempfile::tempdir;
use tendermint_testgen::{light_block::TmLightBlock as TGLightBlock, Generator, LightChain};

#[test]
Expand Down Expand Up @@ -124,7 +124,7 @@ mod tests {
}

fn with_blocks(height: u64, f: impl FnOnce(SledStore, Vec<LightBlock>)) {
let tmp_dir = TempDir::new("tendermint_light_client_sled_test").unwrap();
let tmp_dir = tempdir().unwrap();
let db = SledStore::open(tmp_dir).unwrap();

let chain = LightChain::default_with_length(height);
Expand Down
6 changes: 3 additions & 3 deletions light-client/src/store/sled/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ where
#[cfg(test)]
mod tests {
use super::*;
use tempdir::TempDir;
use tempfile::tempdir;

#[test]
fn iter_next_returns_lowest_height() {
let tmp_dir = TempDir::new("tendermint_light_client_sled_utils_test").unwrap();
let tmp_dir = tempdir().unwrap();
let db = sled::open(tmp_dir).unwrap();
let kv = HeightIndexedDb::new(db.open_tree("light_store/verified").unwrap());

Expand All @@ -126,7 +126,7 @@ mod tests {

#[test]
fn iter_next_back_returns_highest_height() {
let tmp_dir = TempDir::new("tendermint_light_client_sled_utils_test").unwrap();
let tmp_dir = tempdir().unwrap();
let db = sled::open(tmp_dir).unwrap();
let kv = HeightIndexedDb::new(db.open_tree("light_store/verified").unwrap());

Expand Down
2 changes: 1 addition & 1 deletion tools/proto-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ publish = false
walkdir = { version = "2.3" }
prost-build = { version = "0.7" }
git2 = { version = "0.13" }
tempdir = { version = "0.3" }
tempfile = { version = "3.2.0" }
subtle-encoding = { version = "0.5" }
4 changes: 2 additions & 2 deletions tools/proto-compiler/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::env::var;
use std::path::PathBuf;
use tempdir::TempDir;
use tempfile::tempdir;

mod functions;
use functions::{copy_files, find_proto_files, generate_tendermint_lib, get_commitish};
Expand All @@ -26,7 +26,7 @@ fn main() {
.join("prost");
let out_dir = var("OUT_DIR")
.map(PathBuf::from)
.or_else(|_| TempDir::new("tendermint_proto_out").map(|d| d.into_path()))
.or_else(|_| tempdir().map(|d| d.into_path()))
.unwrap();
let tendermint_dir = PathBuf::from(var("TENDERMINT_DIR").unwrap_or_else(|_| {
root.join("..")
Expand Down

0 comments on commit 5475e95

Please sign in to comment.