Update serde dep to 0.6 from 0.3

This commit is contained in:
Andrew Poelstra 2015-09-20 12:52:46 -05:00
parent 016d781f2e
commit cc68cf8b9e
5 changed files with 21 additions and 15 deletions

View File

@ -1,7 +1,7 @@
[package]
name = "secp256k1"
version = "0.1.2"
version = "0.2.2"
authors = [ "Dawid Ciężarkiewicz <dpc@ucore.info>",
"Andrew Poelstra <apoelstra@wpsoftware.net>" ]
license = "CC0-1.0"
@ -24,5 +24,6 @@ arrayvec = "0.3"
rand = "0.3"
libc = "0.1"
rustc-serialize = "0.3"
serde = "0.3"
serde = "0.6"
serde_json = "0.6"

View File

@ -17,7 +17,9 @@
use std::mem;
use libc::{c_int, c_uchar, c_uint, c_void};
/// Flag for context to enable verification precomputation
pub const SECP256K1_START_VERIFY: c_uint = 0x1;
/// Flag for context to enable signing precomputation
pub const SECP256K1_START_SIGN: c_uint = 0x2;
/// A nonce generation function. Ordinary users of the library

View File

@ -255,7 +255,7 @@ impl Deserialize for PublicKey {
}
try!(v.end());
PublicKey::from_slice(&s, &ret[..read_len]).map_err(|_| de::Error::syntax_error())
PublicKey::from_slice(&s, &ret[..read_len]).map_err(|e| de::Error::syntax(&e.to_string()))
}
}
}
@ -402,40 +402,42 @@ mod test {
#[test]
fn test_bad_serde_deserialize() {
use serde::{json, Deserialize};
use serde::Deserialize;
use json;
// Invalid length
let zero31 = "[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]".as_bytes();
let mut json = json::de::Deserializer::new(zero31.iter().map(|c| Ok(*c))).unwrap();
let mut json = json::de::Deserializer::new(zero31.iter().map(|c| Ok(*c)));
assert!(<PublicKey as Deserialize>::deserialize(&mut json).is_err());
let mut json = json::de::Deserializer::new(zero31.iter().map(|c| Ok(*c))).unwrap();
let mut json = json::de::Deserializer::new(zero31.iter().map(|c| Ok(*c)));
assert!(<SecretKey as Deserialize>::deserialize(&mut json).is_err());
let zero32 = "[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]".as_bytes();
let mut json = json::de::Deserializer::new(zero32.iter().map(|c| Ok(*c))).unwrap();
let mut json = json::de::Deserializer::new(zero32.iter().map(|c| Ok(*c)));
assert!(<PublicKey as Deserialize>::deserialize(&mut json).is_err());
let mut json = json::de::Deserializer::new(zero32.iter().map(|c| Ok(*c))).unwrap();
let mut json = json::de::Deserializer::new(zero32.iter().map(|c| Ok(*c)));
assert!(<SecretKey as Deserialize>::deserialize(&mut json).is_ok());
// All zeroes pk is invalid
let zero65 = "[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]".as_bytes();
let mut json = json::de::Deserializer::new(zero65.iter().map(|c| Ok(*c))).unwrap();
let mut json = json::de::Deserializer::new(zero65.iter().map(|c| Ok(*c)));
assert!(<PublicKey as Deserialize>::deserialize(&mut json).is_err());
let mut json = json::de::Deserializer::new(zero65.iter().map(|c| Ok(*c))).unwrap();
let mut json = json::de::Deserializer::new(zero65.iter().map(|c| Ok(*c)));
assert!(<SecretKey as Deserialize>::deserialize(&mut json).is_err());
// Syntax error
let string = "\"my key\"".as_bytes();
let mut json = json::de::Deserializer::new(string.iter().map(|c| Ok(*c))).unwrap();
let mut json = json::de::Deserializer::new(string.iter().map(|c| Ok(*c)));
assert!(<PublicKey as Deserialize>::deserialize(&mut json).is_err());
let mut json = json::de::Deserializer::new(string.iter().map(|c| Ok(*c))).unwrap();
let mut json = json::de::Deserializer::new(string.iter().map(|c| Ok(*c)));
assert!(<SecretKey as Deserialize>::deserialize(&mut json).is_err());
}
#[test]
fn test_serialize_serde() {
use serde::{json, Serialize, Deserialize};
use serde::{Serialize, Deserialize};
use json;
macro_rules! round_trip (
($var:ident) => ({
@ -445,7 +447,7 @@ mod test {
let mut serializer = json::ser::Serializer::new(&mut encoded);
start.serialize(&mut serializer).unwrap();
}
let mut deserializer = json::de::Deserializer::new(encoded.iter().map(|c| Ok(*c))).unwrap();
let mut deserializer = json::de::Deserializer::new(encoded.iter().map(|c| Ok(*c)));
let decoded = Deserialize::deserialize(&mut deserializer);
assert_eq!(Some(start), decoded.ok());
})

View File

@ -38,6 +38,7 @@
extern crate arrayvec;
extern crate rustc_serialize as serialize;
extern crate serde;
extern crate serde_json as json;
extern crate libc;
extern crate rand;

View File

@ -163,7 +163,7 @@ macro_rules! impl_array_newtype {
for i in 0..$len {
ret[i] = match try!(v.visit()) {
Some(c) => c,
None => return Err(::serde::de::Error::end_of_stream_error())
None => return Err(::serde::de::Error::end_of_stream())
};
}
try!(v.end());