removed DecoderError::BadRlp
This commit is contained in:
parent
356be1c635
commit
aa02a71d09
@ -86,7 +86,6 @@ pub enum DecoderError {
|
|||||||
RlpIsTooShort,
|
RlpIsTooShort,
|
||||||
RlpExpectedToBeList,
|
RlpExpectedToBeList,
|
||||||
RlpExpectedToBeData,
|
RlpExpectedToBeData,
|
||||||
BadRlp,
|
|
||||||
}
|
}
|
||||||
impl StdError for DecoderError {
|
impl StdError for DecoderError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
@ -725,9 +724,9 @@ impl BasicDecoder {
|
|||||||
let header_len = 1 + len_of_len;
|
let header_len = 1 + len_of_len;
|
||||||
let value_len = try!(usize::from_bytes(&bytes[1..header_len]));
|
let value_len = try!(usize::from_bytes(&bytes[1..header_len]));
|
||||||
PayloadInfo::new(header_len, value_len)
|
PayloadInfo::new(header_len, value_len)
|
||||||
}
|
},
|
||||||
// we cant reach this place, but rust requires _ to be implemented
|
// we cant reach this place, but rust requires _ to be implemented
|
||||||
_ => return Err(DecoderError::BadRlp),
|
_ => { panic!(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
match item.header_len + item.value_len <= bytes.len() {
|
match item.header_len + item.value_len <= bytes.len() {
|
||||||
@ -753,7 +752,8 @@ impl Decoder for BasicDecoder {
|
|||||||
let len = try!(usize::from_bytes(&bytes[1..begin_of_value]));
|
let len = try!(usize::from_bytes(&bytes[1..begin_of_value]));
|
||||||
Ok(try!(f(&bytes[begin_of_value..begin_of_value + len])))
|
Ok(try!(f(&bytes[begin_of_value..begin_of_value + len])))
|
||||||
}
|
}
|
||||||
_ => Err(DecoderError::BadRlp),
|
// we are reading value, not a list!
|
||||||
|
_ => { panic!(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,7 +280,10 @@ fn test_hex_prefix_encode() {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use rustc_serialize::hex::FromHex;
|
use rustc_serialize::hex::FromHex;
|
||||||
|
use rustc_serialize::json::Json;
|
||||||
|
use bytes::*;
|
||||||
use hash::*;
|
use hash::*;
|
||||||
use triehash::*;
|
use triehash::*;
|
||||||
|
|
||||||
@ -377,4 +380,19 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(trie_root(v), H256::from_str("9f6221ebb8efe7cff60a716ecb886e67dd042014be444669f0159d8e68b42100").unwrap());
|
assert_eq!(trie_root(v), H256::from_str("9f6221ebb8efe7cff60a716ecb886e67dd042014be444669f0159d8e68b42100").unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_triehash_json_trietest_json() {
|
||||||
|
let data = include_bytes!("../tests/TrieTests/trietest.json");
|
||||||
|
|
||||||
|
let s = String::from_bytes(data).unwrap();
|
||||||
|
let json = Json::from_str(&s).unwrap();
|
||||||
|
let obj = json.as_object().unwrap();
|
||||||
|
|
||||||
|
for (key, value) in obj.iter() {
|
||||||
|
println!("running test: {}", key);
|
||||||
|
}
|
||||||
|
assert!(false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user