mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-27 08:41:36 +00:00
Fix compiling error on windows (#410)
* Fix compiling error on windows * Fix JsonFileDatastore tests * Update tempfile cargo, Refactor JsonFileDatastore tests
This commit is contained in:
committed by
Pierre Krieger
parent
b673209839
commit
e5afab104a
@ -10,4 +10,4 @@ chashmap = { git = "https://github.com/redox-os/tfs" }
|
|||||||
futures = "0.1"
|
futures = "0.1"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
tempfile = "2.2"
|
tempfile = "3"
|
||||||
|
@ -140,7 +140,7 @@ where
|
|||||||
.map(|(k, v)| (k, to_value(v).unwrap()))
|
.map(|(k, v)| (k, to_value(v).unwrap()))
|
||||||
.collect::<Map<_, _>>(),
|
.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
|
// 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
|
// shouldn't happen since we created the temporary file in the same directory as the final
|
||||||
@ -275,31 +275,33 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn open_and_flush() {
|
fn open_and_flush() {
|
||||||
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.flush().unwrap();
|
datastore.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn values_store_and_reload() {
|
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("foo".into(), vec![1, 2, 3]);
|
||||||
datastore.put("bar".into(), vec![0, 255, 127]);
|
datastore.put("bar".into(), vec![0, 255, 127]);
|
||||||
datastore.flush().unwrap();
|
datastore.flush().unwrap();
|
||||||
drop(datastore);
|
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("bar").unwrap(), &[0, 255, 127]);
|
||||||
assert_eq!(reload.get("foo").unwrap(), &[1, 2, 3]);
|
assert_eq!(reload.get("foo").unwrap(), &[1, 2, 3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn query_basic() {
|
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("foo1".into(), vec![6, 7, 8]);
|
||||||
datastore.put("foo2".into(), vec![6, 7, 8]);
|
datastore.put("foo2".into(), vec![6, 7, 8]);
|
||||||
datastore.put("foo3".into(), vec![7, 8, 9]);
|
datastore.put("foo3".into(), vec![7, 8, 9]);
|
||||||
|
@ -12,7 +12,7 @@ libp2p-core = { path = "../core" }
|
|||||||
log = "0.4.1"
|
log = "0.4.1"
|
||||||
protobuf = "2.0.2"
|
protobuf = "2.0.2"
|
||||||
rand = "0.3.17"
|
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"
|
aes-ctr = "0.1.0"
|
||||||
aesni = { version = "0.4.1", features = ["nocheck"], optional = true }
|
aesni = { version = "0.4.1", features = ["nocheck"], optional = true }
|
||||||
ctr = { version = "0.1", 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" }
|
rw-stream-sink = { path = "../rw-stream-sink" }
|
||||||
eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1", optional = true }
|
eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1", optional = true }
|
||||||
tokio-io = "0.1.0"
|
tokio-io = "0.1.0"
|
||||||
untrusted = "0.5.1"
|
untrusted = "0.6.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["secp256k1"]
|
default = ["secp256k1"]
|
||||||
|
Reference in New Issue
Block a user