Skip to content

Commit

Permalink
Fix compiling error on windows (#410)
Browse files Browse the repository at this point in the history
* Fix compiling error on windows

* Fix JsonFileDatastore tests

* Update tempfile cargo, Refactor JsonFileDatastore tests
  • Loading branch information
jasl authored and tomaka committed Aug 14, 2018
1 parent b673209 commit e5afab1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion datastore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
18 changes: 10 additions & 8 deletions datastore/src/json_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ where
.map(|(k, v)| (k, to_value(v).unwrap()))
.collect::<Map<_, _>>(),
)?;
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
Expand Down Expand Up @@ -275,31 +275,33 @@ mod tests {

#[test]
fn open_and_flush() {
let temp_file = NamedTempFile::new().unwrap();
let datastore = JsonFileDatastore::<Vec<u8>>::new(temp_file.path()).unwrap();
let path = NamedTempFile::new().unwrap().into_temp_path();

let datastore = JsonFileDatastore::<Vec<u8>>::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::<Vec<u8>>::new(temp_file.path()).unwrap();
let datastore = JsonFileDatastore::<Vec<u8>>::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::<Vec<u8>>::new(temp_file.path()).unwrap();

let reload = JsonFileDatastore::<Vec<u8>>::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::<Vec<u8>>::new(temp_file.path()).unwrap();
let datastore = JsonFileDatastore::<Vec<u8>>::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]);
Expand Down
4 changes: 2 additions & 2 deletions secio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ 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 }
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"]
Expand Down

0 comments on commit e5afab1

Please sign in to comment.