Skip to content

Commit 9bf4263

Browse files
committed
test: add BuilderTxValidation assertions to existing tests
Updates smoke, flashblocks, and revert tests to use the BuilderTxValidation utility for validating builder transactions in blocks: - smoke.rs: Added builder tx count assertions to chain_produces_blocks, chain_produces_big_tx_with_gas_limit, and chain_produces_big_tx_without_gas_limit - flashblocks.rs: Added builder tx count assertions to smoke_dynamic_base, smoke_dynamic_unichain, smoke_classic_unichain, and smoke_classic_base - revert.rs: Added builder tx validation to monitor_transaction_gc, disabled, and allow_reverted_transactions_without_bundle tests
1 parent 0f73840 commit 9bf4263

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed

crates/op-rbuilder/src/tests/flashblocks.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ use std::time::Duration;
99
use crate::{
1010
args::{FlashblocksArgs, OpRbuilderArgs},
1111
tests::{
12-
BlockTransactionsExt, BundleOpts, ChainDriver, FLASHBLOCKS_NUMBER_ADDRESS, LocalInstance,
13-
TransactionBuilderExt, flashblocks_number_contract::FlashblocksNumber,
12+
BlockTransactionsExt, BuilderTxValidation, BundleOpts, ChainDriver,
13+
FLASHBLOCKS_NUMBER_ADDRESS, LocalInstance, TransactionBuilderExt,
14+
flashblocks_number_contract::FlashblocksNumber,
1415
},
1516
};
1617

@@ -43,6 +44,10 @@ async fn smoke_dynamic_base(rbuilder: LocalInstance) -> eyre::Result<()> {
4344
}
4445
let block = driver.build_new_block_with_current_timestamp(None).await?;
4546
assert_eq!(block.transactions.len(), 8, "Got: {:?}", block.transactions); // 5 normal txn + deposit + 2 builder txn
47+
48+
// Validate builder transactions using BuilderTxValidation
49+
block.assert_builder_tx_count(2);
50+
4651
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
4752
}
4853

@@ -81,6 +86,10 @@ async fn smoke_dynamic_unichain(rbuilder: LocalInstance) -> eyre::Result<()> {
8186
}
8287
let block = driver.build_new_block_with_current_timestamp(None).await?;
8388
assert_eq!(block.transactions.len(), 8, "Got: {:?}", block.transactions); // 5 normal txn + deposit + 2 builder txn
89+
90+
// Validate builder transactions using BuilderTxValidation
91+
block.assert_builder_tx_count(2);
92+
8493
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
8594
}
8695

@@ -119,6 +128,10 @@ async fn smoke_classic_unichain(rbuilder: LocalInstance) -> eyre::Result<()> {
119128
}
120129
let block = driver.build_new_block().await?;
121130
assert_eq!(block.transactions.len(), 8, "Got: {:?}", block.transactions); // 5 normal txn + deposit + 2 builder txn
131+
132+
// Validate builder transactions using BuilderTxValidation
133+
block.assert_builder_tx_count(2);
134+
122135
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
123136
}
124137

@@ -157,6 +170,10 @@ async fn smoke_classic_base(rbuilder: LocalInstance) -> eyre::Result<()> {
157170
}
158171
let block = driver.build_new_block().await?;
159172
assert_eq!(block.transactions.len(), 8, "Got: {:?}", block.transactions); // 5 normal txn + deposit + 2 builder txn
173+
174+
// Validate builder transactions using BuilderTxValidation
175+
block.assert_builder_tx_count(2);
176+
160177
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
161178
}
162179

crates/op-rbuilder/src/tests/revert.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use crate::{
66
args::OpRbuilderArgs,
77
primitives::bundle::MAX_BLOCK_RANGE_BLOCKS,
88
tests::{
9-
BlockTransactionsExt, BundleOpts, ChainDriver, ChainDriverExt, LocalInstance, ONE_ETH,
10-
OpRbuilderArgsTestExt, TransactionBuilderExt,
9+
BlockTransactionsExt, BuilderTxValidation, BundleOpts, ChainDriver, ChainDriverExt,
10+
LocalInstance, ONE_ETH, OpRbuilderArgsTestExt, TransactionBuilderExt,
1111
},
1212
};
1313

@@ -53,6 +53,14 @@ async fn monitor_transaction_gc(rbuilder: LocalInstance) -> eyre::Result<()> {
5353
assert_eq!(generated_block.transactions.len(), 3);
5454
}
5555

56+
// Validate builder transactions using BuilderTxValidation
57+
if_standard! {
58+
generated_block.assert_builder_tx_count(1);
59+
}
60+
if_flashblocks! {
61+
generated_block.assert_builder_tx_count(2);
62+
}
63+
5664
// since we created the 10 transactions with increasing block ranges, as we generate blocks
5765
// one transaction will be gc on each block.
5866
// transactions from [0, i] should be dropped, transactions from [i+1, 10] should be queued
@@ -88,6 +96,9 @@ async fn disabled(rbuilder: LocalInstance) -> eyre::Result<()> {
8896

8997
assert!(block.includes(valid_tx.tx_hash()));
9098
assert!(block.includes(reverting_tx.tx_hash()));
99+
100+
// Validate builder transactions are present
101+
assert!(block.has_builder_tx());
91102
}
92103

93104
Ok(())
@@ -396,6 +407,9 @@ async fn allow_reverted_transactions_without_bundle(rbuilder: LocalInstance) ->
396407

397408
assert!(block.includes(valid_tx.tx_hash()));
398409
assert!(block.includes(reverting_tx.tx_hash()));
410+
411+
// Validate builder transactions are present
412+
assert!(block.has_builder_tx());
399413
}
400414

401415
Ok(())

crates/op-rbuilder/src/tests/smoke.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ async fn chain_produces_blocks(rbuilder: LocalInstance) -> eyre::Result<()> {
5353
"Empty blocks should have exactly three transactions"
5454
);
5555
}
56+
57+
// Validate builder transactions are present
58+
if_standard! {
59+
block.assert_builder_tx_count(1);
60+
}
61+
if_flashblocks! {
62+
block.assert_builder_tx_count(2);
63+
}
5664
}
5765

5866
// ensure that transactions are included in blocks and each block has all the transactions
@@ -103,6 +111,14 @@ async fn chain_produces_blocks(rbuilder: LocalInstance) -> eyre::Result<()> {
103111
tx_hash
104112
);
105113
}
114+
115+
// Validate builder transactions are present
116+
if_standard! {
117+
block.assert_builder_tx_count(1);
118+
}
119+
if_flashblocks! {
120+
block.assert_builder_tx_count(2);
121+
}
106122
}
107123
Ok(())
108124
}
@@ -249,6 +265,14 @@ async fn chain_produces_big_tx_with_gas_limit(rbuilder: LocalInstance) -> eyre::
249265
let exclusion_result = txs.hashes().find(|hash| hash == tx_high_gas.tx_hash());
250266
assert!(exclusion_result.is_none());
251267

268+
// Validate builder transactions are present
269+
if_standard! {
270+
block.assert_builder_tx_count(1);
271+
}
272+
if_flashblocks! {
273+
block.assert_builder_tx_count(2);
274+
}
275+
252276
Ok(())
253277
}
254278

@@ -294,6 +318,14 @@ async fn chain_produces_big_tx_without_gas_limit(rbuilder: LocalInstance) -> eyr
294318
);
295319
}
296320

321+
// Validate builder transactions are present
322+
if_standard! {
323+
block.assert_builder_tx_count(1);
324+
}
325+
if_flashblocks! {
326+
block.assert_builder_tx_count(2);
327+
}
328+
297329
Ok(())
298330
}
299331

0 commit comments

Comments
 (0)