|
2 | 2 | mod tests {
|
3 | 3 | use crate::{
|
4 | 4 | integration::{
|
5 |
| - op_rbuilder::OpRbuilderConfig, op_reth::OpRethConfig, IntegrationFramework, TestHarness, |
| 5 | + op_rbuilder::OpRbuilderConfig, op_reth::OpRethConfig, IntegrationFramework, |
| 6 | + TestHarness, TestHarnessBuilder, |
6 | 7 | },
|
7 | 8 | tester::{BlockGenerator, EngineApi},
|
8 | 9 | tx_signer::Signer,
|
@@ -94,10 +95,66 @@ mod tests {
|
94 | 95 | Ok(())
|
95 | 96 | }
|
96 | 97 |
|
| 98 | + #[tokio::test] |
| 99 | + #[cfg(not(feature = "flashblocks"))] |
| 100 | + async fn integration_test_monitor_transaction_drops() -> eyre::Result<()> { |
| 101 | + // This test ensures that the transactions that get reverted an not included in the block |
| 102 | + // are emitted as a log on the builder. |
| 103 | + let harness = TestHarnessBuilder::new("integration_test_monitor_transaction_drops") |
| 104 | + .with_revert_protection() |
| 105 | + .build() |
| 106 | + .await?; |
| 107 | + |
| 108 | + let mut generator = harness.block_generator().await?; |
| 109 | + |
| 110 | + // send 10 reverting transactions |
| 111 | + let mut pending_txn = Vec::new(); |
| 112 | + for _ in 0..10 { |
| 113 | + let txn = harness.send_revert_transaction().await?; |
| 114 | + pending_txn.push(txn); |
| 115 | + } |
| 116 | + |
| 117 | + // generate 10 blocks |
| 118 | + for _ in 0..10 { |
| 119 | + let block_hash = generator.generate_block().await?; |
| 120 | + |
| 121 | + // query the block and the transactions inside the block |
| 122 | + let block = harness |
| 123 | + .provider()? |
| 124 | + .get_block_by_hash(block_hash) |
| 125 | + .await? |
| 126 | + .expect("block"); |
| 127 | + |
| 128 | + // blocks should only include two transactions (deposit + builder) |
| 129 | + assert_eq!(block.transactions.len(), 2); |
| 130 | + } |
| 131 | + |
| 132 | + // check that the builder emitted logs for the reverted transactions |
| 133 | + // with the monitoring logic |
| 134 | + // TODO: this is not ideal, lets find a different way to detect this |
| 135 | + // Each time a transaction is dropped, it emits a log like this |
| 136 | + // 'Transaction event received target="monitoring" tx_hash="<tx_hash>" kind="discarded"' |
| 137 | + let builder_logs = std::fs::read_to_string(harness.builder_log_path)?; |
| 138 | + |
| 139 | + for txn in pending_txn { |
| 140 | + let txn_log = format!( |
| 141 | + "Transaction event received target=\"monitoring\" tx_hash=\"{}\" kind=\"discarded\"", |
| 142 | + txn.tx_hash() |
| 143 | + ); |
| 144 | + |
| 145 | + assert!(builder_logs.contains(txn_log.as_str())); |
| 146 | + } |
| 147 | + |
| 148 | + Ok(()) |
| 149 | + } |
| 150 | + |
97 | 151 | #[tokio::test]
|
98 | 152 | #[cfg(not(feature = "flashblocks"))]
|
99 | 153 | async fn integration_test_revert_protection_disabled() -> eyre::Result<()> {
|
100 |
| - let harness = TestHarness::new("integration_test_revert_protection_disabled").await; |
| 154 | + let harness = TestHarnessBuilder::new("integration_test_revert_protection_disabled") |
| 155 | + .build() |
| 156 | + .await?; |
| 157 | + |
101 | 158 | let mut generator = harness.block_generator().await?;
|
102 | 159 |
|
103 | 160 | let txn1 = harness.send_valid_transaction().await?;
|
@@ -386,13 +443,15 @@ mod tests {
|
386 | 443 | #[tokio::test]
|
387 | 444 | #[cfg(not(feature = "flashblocks"))]
|
388 | 445 | async fn integration_test_get_payload_close_to_fcu() -> eyre::Result<()> {
|
389 |
| - let test_harness = TestHarness::new("integration_test_get_payload_close_to_fcu").await; |
| 446 | + let test_harness = TestHarnessBuilder::new("integration_test_get_payload_close_to_fcu") |
| 447 | + .build() |
| 448 | + .await?; |
390 | 449 | let mut block_generator = test_harness.block_generator().await?;
|
391 | 450 |
|
392 | 451 | // add some transactions to the pool so that the builder is busy when we send the fcu/getPayload requests
|
393 | 452 | for _ in 0..10 {
|
394 | 453 | // Note, for this test it is okay if they are not valid
|
395 |
| - test_harness.send_valid_transaction().await?; |
| 454 | + let _ = test_harness.send_valid_transaction().await?; |
396 | 455 | }
|
397 | 456 |
|
398 | 457 | // TODO: In the fail case scenario, this hangs forever, but it should return an error
|
|
0 commit comments