chore(db): Add tests and fuzz target to BlockNumHash (#130)

* add tests and fuzz target for BlockNumHash

* use block 1 for test_block_num_hash

* new clippy stds

* fmt
This commit is contained in:
joshieDo
2022-10-25 16:23:10 +08:00
committed by GitHub
parent 0998fc3eb7
commit 2a8189d7c9
22 changed files with 141 additions and 87 deletions

View File

@ -18,7 +18,7 @@ fn bench_encode(c: &mut Criterion) {
c.bench_function("encode_u64", |b| {
b.iter(|| {
let mut out = BytesMut::new();
let _ = 0x1023_4567_89ab_cdefu64.encode(&mut out);
0x1023_4567_89ab_cdefu64.encode(&mut out);
})
});
c.bench_function("encode_u256", |b| {

View File

@ -392,9 +392,9 @@ mod tests {
#[test]
fn rlp_strings() {
check_decode::<Bytes, _>(vec![
(Ok((&hex!("00")[..]).to_vec().into()), &hex!("00")[..]),
(Ok(hex!("00")[..].to_vec().into()), &hex!("00")[..]),
(
Ok((&hex!("6f62636465666768696a6b6c6d")[..]).to_vec().into()),
Ok(hex!("6f62636465666768696a6b6c6d")[..].to_vec().into()),
&hex!("8D6F62636465666768696A6B6C6D")[..],
),
(Err(DecodeError::UnexpectedList), &hex!("C0")[..]),

View File

@ -65,7 +65,7 @@ fn test_encode_item() {
let decoded = Decodable::decode(&mut &*expected).unwrap();
assert_eq!(item, decoded);
let mut rlp_view = Rlp::new(&*expected).unwrap();
let mut rlp_view = Rlp::new(&expected).unwrap();
assert_eq!(rlp_view.get_next().unwrap(), Some(item.a));
assert_eq!(rlp_view.get_next().unwrap(), Some(item.b));
assert_eq!(rlp_view.get_next().unwrap(), Some(item.c));