chore(clippy): make clippy happy (#2403)

This commit is contained in:
Matthias Seitz
2023-04-26 12:31:25 +02:00
committed by GitHub
parent 4763aad11e
commit 04947d2c49
3 changed files with 39 additions and 54 deletions

View File

@ -47,6 +47,7 @@ macro_rules! fuzz_type_and_name {
#[allow(non_snake_case)]
#[cfg(any(test, feature = "bench"))]
pub mod fuzz_rlp {
use crate::roundtrip_encoding;
use reth_codecs::derive_arbitrary;
use reth_eth_wire::{
BlockBodies, BlockHeaders, DisconnectReason, GetBlockBodies, GetBlockHeaders, GetNodeData,
@ -59,7 +60,19 @@ pub mod fuzz_rlp {
use serde::{Deserialize, Serialize};
use test_fuzz::test_fuzz;
use crate::roundtrip_encoding;
// manually test Ping and Pong which are not covered by the above
/// Tests the round-trip encoding of Ping
#[test]
fn roundtrip_ping() {
roundtrip_encoding::<P2PMessage>(P2PMessage::Ping)
}
/// Tests the round-trip encoding of Pong
#[test]
fn roundtrip_pong() {
roundtrip_encoding::<P2PMessage>(P2PMessage::Pong)
}
// p2p subprotocol messages
@ -146,18 +159,4 @@ pub mod fuzz_rlp {
fuzz_type_and_name!(GetReceipts, fuzz_GetReceipts);
fuzz_type_and_name!(Receipts, fuzz_Receipts);
fuzz_type_and_name!(TransactionSigned, fuzz_TransactionSigned);
// manually test Ping and Pong which are not covered by the above
/// Tests the round-trip encoding of Ping
#[test]
fn roundtrip_ping() {
roundtrip_encoding::<P2PMessage>(P2PMessage::Ping)
}
/// Tests the round-trip encoding of Pong
#[test]
fn roundtrip_pong() {
roundtrip_encoding::<P2PMessage>(P2PMessage::Pong)
}
}

View File

@ -341,7 +341,7 @@ mod tests {
let first_account = cursor.seek(H256::default()).unwrap();
assert_eq!(first_account, expected.next());
while let Some(expected) = expected.next() {
for expected in expected {
let next_cursor_account = cursor.next().unwrap();
assert_eq!(next_cursor_account, Some(expected));
}
@ -363,7 +363,7 @@ mod tests {
let first_storage = cursor.seek(account, H256::default()).unwrap();
assert_eq!(first_storage.map(|e| (e.key, e.value)), expected_storage.next());
while let Some(expected_entry) = expected_storage.next() {
for expected_entry in expected_storage {
let next_cursor_storage = cursor.next().unwrap();
assert_eq!(next_cursor_storage.map(|e| (e.key, e.value)), Some(expected_entry));
}
@ -374,9 +374,8 @@ mod tests {
#[test]
fn post_state_only_accounts() {
let accounts = Vec::from_iter(
(1..11).into_iter().map(|key| (H256::from_low_u64_be(key), Account::default())),
);
let accounts =
Vec::from_iter((1..11).map(|key| (H256::from_low_u64_be(key), Account::default())));
let post_state = HashedPostState {
accounts: BTreeMap::from_iter(
accounts.iter().map(|(key, account)| (*key, Some(*account))),
@ -393,9 +392,8 @@ mod tests {
#[test]
fn db_only_accounts() {
let accounts = Vec::from_iter(
(1..11).into_iter().map(|key| (H256::from_low_u64_be(key), Account::default())),
);
let accounts =
Vec::from_iter((1..11).map(|key| (H256::from_low_u64_be(key), Account::default())));
let db = create_test_rw_db();
db.update(|tx| {
@ -414,9 +412,8 @@ mod tests {
#[test]
fn account_cursor_correct_order() {
// odd keys are in post state, even keys are in db
let accounts = Vec::from_iter(
(1..111).into_iter().map(|key| (H256::from_low_u64_be(key), Account::default())),
);
let accounts =
Vec::from_iter((1..111).map(|key| (H256::from_low_u64_be(key), Account::default())));
let db = create_test_rw_db();
db.update(|tx| {
@ -444,9 +441,8 @@ mod tests {
#[test]
fn removed_accounts_are_omitted() {
// odd keys are in post state, even keys are in db
let accounts = Vec::from_iter(
(1..111).into_iter().map(|key| (H256::from_low_u64_be(key), Account::default())),
);
let accounts =
Vec::from_iter((1..111).map(|key| (H256::from_low_u64_be(key), Account::default())));
// accounts 5, 9, 11 should be considered removed from post state
let removed_keys = Vec::from_iter([5, 9, 11].into_iter().map(H256::from_low_u64_be));
@ -476,7 +472,7 @@ mod tests {
#[test]
fn post_state_accounts_take_precedence() {
let accounts =
Vec::from_iter((1..10).into_iter().map(|key| {
Vec::from_iter((1..10).map(|key| {
(H256::from_low_u64_be(key), Account { nonce: key, ..Default::default() })
}));
@ -550,9 +546,8 @@ mod tests {
assert!(cursor.is_empty(address).unwrap());
}
let db_storage = BTreeMap::from_iter(
(0..10).into_iter().map(|key| (H256::from_low_u64_be(key), U256::from(key))),
);
let db_storage =
BTreeMap::from_iter((0..10).map(|key| (H256::from_low_u64_be(key), U256::from(key))));
db.update(|tx| {
for (slot, value) in db_storage.iter() {
// insert zero value accounts to the database
@ -611,12 +606,10 @@ mod tests {
#[test]
fn storage_cursor_correct_order() {
let address = H256::random();
let db_storage = BTreeMap::from_iter(
(0..10).into_iter().map(|key| (H256::from_low_u64_be(key), U256::from(key))),
);
let post_state_storage = BTreeMap::from_iter(
(10..20).into_iter().map(|key| (H256::from_low_u64_be(key), U256::from(key))),
);
let db_storage =
BTreeMap::from_iter((0..10).map(|key| (H256::from_low_u64_be(key), U256::from(key))));
let post_state_storage =
BTreeMap::from_iter((10..20).map(|key| (H256::from_low_u64_be(key), U256::from(key))));
let db = create_test_rw_db();
db.update(|tx| {
@ -650,12 +643,10 @@ mod tests {
#[test]
fn wiped_storage_is_discarded() {
let address = H256::random();
let db_storage = BTreeMap::from_iter(
(0..10).into_iter().map(|key| (H256::from_low_u64_be(key), U256::from(key))),
);
let post_state_storage = BTreeMap::from_iter(
(10..20).into_iter().map(|key| (H256::from_low_u64_be(key), U256::from(key))),
);
let db_storage =
BTreeMap::from_iter((0..10).map(|key| (H256::from_low_u64_be(key), U256::from(key))));
let post_state_storage =
BTreeMap::from_iter((10..20).map(|key| (H256::from_low_u64_be(key), U256::from(key))));
let db = create_test_rw_db();
db.update(|tx| {
@ -687,9 +678,8 @@ mod tests {
#[test]
fn post_state_storages_take_precedence() {
let address = H256::random();
let storage = BTreeMap::from_iter(
(1..10).into_iter().map(|key| (H256::from_low_u64_be(key), U256::from(key))),
);
let storage =
BTreeMap::from_iter((1..10).map(|key| (H256::from_low_u64_be(key), U256::from(key))));
let db = create_test_rw_db();
db.update(|tx| {

View File

@ -1254,12 +1254,8 @@ mod tests {
}
fn extension_node_trie(tx: &mut Transaction<'_, Env<WriteMap>>) -> H256 {
let a = Account {
nonce: 0,
balance: U256::from(1u64),
bytecode_hash: Some(H256::random()),
..Default::default()
};
let a =
Account { nonce: 0, balance: U256::from(1u64), bytecode_hash: Some(H256::random()) };
let val = encode_account(a, None);
let mut hashed_accounts = tx.cursor_write::<tables::HashedAccount>().unwrap();