From 9c85e4d305a569d1f7a23b5878dabb5b3ba2fad2 Mon Sep 17 00:00:00 2001 From: debris Date: Wed, 2 Dec 2015 17:52:06 +0100 Subject: [PATCH] commented out tests --- src/triehash.rs | 86 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 74 insertions(+), 12 deletions(-) diff --git a/src/triehash.rs b/src/triehash.rs index 778dc7f17..ab0c75683 100644 --- a/src/triehash.rs +++ b/src/triehash.rs @@ -278,7 +278,7 @@ fn test_hex_prefix_encode() { #[cfg(test)] mod tests { use std::str::FromStr; - use std::collections::BTreeMap; + use std::collections::HashMap; use rustc_serialize::hex::FromHex; use rustc_serialize::json::Json; use bytes::*; @@ -379,18 +379,80 @@ mod tests { 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"); + //fn hex_or_string(s: &str) -> Vec { + //match s.starts_with("0x") { + //true => s[2..].from_hex().unwrap(), + //false => From::from(s) + //} + //} + + //pub fn yield_json_trietest(data: &[u8], name: &str, insert: &mut I, remove: &mut R) -> H256 where I: FnMut(Vec, Vec), R: FnMut(Vec) { + ////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(); + //let s = String::from_bytes(data).unwrap(); + //let json = Json::from_str(&s).unwrap(); + //let obj = json.as_object().unwrap(); + //println!("here"); + + //let value = &obj[name]; + + //let i = &value["in"]; + //let o = &value["root"]; + + //let root_str = o.as_string().unwrap(); + + //println!("here2"); + //for i in i.as_array().unwrap().iter() { + //let key = hex_or_string(i[0].as_string().unwrap()); + + //match i[1].is_null() { + //true => remove(key), + //false => insert(key, hex_or_string(i[1].as_string().unwrap())) + //}; + //} + + //H256::from_str(&root_str[2..]).unwrap() + //} + + ////fn load_json_trietest(data: &[u8], name: &str) -> (Vec<(Vec, Vec)>, H256) { + ////use std::cell::RefCell; + //let map = RefCell::new(HashMap::new()); + //let root = yield_json_trietest(data, name, &mut | key, value | { + //map.borrow_mut().insert(key, value); + //}, &mut | key | { + //map.borrow_mut().remove(&key); + //}); + + //let res = map.into_inner() + //.into_iter() + //.map(|p| p) + //.collect(); + //(res, root) + //} + + //#[test] + //fn triehash_json_empty_values() { + //let (input, root) = load_json_trietest(include_bytes!("../tests/TrieTests/trietest.json"), "emptyValues"); + //assert_eq!(trie_root(input), root); + //} + + //#[test] + //fn triehash_json_branching_tests() { + //let (input, root) = load_json_trietest(include_bytes!("../tests/TrieTests/trietest.json"), "branchingTests"); + //assert_eq!(trie_root(input), root); + //} + + //#[test] + //fn triehash_json_jeff_tests() { + //let (input, root) = load_json_trietest(include_bytes!("../tests/TrieTests/trietest.json"), "jeff"); + //assert_eq!(trie_root(input), root); + //} + + ////#[test] + ////fn triehash_json_test1() { + //let (input, root) = load_json_trietest(include_bytes!("../tests/TrieTests/hex_encoded_securetrie_test.json"), "test1"); + //assert_eq!(trie_root(input), root); + //} - for (key, value) in obj.iter() { - println!("running test: {}", key); - } - assert!(false); - } }