Add a test for decoding corrupt data (#8713)

This commit is contained in:
David 2018-05-28 16:41:08 +02:00 committed by Niklas Adolfsson
parent 5400447395
commit 3b083d545d

View File

@ -594,29 +594,27 @@ fn debug_output_supports_pretty_print() {
}"); }");
} }
// Test will work once https://github.com/paritytech/parity/pull/8527 is merged and rlp::decode returns Result instead of panicking #[test]
//#[test] fn test_lookup_with_corrupt_data_returns_decoder_error() {
//fn test_lookup_with_corrupt_data_returns_decoder_error() { use memorydb::*;
// use memorydb::*; use super::TrieMut;
// use super::TrieMut; use super::triedbmut::*;
// use super::triedbmut::*; use rlp;
// use rlp; use ethereum_types::H512;
// use ethereum_types::H512;
// let mut memdb = MemoryDB::new();
// let mut memdb = MemoryDB::new(); let mut root = H256::new();
// let mut root = H256::new(); {
// { let mut t = TrieDBMut::new(&mut memdb, &mut root);
// let mut t = TrieDBMut::new(&mut memdb, &mut root); t.insert(b"A", b"ABC").unwrap();
// t.insert(b"A", b"ABC").unwrap(); t.insert(b"B", b"ABCBA").unwrap();
// t.insert(b"B", b"ABCBA").unwrap(); }
// }
// let t = TrieDB::new(&memdb, &root).unwrap();
// let t = TrieDB::new(&memdb, &root).unwrap();
// // query for an invalid data type to trigger an error
// // query for an invalid data type to trigger an error let q = rlp::decode::<H512>;
// let q = rlp::decode::<H512>; let lookup = Lookup{ db: t.db, query: q, hash: root };
// let lookup = Lookup{ db: t.db, query: q, hash: root }; let query_result = lookup.look_up(NibbleSlice::new(b"A"));
// let query_result = lookup.look_up(NibbleSlice::new(b"A")); assert_eq!(query_result.unwrap().unwrap().unwrap_err(), rlp::DecoderError::RlpIsTooShort);
// let expected = Box::new(TrieError::DecoderError(::rlp::DecoderError::RlpIsTooShort)); }
// assert_eq!(query_result.unwrap_err(), expected);
//}