diff --git a/crates/rbuilder/src/integration/playground.rs b/crates/rbuilder/src/integration/playground.rs index c5af804a..a65548cd 100644 --- a/crates/rbuilder/src/integration/playground.rs +++ b/crates/rbuilder/src/integration/playground.rs @@ -108,6 +108,10 @@ impl Playground { Ok(event) } + pub fn rbuilder_rpc_url(&self) -> &str { + "http://localhost:8645" + } + pub fn el_url(&self) -> &str { "http://localhost:8545" } diff --git a/crates/rbuilder/src/integration/simple.rs b/crates/rbuilder/src/integration/simple.rs index c84e7863..e66f1681 100644 --- a/crates/rbuilder/src/integration/simple.rs +++ b/crates/rbuilder/src/integration/simple.rs @@ -4,7 +4,7 @@ mod tests { use alloy_network::TransactionBuilder; use alloy_primitives::U256; - use alloy_provider::{Provider, ProviderBuilder}; + use alloy_provider::{PendingTransactionBuilder, Provider, ProviderBuilder}; use alloy_rpc_types::TransactionRequest; use std::str::FromStr; use test_utils::ignore_if_env_not_set; @@ -13,6 +13,7 @@ mod tests { #[ignore_if_env_not_set("PLAYGROUND_DIR")] // TODO: Change with a custom macro (i.e ignore_if_not_playground) #[tokio::test] async fn test_simple_example() { + // This test sends a transaction ONLY to the builder and waits for the block to be built with it. let srv = Playground::new().unwrap(); srv.wait_for_next_slot().await.unwrap(); @@ -30,9 +31,23 @@ mod tests { .with_gas_price(gas_price) .with_gas_limit(21000); - let pending_tx = provider.send_transaction(tx).await.unwrap(); - let receipt = pending_tx.get_receipt().await.unwrap(); + let tx = provider.fill(tx).await.unwrap(); + + // send the transaction ONLY to the builder + let rbuilder_provider = + ProviderBuilder::new().on_http(Url::parse(srv.rbuilder_rpc_url()).unwrap()); + let pending_tx = rbuilder_provider + .send_tx_envelope(tx.as_envelope().unwrap().clone()) + .await + .unwrap(); + + // wait for the transaction in the el node since rbuilder does not implement + // the `eth_getTransactionReceipt` method. + let binding = ProviderBuilder::new().on_http(Url::parse(srv.el_url()).unwrap()); + let pending_tx = PendingTransactionBuilder::new(&binding, *pending_tx.tx_hash()) + .with_timeout(Some(std::time::Duration::from_secs(60))); + let receipt = pending_tx.get_receipt().await.unwrap(); srv.validate_block_built(receipt.block_number.unwrap()) .await .unwrap();