fix: use correct payload length for blob pooled txs (#4972)

This commit is contained in:
Dan Cline
2023-10-10 17:02:26 -04:00
committed by GitHub
parent c6531b48f8
commit 39f566e7cc
4 changed files with 64 additions and 10 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
//! Decoding tests for [`PooledTransactions`]
use alloy_rlp::Decodable;
use reth_eth_wire::PooledTransactions;
use alloy_rlp::{Decodable, Encodable};
use reth_eth_wire::{EthVersion, PooledTransactions, ProtocolMessage};
use reth_primitives::{hex, Bytes, PooledTransactionsElement};
use std::{fs, path::PathBuf};
@ -10,7 +10,26 @@ fn decode_pooled_transactions_data() {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("testdata/pooled_transactions_with_blob");
let data = fs::read_to_string(network_data_path).expect("Unable to read file");
let hex_data = hex::decode(data.trim()).unwrap();
let _txs = PooledTransactions::decode(&mut &hex_data[..]).unwrap();
let txs = PooledTransactions::decode(&mut &hex_data[..]).unwrap();
// do a roundtrip test
let mut buf = Vec::new();
txs.encode(&mut buf);
if hex_data != buf {
panic!("mixed pooled transaction roundtrip failed");
}
// now do another decoding, on what we encoded - this should succeed
let _txs2 = PooledTransactions::decode(&mut &buf[..]).unwrap();
}
#[test]
fn decode_request_pair_pooled_blob_transactions() {
let network_data_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("testdata/request_pair_pooled_blob_transactions");
let data = fs::read_to_string(network_data_path).expect("Unable to read file");
let hex_data = hex::decode(data.trim()).unwrap();
let _txs = ProtocolMessage::decode_message(EthVersion::Eth68, &mut &hex_data[..]).unwrap();
}
#[test]