Skip to content

Commit

Permalink
chore(consensus): test use Vec::with_capacity (#1476)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg authored Oct 15, 2024
1 parent f37ac30 commit e0715bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion crates/consensus/src/receipt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ mod tests {
}
.with_bloom();

let mut data = vec![];
let len = receipt.length();
let mut data = Vec::with_capacity(receipt.length());

receipt.encode(&mut data);
assert_eq!(data.len(), len);
let decoded = ReceiptWithBloom::decode(&mut &data[..]).unwrap();

// receipt.clone().to_compact(&mut data);
Expand Down
5 changes: 3 additions & 2 deletions crates/consensus/src/transaction/eip4844.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,9 +1073,10 @@ mod tests {
let actual_envelope: TxEnvelope = actual_signed.into();

// now encode the transaction and check the length
let mut buf = Vec::new();
let len = expected_envelope.length();
let mut buf = Vec::with_capacity(len);
expected_envelope.encode(&mut buf);
assert_eq!(buf.len(), expected_envelope.length());
assert_eq!(buf.len(), len);

// ensure it's also the same size that `actual` claims to be, since we just changed the
// sidecar values.
Expand Down

0 comments on commit e0715bf

Please sign in to comment.