From 611226c117ca773b9a3ef43cc4aa390e82e22cb9 Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 3 Dec 2015 11:36:20 +0100 Subject: [PATCH] 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();