Replace serde_json with strason in tests
This commit is contained in:
parent
fa59c35e9a
commit
c3c6983789
|
@ -26,6 +26,6 @@ rust-crypto = "0.2"
|
||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
secp256k1 = "0.5"
|
secp256k1 = "0.5"
|
||||||
serde = "0.6"
|
serde = "0.6"
|
||||||
serde_json = "0.6"
|
strason = "0.3"
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ extern crate rand;
|
||||||
extern crate rustc_serialize as serialize;
|
extern crate rustc_serialize as serialize;
|
||||||
extern crate secp256k1;
|
extern crate secp256k1;
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
extern crate serde_json as json;
|
extern crate strason;
|
||||||
#[cfg(all(test, feature = "unstable"))] extern crate test;
|
#[cfg(all(test, feature = "unstable"))] extern crate test;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
|
|
||||||
|
|
|
@ -19,17 +19,13 @@
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! serde_round_trip (
|
macro_rules! serde_round_trip (
|
||||||
($var:expr) => ({
|
($var:expr) => ({
|
||||||
use serde::{json, Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
|
use strason;
|
||||||
|
|
||||||
let start = $var;
|
let start = $var;
|
||||||
let mut encoded = Vec::new();
|
let encoded = strason::from_serialize(start).unwrap();
|
||||||
{
|
let decoded = encoded.into_deserialize().unwrap();
|
||||||
let mut serializer = json::ser::Serializer::new(&mut encoded);
|
assert_eq!(start, decoded);
|
||||||
start.serialize(&mut serializer).unwrap();
|
|
||||||
}
|
|
||||||
let mut deserializer = json::de::Deserializer::new(encoded.iter().map(|c| Ok(*c))).unwrap();
|
|
||||||
let decoded = Deserialize::deserialize(&mut deserializer);
|
|
||||||
assert_eq!(Some(start), decoded.ok());
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -282,7 +282,7 @@ impl <T: BitcoinHash> MerkleRoot for Vec<T> {
|
||||||
mod tests {
|
mod tests {
|
||||||
use num::FromPrimitive;
|
use num::FromPrimitive;
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use json;
|
use strason;
|
||||||
|
|
||||||
use network::serialize::{serialize, deserialize};
|
use network::serialize::{serialize, deserialize};
|
||||||
use util::hash::Sha256dHash;
|
use util::hash::Sha256dHash;
|
||||||
|
@ -309,15 +309,11 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_hash_encode_decode() {
|
fn test_hash_encode_decode() {
|
||||||
let hash = Sha256dHash::from_data(&[]);
|
let hash = Sha256dHash::from_data(&[]);
|
||||||
let mut writer = vec![];
|
let encoded = strason::from_serialize(&hash).unwrap();
|
||||||
{
|
assert_eq!(encoded.to_bytes(),
|
||||||
let mut serializer = json::ser::Serializer::new(&mut writer);
|
|
||||||
assert!(hash.serialize(&mut serializer).is_ok());
|
|
||||||
}
|
|
||||||
assert_eq!(&writer[..],
|
|
||||||
"\"56944c5d3f98413ef45cf54545538103cc9f298e0575820ad3591376e2e0f65d\"".as_bytes());
|
"\"56944c5d3f98413ef45cf54545538103cc9f298e0575820ad3591376e2e0f65d\"".as_bytes());
|
||||||
let mut deserializer = json::de::Deserializer::new(writer.iter().map(|c| Ok(*c)));
|
let decoded = encoded.into_deserialize().unwrap();
|
||||||
assert_eq!(hash, Deserialize::deserialize(&mut deserializer).unwrap());
|
assert_eq!(hash, decoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue