From 05f7e85d301c8400df7635c0236ca845d0237670 Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 3 Dec 2015 05:44:35 +0100 Subject: [PATCH 1/7] rlp tests, the beginning --- json-tests/json/rlp/README.md | 39 +++++++++++++++++++++++++ json-tests/json/rlp/catdog.json | 18 ++++++++++++ json-tests/src/lib.rs | 2 ++ json-tests/src/rlp.rs | 52 +++++++++++++++++++++++++++++++++ json-tests/src/trie.rs | 33 ++++----------------- json-tests/src/util.rs | 8 +++++ src/trie.rs | 2 +- 7 files changed, 126 insertions(+), 28 deletions(-) create mode 100644 json-tests/json/rlp/README.md create mode 100644 json-tests/json/rlp/catdog.json create mode 100644 json-tests/src/rlp.rs create mode 100644 json-tests/src/util.rs diff --git a/json-tests/json/rlp/README.md b/json-tests/json/rlp/README.md new file mode 100644 index 000000000..89cb072c7 --- /dev/null +++ b/json-tests/json/rlp/README.md @@ -0,0 +1,39 @@ +# Rlp tests guideline + +Rlp can be tested in various ways. It can encode/decode a value or an array of values. Let's start with encoding. + +Each operation must have field: + +- `operation` - `append`, `append_list`, `append_empty` or `append_raw` + +Additionally `append` and `append_raw` must additionally define a `value` field: + +- `value` - data + +Also `append_raw` and `append_list` requires `len` field + +- `len` - integer + +### Encoding Test Example + +```json +{ + "input": + [ + { + "operation": "append_list", + "len": 2 + }, + { + "operation": "append", + "value": "cat" + }, + { + "operation": "append", + "value": "dog" + } + ] + "output": "0xc88363617183646f67" +} +``` + diff --git a/json-tests/json/rlp/catdog.json b/json-tests/json/rlp/catdog.json new file mode 100644 index 000000000..352b24892 --- /dev/null +++ b/json-tests/json/rlp/catdog.json @@ -0,0 +1,18 @@ +{ + "input": + [ + { + "operation": "append_list", + "len": 2 + }, + { + "operation": "append", + "value": "cat" + }, + { + "operation": "append", + "value": "dog" + } + ] + "output": "0xc88363617183646f67" +} diff --git a/json-tests/src/lib.rs b/json-tests/src/lib.rs index 8a800e8f9..0fb1b091a 100644 --- a/json-tests/src/lib.rs +++ b/json-tests/src/lib.rs @@ -8,7 +8,9 @@ use std::fs::File; use glob::glob; use rustc_serialize::*; +mod util; pub mod trie; +pub mod rlp; pub trait JsonTest: Sized { type Input; diff --git a/json-tests/src/rlp.rs b/json-tests/src/rlp.rs new file mode 100644 index 000000000..bf6131b5b --- /dev/null +++ b/json-tests/src/rlp.rs @@ -0,0 +1,52 @@ +//! json rlp tests +use rustc_serialize::*; +use super::{JsonTest, JsonLoader}; +use util::*; + +pub enum Operation { + Append(Vec), + AppendList(usize), + AppendRaw(Vec, usize), + AppendEmpty +} + +impl Into for json::Json { + fn into(self) -> Operation { + let obj = self.as_object().unwrap(); + match obj["operation"].as_string().unwrap().as_ref() { + "append" => Operation::Append(hex_or_string(obj["value"].as_string().unwrap())), + "append_list" => Operation::AppendList(obj["len"].as_u64().unwrap() as usize), + "append_raw" => Operation::AppendRaw(hex_or_string(obj["value"].as_string().unwrap()), obj["len"].as_u64().unwrap() as usize), + "append_empty" => Operation::AppendEmpty, + other => { panic!("Unsupported opertation: {}", other); } + } + } +} + +pub struct RlpStreamTest { + loader: JsonLoader +} + +impl JsonTest for RlpStreamTest { + type Input = Vec; + type Output = Vec; + + fn new(data: &[u8]) -> Self { + RlpStreamTest { + loader: JsonLoader::new(data) + } + } + + fn input(&self) -> Self::Input { + self.loader.input().as_array().unwrap() + .iter() + .cloned() + .map(|i| i.into()) + .collect() + } + + fn output(&self) -> Self::Output { + hex_or_string(self.loader.output().as_string().unwrap()) + } +} + diff --git a/json-tests/src/trie.rs b/json-tests/src/trie.rs index 827bf8c9a..bc65e9db9 100644 --- a/json-tests/src/trie.rs +++ b/json-tests/src/trie.rs @@ -1,27 +1,12 @@ //! json trie tests use std::collections::HashMap; use rustc_serialize::*; -use rustc_serialize::hex::FromHex; use super::{JsonTest, JsonLoader}; - -enum OperationType { - Insert, - Remove -} - -impl Decodable for OperationType { - fn decode(d: &mut D) -> Result where D: Decoder { - match try!(String::decode(d)).as_ref() { - "insert" => Ok(OperationType::Insert), - "remove" => Ok(OperationType::Remove), - other => panic!("invalid operation type: {}", other) - } - } -} +use util::*; #[derive(RustcDecodable)] struct RawOperation { - operation: OperationType, + operation: String, key: String, value: Option } @@ -31,18 +16,12 @@ pub enum Operation { Remove(Vec) } -fn hex_or_string(s: &str) -> Vec { - match s.starts_with("0x") { - true => s[2..].from_hex().unwrap(), - false => From::from(s) - } -} - impl Into for RawOperation { fn into(self) -> Operation { - match self.operation { - OperationType::Insert => Operation::Insert(hex_or_string(&self.key), hex_or_string(&self.value.unwrap())), - OperationType::Remove => Operation::Remove(hex_or_string(&self.key)) + match self.operation.as_ref() { + "insert" => Operation::Insert(hex_or_string(&self.key), hex_or_string(&self.value.unwrap())), + "remove" => Operation::Remove(hex_or_string(&self.key)), + other => panic!("invalid operation type: {}", other) } } } diff --git a/json-tests/src/util.rs b/json-tests/src/util.rs new file mode 100644 index 000000000..f9d1e4eab --- /dev/null +++ b/json-tests/src/util.rs @@ -0,0 +1,8 @@ +use rustc_serialize::hex::FromHex; + +pub fn hex_or_string(s: &str) -> Vec { + match s.starts_with("0x") { + true => s[2..].from_hex().unwrap(), + false => From::from(s) + } +} diff --git a/src/trie.rs b/src/trie.rs index 081fcfcff..9dd12d8a5 100644 --- a/src/trie.rs +++ b/src/trie.rs @@ -742,7 +742,7 @@ impl Trie for TrieDB { #[cfg(test)] mod tests { extern crate json_tests; - use self::json_tests::*; + use self::json_tests::{trie, execute_tests_from_directory}; use rustc_serialize::hex::FromHex; use triehash::*; use hash::*; From 9f9c508ebd9306aeb5e892c52583a71cf2dfc792 Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 3 Dec 2015 05:47:07 +0100 Subject: [PATCH 2/7] fixed example .json files --- json-tests/json/rlp/README.md | 2 +- json-tests/json/rlp/catdog.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/json-tests/json/rlp/README.md b/json-tests/json/rlp/README.md index 89cb072c7..ab8b01020 100644 --- a/json-tests/json/rlp/README.md +++ b/json-tests/json/rlp/README.md @@ -32,7 +32,7 @@ Also `append_raw` and `append_list` requires `len` field "operation": "append", "value": "dog" } - ] + ], "output": "0xc88363617183646f67" } ``` diff --git a/json-tests/json/rlp/catdog.json b/json-tests/json/rlp/catdog.json index 352b24892..ed4c02602 100644 --- a/json-tests/json/rlp/catdog.json +++ b/json-tests/json/rlp/catdog.json @@ -13,6 +13,6 @@ "operation": "append", "value": "dog" } - ] + ], "output": "0xc88363617183646f67" } From 84eb30a133653a9519be13b34e2e4e89234d984b Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 3 Dec 2015 06:06:42 +0100 Subject: [PATCH 3/7] empty lists tests --- json-tests/json/rlp/catdog.json | 2 +- json-tests/json/rlp/empty_lists.json | 38 ++++++++++++++++ src/rlp.rs | 24 ++++++++++ src/trie.rs | 65 ---------------------------- 4 files changed, 63 insertions(+), 66 deletions(-) create mode 100644 json-tests/json/rlp/empty_lists.json diff --git a/json-tests/json/rlp/catdog.json b/json-tests/json/rlp/catdog.json index ed4c02602..724329784 100644 --- a/json-tests/json/rlp/catdog.json +++ b/json-tests/json/rlp/catdog.json @@ -14,5 +14,5 @@ "value": "dog" } ], - "output": "0xc88363617183646f67" + "output": "0xc88363617483646f67" } diff --git a/json-tests/json/rlp/empty_lists.json b/json-tests/json/rlp/empty_lists.json new file mode 100644 index 000000000..5ac649c2c --- /dev/null +++ b/json-tests/json/rlp/empty_lists.json @@ -0,0 +1,38 @@ +{ + "input": + [ + { + "operation": "append_list", + "len": 3 + }, + { + "operation": "append_list", + "len": 0 + }, + { + "operation": "append_list", + "len": 1 + }, + { + "operation": "append_list", + "len": 0 + }, + { + "operation": "append_list", + "len": 2 + }, + { + "operation": "append_list", + "len": 0 + }, + { + "operation": "append_list", + "len": 1 + }, + { + "operation": "append_list", + "len": 0 + } + ], + "output": "0xc7c0c1c0c3c0c1c0" +} diff --git a/src/rlp.rs b/src/rlp.rs index b055632b1..8cb5f2b9b 100644 --- a/src/rlp.rs +++ b/src/rlp.rs @@ -1098,6 +1098,9 @@ impl Encoder for BasicEncoder { #[cfg(test)] mod tests { + extern crate json_tests; + use self::json_tests::execute_tests_from_directory; + use self::json_tests::rlp as rlptest; use std::{fmt, cmp}; use std::str::FromStr; use rlp; @@ -1496,4 +1499,25 @@ mod tests { let view = View::new(&data); let _data_slice = view.offset(1).data(); } + + #[test] + fn test_rlp_json() { + println!("Json rlp test: "); + execute_tests_from_directory::("json-tests/json/rlp/*.json", &mut | file, input, output | { + println!("file: {}", file); + + let mut stream = RlpStream::new(); + for operation in input.into_iter() { + match operation { + rlptest::Operation::Append(ref v) => stream.append(v), + rlptest::Operation::AppendList(len) => stream.append_list(len), + rlptest::Operation::AppendRaw(ref raw, len) => stream.append_raw(raw, len), + rlptest::Operation::AppendEmpty => stream.append_empty_data() + }; + } + + assert_eq!(stream.out(), output); + }); + } + } diff --git a/src/trie.rs b/src/trie.rs index 9dd12d8a5..674d22488 100644 --- a/src/trie.rs +++ b/src/trie.rs @@ -743,7 +743,6 @@ impl Trie for TrieDB { mod tests { extern crate json_tests; use self::json_tests::{trie, execute_tests_from_directory}; - use rustc_serialize::hex::FromHex; use triehash::*; use hash::*; use super::*; @@ -969,24 +968,6 @@ mod tests { //assert!(false); } - fn test_all(v: Vec<(Vec, Vec)>) { - let mut t = TrieDB::new_memory(); - - for i in 0..v.len() { - let key: &[u8]= &v[i].0; - let val: &[u8] = &v[i].1; - t.insert(&key, &val); - } - -// trace!("{:?}", t); -// println!("{:?}", t); - - // check lifetime -// let _q = t.at(&[b'd', b'o']).unwrap(); - - assert_eq!(*t.root(), trie_root(v)); - } - fn random_key() -> Vec { let chars = b"abcdefgrstuvwABCDEFGRSTUVW"; let mut ret: Vec = Vec::new(); @@ -1041,52 +1022,6 @@ mod tests { t } - #[test] - fn test_at_dog() { - env_logger::init().ok(); - let v = vec![ - (From::from("do"), From::from("verb")), - (From::from("dog"), From::from("puppy")), - (From::from("doge"), From::from("coin")), - (From::from("horse"), From::from("stallion")), - ]; - - test_all(v); - } - - #[test] - fn test_more_data() { - let v = vec![ - - ("0000000000000000000000000000000000000000000000000000000000000045".from_hex().unwrap(), - "22b224a1420a802ab51d326e29fa98e34c4f24ea".from_hex().unwrap()), - - ("0000000000000000000000000000000000000000000000000000000000000046".from_hex().unwrap(), - "67706c2076330000000000000000000000000000000000000000000000000000".from_hex().unwrap()), - - ("000000000000000000000000697c7b8c961b56f675d570498424ac8de1a918f6".from_hex().unwrap(), - "6f6f6f6820736f2067726561742c207265616c6c6c793f000000000000000000".from_hex().unwrap()), - - ("0000000000000000000000007ef9e639e2733cb34e4dfc576d4b23f72db776b2".from_hex().unwrap(), - "4655474156000000000000000000000000000000000000000000000000000000".from_hex().unwrap()), - - ("000000000000000000000000ec4f34c97e43fbb2816cfd95e388353c7181dab1".from_hex().unwrap(), - "4e616d6552656700000000000000000000000000000000000000000000000000".from_hex().unwrap()), - - ("4655474156000000000000000000000000000000000000000000000000000000".from_hex().unwrap(), - "7ef9e639e2733cb34e4dfc576d4b23f72db776b2".from_hex().unwrap()), - - ("4e616d6552656700000000000000000000000000000000000000000000000000".from_hex().unwrap(), - "ec4f34c97e43fbb2816cfd95e388353c7181dab1".from_hex().unwrap()), - - ("6f6f6f6820736f2067726561742c207265616c6c6c793f000000000000000000".from_hex().unwrap(), - "697c7b8c961b56f675d570498424ac8de1a918f6".from_hex().unwrap()) - - ]; - - test_all(v); - } - #[test] fn test_trie_json() { println!("Json trie test: "); From dc316dcfeb04619d659ac8768b62eaf595f1156f Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 3 Dec 2015 06:13:27 +0100 Subject: [PATCH 4/7] additional simple json tests --- json-tests/json/rlp/empty.json | 9 +++++++++ json-tests/json/rlp/integer.json | 10 ++++++++++ 2 files changed, 19 insertions(+) create mode 100644 json-tests/json/rlp/empty.json create mode 100644 json-tests/json/rlp/integer.json diff --git a/json-tests/json/rlp/empty.json b/json-tests/json/rlp/empty.json new file mode 100644 index 000000000..19cbf4185 --- /dev/null +++ b/json-tests/json/rlp/empty.json @@ -0,0 +1,9 @@ +{ + "input": + [ + { + "operation": "append_empty" + } + ], + "output": "0x80" +} diff --git a/json-tests/json/rlp/integer.json b/json-tests/json/rlp/integer.json new file mode 100644 index 000000000..1effa4a1e --- /dev/null +++ b/json-tests/json/rlp/integer.json @@ -0,0 +1,10 @@ +{ + "input": + [ + { + "operation": "append", + "value": "0x0400" + } + ], + "output": "0x820400" +} From 611226c117ca773b9a3ef43cc4aa390e82e22cb9 Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 3 Dec 2015 11:36:20 +0100 Subject: [PATCH 5/7] small changes in tests --- json-tests/json/rlp/{ => stream}/catdog.json | 0 json-tests/json/rlp/{ => stream}/empty.json | 0 .../json/rlp/{ => stream}/empty_lists.json | 0 json-tests/json/rlp/{ => stream}/integer.json | 0 .../json/rlp/stream/list_of_empty_data.json | 22 +++++++++++++++++++ .../json/rlp/stream/list_of_empty_data2.json | 19 ++++++++++++++++ src/rlp.rs | 16 +++++++++++++- 7 files changed, 56 insertions(+), 1 deletion(-) rename json-tests/json/rlp/{ => stream}/catdog.json (100%) rename json-tests/json/rlp/{ => stream}/empty.json (100%) rename json-tests/json/rlp/{ => stream}/empty_lists.json (100%) rename json-tests/json/rlp/{ => stream}/integer.json (100%) create mode 100644 json-tests/json/rlp/stream/list_of_empty_data.json create mode 100644 json-tests/json/rlp/stream/list_of_empty_data2.json diff --git a/json-tests/json/rlp/catdog.json b/json-tests/json/rlp/stream/catdog.json similarity index 100% rename from json-tests/json/rlp/catdog.json rename to json-tests/json/rlp/stream/catdog.json diff --git a/json-tests/json/rlp/empty.json b/json-tests/json/rlp/stream/empty.json similarity index 100% rename from json-tests/json/rlp/empty.json rename to json-tests/json/rlp/stream/empty.json diff --git a/json-tests/json/rlp/empty_lists.json b/json-tests/json/rlp/stream/empty_lists.json similarity index 100% rename from json-tests/json/rlp/empty_lists.json rename to json-tests/json/rlp/stream/empty_lists.json diff --git a/json-tests/json/rlp/integer.json b/json-tests/json/rlp/stream/integer.json similarity index 100% rename from json-tests/json/rlp/integer.json rename to json-tests/json/rlp/stream/integer.json diff --git a/json-tests/json/rlp/stream/list_of_empty_data.json b/json-tests/json/rlp/stream/list_of_empty_data.json new file mode 100644 index 000000000..c5b898f25 --- /dev/null +++ b/json-tests/json/rlp/stream/list_of_empty_data.json @@ -0,0 +1,22 @@ +{ + "input": + [ + { + "operation": "append_list", + "len": 3 + }, + { + "operation": "append", + "value": "" + }, + { + "operation": "append", + "value": "" + }, + { + "operation": "append", + "value": "" + } + ], + "output": "0xc3808080" +} diff --git a/json-tests/json/rlp/stream/list_of_empty_data2.json b/json-tests/json/rlp/stream/list_of_empty_data2.json new file mode 100644 index 000000000..76043af91 --- /dev/null +++ b/json-tests/json/rlp/stream/list_of_empty_data2.json @@ -0,0 +1,19 @@ +{ + "input": + [ + { + "operation": "append_list", + "len": 3 + }, + { + "operation": "append_empty" + }, + { + "operation": "append_empty" + }, + { + "operation": "append_empty" + } + ], + "output": "0xc3808080" +} diff --git a/src/rlp.rs b/src/rlp.rs index 8cb5f2b9b..5f5c90590 100644 --- a/src/rlp.rs +++ b/src/rlp.rs @@ -1335,6 +1335,20 @@ mod tests { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80]); } + #[test] + fn rlp_stream_list4() { + let mut stream = RlpStream::new(); + stream.append_list(17); + let v: Vec = vec![]; + for _ in 0..17 { + stream.append(&v); + } + let out = stream.out(); + assert_eq!(out, vec![0xd1, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80]); + } + #[test] fn rlp_stream_list3() { let mut stream = RlpStream::new(); @@ -1503,7 +1517,7 @@ mod tests { #[test] fn test_rlp_json() { println!("Json rlp test: "); - execute_tests_from_directory::("json-tests/json/rlp/*.json", &mut | file, input, output | { + execute_tests_from_directory::("json-tests/json/rlp/stream/*.json", &mut | file, input, output | { println!("file: {}", file); let mut stream = RlpStream::new(); From 38a3650ba95741e9e60dcb442a53a1010b272aa9 Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 3 Dec 2015 12:00:57 +0100 Subject: [PATCH 6/7] few additional json tests --- json-tests/json/.DS_Store | Bin 0 -> 6148 bytes json-tests/json/rlp/stream/bytestring0.json | 10 + json-tests/json/rlp/stream/bytestring1.json | 10 + json-tests/json/rlp/stream/bytestring7.json | 10 + json-tests/json/rlp/stream/catdog.json | 12 +- json-tests/json/rlp/stream/longlist.json | 521 ++++++++++++++++++++ json-tests/json/rlp/stream/longstring.json | 10 + 7 files changed, 563 insertions(+), 10 deletions(-) create mode 100644 json-tests/json/.DS_Store create mode 100644 json-tests/json/rlp/stream/bytestring0.json create mode 100644 json-tests/json/rlp/stream/bytestring1.json create mode 100644 json-tests/json/rlp/stream/bytestring7.json create mode 100644 json-tests/json/rlp/stream/longlist.json create mode 100644 json-tests/json/rlp/stream/longstring.json diff --git a/json-tests/json/.DS_Store b/json-tests/json/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5ddc63de7e78f0f09186cf46a2ff1cf2b9cae2aa GIT binary patch literal 6148 zcmeH~Jr2S!425mVfW*>~F$)La1`&c2Z~+8}2?+#Z&(V4QSt!h?LeG-@#ZIlZZ)j=} z(e?AR66r-`1~vIYIqf#4$mI7QhFYo8^+Vg;}!TM!kPMk^St>SKu2 zy&WuhT}`%Nw2S8Op?PPuDF&v|E?SVlv^p5502LT0&_&+c`M-sKoBszbOsN1B_%j7` zy4h{kc&R*FKVHx3`>fi!!9l+q;q4~?i5 Date: Thu, 3 Dec 2015 13:11:02 +0100 Subject: [PATCH 7/7] removed duplicate tests --- src/rlp.rs | 99 ++---------------------------------------------------- 1 file changed, 2 insertions(+), 97 deletions(-) diff --git a/src/rlp.rs b/src/rlp.rs index 5f5c90590..076111b23 100644 --- a/src/rlp.rs +++ b/src/rlp.rs @@ -1259,7 +1259,7 @@ mod tests { run_encode_tests(tests); } - /// Vec is treated as a single value + /// Vec (Bytes) is treated as a single value #[test] fn encode_vector_u8() { let tests = vec![ @@ -1295,74 +1295,6 @@ mod tests { run_encode_tests(tests); } - #[test] - fn encode_bytes() { - let vec = vec![0u8]; - let slice: &[u8] = &vec; - let res = rlp::encode(&slice); - assert_eq!(res, vec![0u8]); - } - - #[test] - fn rlp_stream() { - let mut stream = RlpStream::new_list(2); - stream.append(&"cat").append(&"dog"); - let out = stream.out(); - assert_eq!(out, - vec![0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g']); - } - - #[test] - fn rlp_stream_list() { - let mut stream = RlpStream::new_list(3); - stream.append_list(0); - stream.append_list(1).append_list(0); - stream.append_list(2).append_list(0).append_list(1).append_list(0); - let out = stream.out(); - assert_eq!(out, vec![0xc7, 0xc0, 0xc1, 0xc0, 0xc3, 0xc0, 0xc1, 0xc0]); - } - - #[test] - fn rlp_stream_list2() { - let mut stream = RlpStream::new(); - stream.append_list(17); - for _ in 0..17 { - stream.append(&""); - } - let out = stream.out(); - assert_eq!(out, vec![0xd1, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80]); - } - - #[test] - fn rlp_stream_list4() { - let mut stream = RlpStream::new(); - stream.append_list(17); - let v: Vec = vec![]; - for _ in 0..17 { - stream.append(&v); - } - let out = stream.out(); - assert_eq!(out, vec![0xd1, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80]); - } - - #[test] - fn rlp_stream_list3() { - let mut stream = RlpStream::new(); - stream.append_list(17); - - let mut res = vec![0xf8, 0x44]; - for _ in 0..17 { - stream.append(&"aaa"); - res.extend(vec![0x83, b'a', b'a', b'a']); - } - let out = stream.out(); - assert_eq!(out, res); - } - struct DTestPair(T, Vec) where T: rlp::Decodable + fmt::Debug + cmp::Eq; fn run_decode_tests(tests: Vec>) where T: rlp::Decodable + fmt::Debug + cmp::Eq { @@ -1372,7 +1304,7 @@ mod tests { } } - /// Vec is treated as a single value + /// Vec (Bytes) is treated as a single value #[test] fn decode_vector_u8() { let tests = vec![ @@ -1487,33 +1419,6 @@ mod tests { run_decode_tests(tests); } - #[test] - fn test_view() { - struct View<'a> { - bytes: &'a [u8] - } - - impl <'a, 'view> View<'a> where 'a: 'view { - fn new(bytes: &'a [u8]) -> View<'a> { - View { - bytes: bytes - } - } - - fn offset(&'view self, len: usize) -> View<'a> { - View::new(&self.bytes[len..]) - } - - fn data(&'view self) -> &'a [u8] { - self.bytes - } - } - - let data = vec![0, 1, 2, 3]; - let view = View::new(&data); - let _data_slice = view.offset(1).data(); - } - #[test] fn test_rlp_json() { println!("Json rlp test: ");