mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 09:08:05 -05:00
test: improve slow tests (#3487)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -68,11 +68,17 @@ impl From<Vec<H256>> for GetBlockBodies {
|
||||
|
||||
/// The response to [`GetBlockBodies`], containing the block bodies that the peer knows about if
|
||||
/// any were found.
|
||||
#[derive_arbitrary(rlp, 1)]
|
||||
#[derive_arbitrary(rlp, 16)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct BlockBodies(
|
||||
/// The requested block bodies, each of which should correspond to a hash in the request.
|
||||
#[cfg_attr(
|
||||
any(test, feature = "arbitrary"),
|
||||
proptest(
|
||||
strategy = "proptest::collection::vec(proptest::arbitrary::any::<BlockBody>(), 0..=20)"
|
||||
)
|
||||
)]
|
||||
pub Vec<BlockBody>,
|
||||
);
|
||||
|
||||
|
||||
@@ -17,11 +17,17 @@ pub struct GetReceipts(
|
||||
|
||||
/// The response to [`GetReceipts`], containing receipt lists that correspond to each block
|
||||
/// requested.
|
||||
#[derive_arbitrary(rlp, 1)]
|
||||
#[derive_arbitrary(rlp)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Receipts(
|
||||
/// Each receipt hash should correspond to a block hash in the request.
|
||||
#[cfg_attr(
|
||||
any(test, feature = "arbitrary"),
|
||||
proptest(
|
||||
strategy = "proptest::collection::vec(proptest::collection::vec(proptest::arbitrary::any::<ReceiptWithBloom>(), 0..=50), 0..=5)"
|
||||
)
|
||||
)]
|
||||
pub Vec<Vec<ReceiptWithBloom>>,
|
||||
);
|
||||
|
||||
|
||||
@@ -739,10 +739,28 @@ impl From<(BlockHash, BlockNumber)> for BlockNumHash {
|
||||
#[rlp(trailing)]
|
||||
pub struct BlockBody {
|
||||
/// Transactions in the block
|
||||
#[cfg_attr(
|
||||
any(test, feature = "arbitrary"),
|
||||
proptest(
|
||||
strategy = "proptest::collection::vec(proptest::arbitrary::any::<TransactionSigned>(), 0..=100)"
|
||||
)
|
||||
)]
|
||||
pub transactions: Vec<TransactionSigned>,
|
||||
/// Uncle headers for the given block
|
||||
#[cfg_attr(
|
||||
any(test, feature = "arbitrary"),
|
||||
proptest(
|
||||
strategy = "proptest::collection::vec(proptest::arbitrary::any::<Header>(), 0..=2)"
|
||||
)
|
||||
)]
|
||||
pub ommers: Vec<Header>,
|
||||
/// Withdrawals in the block.
|
||||
#[cfg_attr(
|
||||
any(test, feature = "arbitrary"),
|
||||
proptest(
|
||||
strategy = "proptest::option::of(proptest::collection::vec(proptest::arbitrary::any::<Withdrawal>(), 0..=16))"
|
||||
)
|
||||
)]
|
||||
pub withdrawals: Option<Vec<Withdrawal>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,12 @@ pub struct Log {
|
||||
/// Contract that emitted this log.
|
||||
pub address: Address,
|
||||
/// Topics of the log. The number of logs depend on what `LOG` opcode is used.
|
||||
#[cfg_attr(
|
||||
any(test, feature = "arbitrary"),
|
||||
proptest(
|
||||
strategy = "proptest::collection::vec(proptest::arbitrary::any::<H256>(), 0..=5)"
|
||||
)
|
||||
)]
|
||||
pub topics: Vec<H256>,
|
||||
/// Arbitrary length data.
|
||||
pub data: Bytes,
|
||||
|
||||
@@ -21,6 +21,12 @@ pub struct Receipt {
|
||||
/// Gas used
|
||||
pub cumulative_gas_used: u64,
|
||||
/// Log send from contracts.
|
||||
#[cfg_attr(
|
||||
any(test, feature = "arbitrary"),
|
||||
proptest(
|
||||
strategy = "proptest::collection::vec(proptest::arbitrary::any::<Log>(), 0..=20)"
|
||||
)
|
||||
)]
|
||||
pub logs: Vec<Log>,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use crate::{Address, H256};
|
||||
use revm_primitives::U256;
|
||||
|
||||
use reth_codecs::{main_codec, Compact};
|
||||
use reth_rlp::{RlpDecodable, RlpDecodableWrapper, RlpEncodable, RlpEncodableWrapper};
|
||||
use revm_primitives::U256;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A list of addresses and storage keys that the transaction plans to access.
|
||||
@@ -14,13 +13,27 @@ pub struct AccessListItem {
|
||||
/// Account addresses that would be loaded at the start of execution
|
||||
pub address: Address,
|
||||
/// Keys of storage that would be loaded at the start of execution
|
||||
#[cfg_attr(
|
||||
any(test, feature = "arbitrary"),
|
||||
proptest(
|
||||
strategy = "proptest::collection::vec(proptest::arbitrary::any::<H256>(), 0..=20)"
|
||||
)
|
||||
)]
|
||||
pub storage_keys: Vec<H256>,
|
||||
}
|
||||
|
||||
/// AccessList as defined in EIP-2930
|
||||
#[main_codec(rlp)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Default, RlpDecodableWrapper, RlpEncodableWrapper)]
|
||||
pub struct AccessList(pub Vec<AccessListItem>);
|
||||
pub struct AccessList(
|
||||
#[cfg_attr(
|
||||
any(test, feature = "arbitrary"),
|
||||
proptest(
|
||||
strategy = "proptest::collection::vec(proptest::arbitrary::any::<AccessListItem>(), 0..=20)"
|
||||
)
|
||||
)]
|
||||
pub Vec<AccessListItem>,
|
||||
);
|
||||
|
||||
impl AccessList {
|
||||
/// Converts the list into a vec, expected by revm
|
||||
|
||||
@@ -1212,12 +1212,13 @@ mod tests {
|
||||
assert_trie_updates(&account_updates);
|
||||
}
|
||||
|
||||
// TODO: limit the thumber of test cases?
|
||||
proptest! {
|
||||
#![proptest_config(ProptestConfig {
|
||||
cases: 128, ..ProptestConfig::default()
|
||||
})]
|
||||
#[test]
|
||||
fn fuzz_state_root_incremental(account_changes: [BTreeMap<H256, U256>; 5]) {
|
||||
tokio::runtime::Runtime::new().unwrap().block_on(async {
|
||||
|
||||
let db = create_test_rw_db();
|
||||
let factory = ProviderFactory::new(db.as_ref(), MAINNET.clone());
|
||||
let tx = factory.provider_rw().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user