Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion crates/op-rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ reth-ipc = { workspace = true, optional = true }
bollard = { version = "0.19", optional = true }
tar = { version = "0.4", optional = true }
ctor = { version = "0.4.2", optional = true }
macros = { path = "src/tests/framework/macros", optional = true }

[target.'cfg(unix)'.dependencies]
tikv-jemallocator = { version = "0.6", optional = true }
Expand All @@ -135,7 +136,7 @@ alloy-provider = { workspace = true, default-features = true, features = [
"txpool-api",
] }
tempfile = "3.8"

macros = { path = "src/tests/framework/macros" }
dashmap = { version = "6.1" }
nanoid = { version = "0.4" }
reth-ipc = { workspace = true }
Expand Down Expand Up @@ -172,6 +173,7 @@ testing = [
"reth-node-builder/test-utils",
"bollard",
"ctor",
"macros",
]


Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::tests::{BlockTransactionsExt, ChainDriverExt, LocalInstance};
use alloy_provider::Provider;
use macros::{if_flashblocks, if_standard, rb_test};

/// This test ensures that the transaction size limit is respected.
/// We will set limit to 1 byte and see that the builder will not include any transactions.
#[tokio::test]
async fn tx_size_limit() -> eyre::Result<()> {
let rbuilder = LocalInstance::standard().await?;
#[rb_test]
async fn tx_size_limit(rbuilder: LocalInstance) -> eyre::Result<()> {
let driver = rbuilder.driver().await?;

// Set (max_tx_da_size, max_block_da_size), with this case block won't fit any transaction
Expand Down Expand Up @@ -33,9 +33,8 @@ async fn tx_size_limit() -> eyre::Result<()> {

/// This test ensures that the block size limit is respected.
/// We will set limit to 1 byte and see that the builder will not include any transactions.
#[tokio::test]
async fn block_size_limit() -> eyre::Result<()> {
let rbuilder = LocalInstance::standard().await?;
#[rb_test]
async fn block_size_limit(rbuilder: LocalInstance) -> eyre::Result<()> {
let driver = rbuilder.driver().await?;

// Set block da size to be small, so it won't include tx
Expand All @@ -60,9 +59,8 @@ async fn block_size_limit() -> eyre::Result<()> {
/// Size of each transaction is 100000000
/// We will set limit to 3 txs and see that the builder will include 3 transactions.
/// We should not forget about builder transaction so we will spawn only 2 regular txs.
#[tokio::test]
async fn block_fill() -> eyre::Result<()> {
let rbuilder = LocalInstance::standard().await?;
#[rb_test]
async fn block_fill(rbuilder: LocalInstance) -> eyre::Result<()> {
let driver = rbuilder.driver().await?;

// Set block big enough so it could fit 3 transactions without tx size limit
Expand All @@ -87,9 +85,21 @@ async fn block_fill() -> eyre::Result<()> {
let unfit_tx_3 = driver.create_transaction().send().await?;

let block = driver.build_new_block().await?;
// Now the first 2 txs will fit into the block
assert!(block.includes(fit_tx_1.tx_hash()), "tx should be in block");
assert!(block.includes(fit_tx_2.tx_hash()), "tx should be in block");

if_standard! {
// Now the first 2 txs will fit into the block
assert!(block.includes(fit_tx_1.tx_hash()), "tx should be in block");
assert!(block.includes(fit_tx_2.tx_hash()), "tx should be in block");
}

if_flashblocks! {
// in flashblocks the DA quota is divided by the number of flashblocks
// so we will include only one tx in the block because not all of them
// will fit within DA quote / flashblocks count.
assert!(block.includes(fit_tx_1.tx_hash()), "tx should be in block");
assert!(!block.includes(fit_tx_2.tx_hash()), "tx should not be in block");
}

assert!(
!block.includes(unfit_tx_3.tx_hash()),
"unfit tx should not be in block"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
use std::sync::Arc;

use futures::StreamExt;
use macros::rb_test;
use parking_lot::Mutex;
use tokio::task::JoinHandle;
use tokio_tungstenite::{connect_async, tungstenite::Message};
use tokio_util::sync::CancellationToken;

use crate::{
args::{FlashblocksArgs, OpRbuilderArgs},
builders::FlashblocksBuilder,
args::OpRbuilderArgs,
tests::{ChainDriverExt, LocalInstance, TransactionBuilderExt},
};

#[tokio::test]
async fn chain_produces_blocks() -> eyre::Result<()> {
let rbuilder = LocalInstance::new::<FlashblocksBuilder>(OpRbuilderArgs {
chain_block_time: 2000,
flashblocks: FlashblocksArgs {
enabled: true,
flashblocks_port: 1239,
flashblocks_addr: "127.0.0.1".into(),
flashblocks_block_time: 200,
},
..Default::default()
})
.await?;

#[rb_test(flashblocks, args = OpRbuilderArgs {
chain_block_time: 2000,
..Default::default()
})]
async fn smoke(rbuilder: LocalInstance) -> eyre::Result<()> {
let driver = rbuilder.driver().await?;
driver.fund_default_accounts().await?;

Expand Down
3 changes: 0 additions & 3 deletions crates/op-rbuilder/src/tests/flashblocks/mod.rs

This file was deleted.

14 changes: 14 additions & 0 deletions crates/op-rbuilder/src/tests/framework/macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "macros"
version = "0.1.0"
edition = "2024"
description = "Macros supporting the tests infrastructure for op-rbuilder"

[lib]
proc-macro = true

[dependencies]
syn = "2.0"
quote = "1.0"
proc-macro2 = "1.0"
paste = "1.0"
Loading
Loading