* Porting json

* Dapps

* Rpc & Ethstore

* New ethabi

* Last bunch of fixes

* Fixing last test

* Removing build script

* Adding ethcore-ipc-tests back

* Fixing grumbles

* Fixing blockchain tests (inference regression?)
This commit is contained in:
Tomasz Drwięga
2017-02-13 16:38:47 +01:00
committed by Nikolay Volf
parent a2c6cd8f7b
commit f1e99ea2e4
68 changed files with 683 additions and 2480 deletions

View File

@@ -16,11 +16,12 @@
//! Trie test input deserialization.
use std::fmt;
use std::collections::BTreeMap;
use std::str::FromStr;
use bytes::Bytes;
use serde::{Deserialize, Deserializer, Error};
use serde::de::{Visitor, MapVisitor, SeqVisitor};
use serde::{Deserialize, Deserializer};
use serde::de::{Error as ErrorTrait, Visitor, MapVisitor, SeqVisitor};
/// Trie test input.
#[derive(Debug, PartialEq)]
@@ -30,7 +31,7 @@ pub struct Input {
}
impl Deserialize for Input {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer
{
deserializer.deserialize(InputVisitor)
@@ -42,20 +43,24 @@ struct InputVisitor;
impl Visitor for InputVisitor {
type Value = Input;
fn visit_map<V>(&mut self, mut visitor: V) -> Result<Self::Value, V::Error> where V: MapVisitor {
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a map of bytes into bytes")
}
fn visit_map<V>(self, mut visitor: V) -> Result<Self::Value, V::Error> where V: MapVisitor {
let mut result = BTreeMap::new();
loop {
let key_str: Option<String> = visitor.visit_key()?;
let key = match key_str {
Some(ref k) if k.starts_with("0x") => Bytes::from_str(k).map_err(Error::custom)?,
Some(ref k) if k.starts_with("0x") => Bytes::from_str(k).map_err(V::Error::custom)?,
Some(k) => Bytes::new(k.into_bytes()),
None => { break; }
};
let val_str: Option<String> = visitor.visit_value()?;
let val = match val_str {
Some(ref v) if v.starts_with("0x") => Some(Bytes::from_str(v).map_err(Error::custom)?),
Some(ref v) if v.starts_with("0x") => Some(Bytes::from_str(v).map_err(V::Error::custom)?),
Some(v) => Some(Bytes::new(v.into_bytes())),
None => None,
};
@@ -63,8 +68,6 @@ impl Visitor for InputVisitor {
result.insert(key, val);
}
visitor.end()?;
let input = Input {
data: result
};
@@ -72,7 +75,7 @@ impl Visitor for InputVisitor {
Ok(input)
}
fn visit_seq<V>(&mut self, mut visitor: V) -> Result<Self::Value, V::Error> where V: SeqVisitor {
fn visit_seq<V>(self, mut visitor: V) -> Result<Self::Value, V::Error> where V: SeqVisitor {
let mut result = BTreeMap::new();
loop {
@@ -83,20 +86,20 @@ impl Visitor for InputVisitor {
};
if keyval.len() != 2 {
return Err(Error::custom("Invalid key value pair."));
return Err(V::Error::custom("Invalid key value pair."));
}
let ref key_str: Option<String> = keyval[0];
let ref val_str: Option<String> = keyval[1];
let key = match *key_str {
Some(ref k) if k.starts_with("0x") => Bytes::from_str(k).map_err(Error::custom)?,
Some(ref k) if k.starts_with("0x") => Bytes::from_str(k).map_err(V::Error::custom)?,
Some(ref k) => Bytes::new(k.clone().into_bytes()),
None => { break; }
};
let val = match *val_str {
Some(ref v) if v.starts_with("0x") => Some(Bytes::from_str(v).map_err(Error::custom)?),
Some(ref v) if v.starts_with("0x") => Some(Bytes::from_str(v).map_err(V::Error::custom)?),
Some(ref v) => Some(Bytes::new(v.clone().into_bytes())),
None => None,
};
@@ -104,8 +107,6 @@ impl Visitor for InputVisitor {
result.insert(key, val);
}
visitor.end()?;
let input = Input {
data: result
};