feat: generic data primitives block builder test framework (#13522)

This commit is contained in:
Hoa Nguyen
2024-12-27 16:41:29 +07:00
committed by GitHub
parent df294e424b
commit 0933e1b07d
5 changed files with 30 additions and 27 deletions

View File

@ -34,7 +34,7 @@ use tokio::sync::broadcast::{self, Sender};
/// Functionality to build blocks for tests and help with assertions about
/// their execution.
#[derive(Debug)]
pub struct TestBlockBuilder<N: NodePrimitives = reth_primitives::EthPrimitives> {
pub struct TestBlockBuilder<N: NodePrimitives = EthPrimitives> {
/// The account that signs all the block's transactions.
pub signer: Address,
/// Private key for signing.
@ -66,7 +66,7 @@ impl<N: NodePrimitives> Default for TestBlockBuilder<N> {
}
}
impl TestBlockBuilder {
impl<N: NodePrimitives> TestBlockBuilder<N> {
/// Signer pk setter.
pub fn with_signer_pk(mut self, signer_pk: PrivateKeySigner) -> Self {
self.signer = signer_pk.address();
@ -295,6 +295,13 @@ impl TestBlockBuilder {
execution_outcome.with_receipts(Receipts::from(receipts))
}
}
impl TestBlockBuilder {
/// Creates a `TestBlockBuilder` configured for Ethereum primitives.
pub fn eth() -> Self {
Self::default()
}
}
/// A test `ChainEventSubscriptions`
#[derive(Clone, Debug, Default)]
pub struct TestCanonStateSubscriptions<N: NodePrimitives = reth_primitives::EthPrimitives> {