From e5afab104a3543281439a6a9b83b07cfd05b6187 Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Tue, 14 Aug 2018 17:31:05 +0800 Subject: [PATCH] Fix compiling error on windows (#410) * Fix compiling error on windows * Fix JsonFileDatastore tests * Update tempfile cargo, Refactor JsonFileDatastore tests --- datastore/Cargo.toml | 2 +- datastore/src/json_file.rs | 18 ++++++++++-------- secio/Cargo.toml | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/datastore/Cargo.toml b/datastore/Cargo.toml index 7a60a5cb4da..9e0c494f141 100644 --- a/datastore/Cargo.toml +++ b/datastore/Cargo.toml @@ -10,4 +10,4 @@ chashmap = { git = "https://github.com/redox-os/tfs" } futures = "0.1" serde = "1.0" serde_json = "1.0" -tempfile = "2.2" +tempfile = "3" diff --git a/datastore/src/json_file.rs b/datastore/src/json_file.rs index 9ada37a1f15..2c700fa98ae 100644 --- a/datastore/src/json_file.rs +++ b/datastore/src/json_file.rs @@ -140,7 +140,7 @@ where .map(|(k, v)| (k, to_value(v).unwrap())) .collect::>(), )?; - temporary_file.sync_data()?; + temporary_file.as_file().sync_data()?; // Note that `persist` will fail if we try to persist across filesystems. However that // shouldn't happen since we created the temporary file in the same directory as the final @@ -275,31 +275,33 @@ mod tests { #[test] fn open_and_flush() { - let temp_file = NamedTempFile::new().unwrap(); - let datastore = JsonFileDatastore::>::new(temp_file.path()).unwrap(); + let path = NamedTempFile::new().unwrap().into_temp_path(); + + let datastore = JsonFileDatastore::>::new(&path).unwrap(); datastore.flush().unwrap(); } #[test] fn values_store_and_reload() { - let temp_file = NamedTempFile::new().unwrap(); + let path = NamedTempFile::new().unwrap().into_temp_path(); - let datastore = JsonFileDatastore::>::new(temp_file.path()).unwrap(); + let datastore = JsonFileDatastore::>::new(&path).unwrap(); datastore.put("foo".into(), vec![1, 2, 3]); datastore.put("bar".into(), vec![0, 255, 127]); datastore.flush().unwrap(); drop(datastore); - let reload = JsonFileDatastore::>::new(temp_file.path()).unwrap(); + + let reload = JsonFileDatastore::>::new(&path).unwrap(); assert_eq!(reload.get("bar").unwrap(), &[0, 255, 127]); assert_eq!(reload.get("foo").unwrap(), &[1, 2, 3]); } #[test] fn query_basic() { - let temp_file = NamedTempFile::new().unwrap(); + let path = NamedTempFile::new().unwrap().into_temp_path(); - let datastore = JsonFileDatastore::>::new(temp_file.path()).unwrap(); + let datastore = JsonFileDatastore::>::new(&path).unwrap(); datastore.put("foo1".into(), vec![6, 7, 8]); datastore.put("foo2".into(), vec![6, 7, 8]); datastore.put("foo3".into(), vec![7, 8, 9]); diff --git a/secio/Cargo.toml b/secio/Cargo.toml index 16040d36656..d20bd98e272 100644 --- a/secio/Cargo.toml +++ b/secio/Cargo.toml @@ -12,7 +12,7 @@ libp2p-core = { path = "../core" } log = "0.4.1" protobuf = "2.0.2" rand = "0.3.17" -ring = { version = "0.12.1", features = ["rsa_signing"] } +ring = { version = "0.13.2", features = ["rsa_signing"] } aes-ctr = "0.1.0" aesni = { version = "0.4.1", features = ["nocheck"], optional = true } ctr = { version = "0.1", optional = true } @@ -20,7 +20,7 @@ lazy_static = { version = "0.2.11", optional = true } rw-stream-sink = { path = "../rw-stream-sink" } eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1", optional = true } tokio-io = "0.1.0" -untrusted = "0.5.1" +untrusted = "0.6.2" [features] default = ["secp256k1"]