fixed U256 and transaction request deserialization, added tests for transaction request
This commit is contained in:
@@ -39,7 +39,6 @@
|
||||
use std::fmt;
|
||||
use std::cmp;
|
||||
|
||||
use std::mem;
|
||||
use std::str::{FromStr};
|
||||
use std::convert::From;
|
||||
use std::hash::{Hash, Hasher};
|
||||
@@ -788,14 +787,11 @@ macro_rules! construct_uint {
|
||||
|
||||
fn visit_str<E>(&mut self, value: &str) -> Result<Self::Value, E> where E: serde::Error {
|
||||
// 0x + len
|
||||
if value.len() != 2 + $n_words / 8 {
|
||||
if value.len() > 2 + $n_words * 16 {
|
||||
return Err(serde::Error::custom("Invalid length."));
|
||||
}
|
||||
|
||||
match $name::from_str(&value[2..]) {
|
||||
Ok(val) => Ok(val),
|
||||
Err(_) => { return Err(serde::Error::custom("Invalid length.")); }
|
||||
}
|
||||
$name::from_str(&value[2..]).map_err(|_| serde::Error::custom("Invalid hex value."))
|
||||
}
|
||||
|
||||
fn visit_string<E>(&mut self, value: String) -> Result<Self::Value, E> where E: serde::Error {
|
||||
|
||||
@@ -257,7 +257,7 @@ macro_rules! impl_hash {
|
||||
return Err(serde::Error::custom("Invalid length."));
|
||||
}
|
||||
|
||||
value[2..].from_hex().map(|ref v| $from::from_slice(v)).map_err(|_| serde::Error::custom("Invalid valid hex."))
|
||||
value[2..].from_hex().map(|ref v| $from::from_slice(v)).map_err(|_| serde::Error::custom("Invalid hex value."))
|
||||
}
|
||||
|
||||
fn visit_string<E>(&mut self, value: String) -> Result<Self::Value, E> where E: serde::Error {
|
||||
|
||||
Reference in New Issue
Block a user