Skip to content

Commit 1926768

Browse files
committed
adds hoodi tests scaffolding
1 parent 7b45a34 commit 1926768

File tree

1 file changed

+96
-6
lines changed

1 file changed

+96
-6
lines changed

tests/flashbots.rs

Lines changed: 96 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,15 +406,10 @@ async fn test_alloy_flashbots_mainnet() {
406406

407407
let block = mainnet.get_block(BlockId::latest()).await.unwrap().unwrap();
408408
let target_block = block.number() + 1;
409-
dbg!("preparing bundle for", target_block);
410-
411-
let target_block = block.number() + 1;
412-
dbg!("preparing bundle for", target_block);
413-
414409
let SendableTx::Envelope(tx) = mainnet.fill(req.clone()).await.unwrap() else {
415410
panic!("expected filled tx");
416411
};
417-
dbg!("prepared transaction request", tx.clone());
412+
dbg!("prepared transaction request", tx.clone(), target_block);
418413
let tx_bytes = tx.encoded_2718();
419414

420415
let bundle = EthSendBundle {
@@ -474,6 +469,101 @@ pub async fn test_send_single_tx_sepolia() {
474469
dbg!(pending_tx);
475470
}
476471

472+
#[tokio::test]
473+
#[ignore = "integration test"]
474+
pub async fn test_send_single_tx_hoodi() {
475+
setup_logging();
476+
477+
let raw_key = env::var("BUILDER_KEY").expect("BUILDER_KEY must be set");
478+
let builder_key = LocalOrAws::load(&raw_key, Some(560048))
479+
.await
480+
.expect("failed to load builder key");
481+
482+
let req = TransactionRequest::default()
483+
.to(builder_key.address())
484+
.value(U256::from(0u64))
485+
.gas_limit(21_000)
486+
.max_fee_per_gas((50 * GWEI_TO_WEI).into())
487+
.max_priority_fee_per_gas((2 * GWEI_TO_WEI).into())
488+
.from(builder_key.address());
489+
490+
let hoodi = ProviderBuilder::new()
491+
.wallet(builder_key.clone())
492+
.connect_http("https://ethereum-hoodi-rpc.publicnode.com".parse().unwrap());
493+
494+
let SendableTx::Envelope(tx) = hoodi.fill(req.clone()).await.unwrap() else {
495+
panic!("expected filled tx");
496+
};
497+
dbg!("prepared transaction request", tx.clone());
498+
let tx_bytes = tx.encoded_2718();
499+
500+
let pending_tx = hoodi
501+
.send_raw_transaction(&tx_bytes)
502+
.await
503+
.expect("should send tx")
504+
.watch()
505+
.await
506+
.unwrap();
507+
dbg!(pending_tx);
508+
}
509+
510+
#[tokio::test]
511+
#[ignore = "integration test"]
512+
async fn test_send_valid_bundle_hoodi() {
513+
setup_logging();
514+
515+
let raw_key = env::var("BUILDER_KEY").expect("BUILDER_KEY must be set");
516+
let builder_key = LocalOrAws::load(&raw_key, Some(560048))
517+
.await
518+
.expect("failed to load builder key");
519+
520+
let flashbots = ProviderBuilder::new()
521+
.wallet(builder_key.clone())
522+
.connect_http("https://boost-relay-hoodi.flashbots.net".parse().unwrap());
523+
524+
let hoodi = ProviderBuilder::new()
525+
.wallet(builder_key.clone())
526+
.connect_http("https://ethereum-hoodi-rpc.publicnode.com".parse().unwrap());
527+
528+
let req = TransactionRequest::default()
529+
.to(builder_key.address())
530+
.value(U256::from(0u64))
531+
.gas_limit(21_000)
532+
.max_fee_per_gas((50 * GWEI_TO_WEI).into())
533+
.max_priority_fee_per_gas((2 * GWEI_TO_WEI).into())
534+
.from(builder_key.address());
535+
536+
let SendableTx::Envelope(tx) = hoodi.fill(req.clone()).await.unwrap() else {
537+
panic!("expected filled tx");
538+
};
539+
dbg!("prepared transaction request", tx.clone());
540+
let tx_bytes = tx.encoded_2718();
541+
542+
let block = hoodi.get_block(BlockId::latest()).await.unwrap().unwrap();
543+
let target_block = block.number() + 1;
544+
dbg!("preparing bundle for", target_block);
545+
546+
// let call_bundle = EthCallBundle {
547+
// txs: vec![tx_bytes.clone().into()],
548+
// block_number: target_block,
549+
// ..Default::default()
550+
// };
551+
552+
// let sim = flashbots
553+
// .call_bundle(call_bundle)
554+
// .with_auth(builder_key.clone());
555+
// dbg!(sim.await.unwrap());
556+
557+
let bundle = EthSendBundle {
558+
txs: vec![tx_bytes.clone().into()],
559+
block_number: target_block,
560+
..Default::default()
561+
};
562+
563+
let result = flashbots.send_bundle(bundle).with_auth(builder_key.clone());
564+
dbg!(result.await.unwrap());
565+
}
566+
477567
/// Asserts that a tx was included in Sepolia within `deadline` seconds.
478568
async fn assert_tx_included(sepolia: &SepoliaProvider, tx_hash: B256, deadline: u64) {
479569
let now = Instant::now();

0 commit comments

Comments
 (0)