refactor: rm redundant clones in tests (#11840)

This commit is contained in:
nk_ysg
2024-10-17 22:40:10 +08:00
committed by GitHub
parent 6ba4bbe4aa
commit 2131c87edb
4 changed files with 13 additions and 7 deletions

View File

@ -109,12 +109,14 @@ mod tests {
let mut receipts = Vec::new();
for block in &blocks {
receipts.reserve_exact(block.body.transactions.len());
for transaction in &block.body.transactions {
receipts
.push((receipts.len() as u64, random_receipt(&mut rng, transaction, Some(0))));
}
}
db.insert_receipts(receipts.clone()).expect("insert receipts");
let receipts_len = receipts.len();
db.insert_receipts(receipts).expect("insert receipts");
assert_eq!(
db.table::<tables::Transactions>().unwrap().len(),
@ -194,7 +196,7 @@ mod tests {
assert_eq!(
db.table::<tables::Receipts>().unwrap().len(),
receipts.len() - (last_pruned_tx_number + 1)
receipts_len - (last_pruned_tx_number + 1)
);
assert_eq!(
db.factory

View File

@ -263,6 +263,7 @@ mod tests {
let (deposit_contract_addr, _) = random_eoa_account(&mut rng);
for block in &blocks {
receipts.reserve_exact(block.body.size());
for (txi, transaction) in block.body.transactions.iter().enumerate() {
let mut receipt = random_receipt(&mut rng, transaction, Some(1));
receipt.logs.push(random_log(

View File

@ -110,6 +110,7 @@ mod tests {
let mut transaction_senders = Vec::new();
for block in &blocks {
transaction_senders.reserve_exact(block.body.transactions.len());
for transaction in &block.body.transactions {
transaction_senders.push((
transaction_senders.len() as u64,
@ -117,8 +118,8 @@ mod tests {
));
}
}
db.insert_transaction_senders(transaction_senders.clone())
.expect("insert transaction senders");
let transaction_senders_len = transaction_senders.len();
db.insert_transaction_senders(transaction_senders).expect("insert transaction senders");
assert_eq!(
db.table::<tables::Transactions>().unwrap().len(),
@ -202,7 +203,7 @@ mod tests {
assert_eq!(
db.table::<tables::TransactionSenders>().unwrap().len(),
transaction_senders.len() - (last_pruned_tx_number + 1)
transaction_senders_len - (last_pruned_tx_number + 1)
);
assert_eq!(
db.factory

View File

@ -140,11 +140,13 @@ mod tests {
let mut tx_hash_numbers = Vec::new();
for block in &blocks {
tx_hash_numbers.reserve_exact(block.body.transactions.len());
for transaction in &block.body.transactions {
tx_hash_numbers.push((transaction.hash, tx_hash_numbers.len() as u64));
}
}
db.insert_tx_hash_numbers(tx_hash_numbers.clone()).expect("insert tx hash numbers");
let tx_hash_numbers_len = tx_hash_numbers.len();
db.insert_tx_hash_numbers(tx_hash_numbers).expect("insert tx hash numbers");
assert_eq!(
db.table::<tables::Transactions>().unwrap().len(),
@ -228,7 +230,7 @@ mod tests {
assert_eq!(
db.table::<tables::TransactionHashNumbers>().unwrap().len(),
tx_hash_numbers.len() - (last_pruned_tx_number + 1)
tx_hash_numbers_len - (last_pruned_tx_number + 1)
);
assert_eq!(
db.factory