@@ -22,7 +22,6 @@ use alloy::{
2222 } ,
2323 signers:: { local:: PrivateKeySigner , Signer } ,
2424} ;
25- use eyre:: Context ;
2625use init4_bin_base:: {
2726 deps:: tracing:: debug,
2827 deps:: tracing_subscriber:: {
@@ -258,52 +257,6 @@ async fn test_send_valid_bundle_mainnet() {
258257 assert ! ( resp. bundle_hash != B256 :: ZERO ) ;
259258}
260259
261- /// Asserts that a tx was included in Sepolia within `deadline` seconds.
262- async fn assert_tx_included ( sepolia : & SepoliaProvider , tx_hash : B256 , deadline : u64 ) {
263- let now = Instant :: now ( ) ;
264- let deadline = now + Duration :: from_secs ( deadline) ;
265- let mut found = false ;
266-
267- loop {
268- let n = Instant :: now ( ) ;
269- if n >= deadline {
270- break ;
271- }
272-
273- match sepolia. get_transaction_by_hash ( tx_hash) . await {
274- Ok ( Some ( _tx) ) => {
275- found = true ;
276- break ;
277- }
278- Ok ( None ) => {
279- // Not yet present; wait and retry
280- dbg ! ( "transaction not yet seen" ) ;
281- tokio:: time:: sleep ( Duration :: from_secs ( 1 ) ) . await ;
282- }
283- Err ( err) => {
284- // Transient error querying the provider; log and retry
285- eprintln ! ( "warning: error querying tx: {}" , err) ;
286- tokio:: time:: sleep ( Duration :: from_secs ( 1 ) ) . await ;
287- }
288- }
289- }
290-
291- assert ! (
292- found,
293- "transaction was not seen by the provider within {:?} seconds" ,
294- deadline
295- ) ;
296- }
297-
298- /// Initializes logger for printing during testing
299- pub fn setup_logging ( ) {
300- // Initialize logging
301- let filter = EnvFilter :: from_default_env ( ) ;
302- let fmt = fmt:: layer ( ) . with_filter ( filter) ;
303- let registry = registry ( ) . with ( fmt) ;
304- let _ = registry. try_init ( ) ;
305- }
306-
307260#[ tokio:: test]
308261#[ ignore = "integration test" ]
309262async fn test_alloy_flashbots_sepolia ( ) {
@@ -325,7 +278,7 @@ async fn test_alloy_flashbots_sepolia() {
325278 . value ( U256 :: from ( 0u64 ) )
326279 . gas_limit ( 21_000 )
327280 . max_fee_per_gas ( ( 50 * GWEI_TO_WEI ) . into ( ) )
328- . max_priority_fee_per_gas ( ( 2 * GWEI_TO_WEI ) . into ( ) )
281+ . max_priority_fee_per_gas ( ( 20 * GWEI_TO_WEI ) . into ( ) )
329282 . from ( builder_key. address ( ) ) ;
330283
331284 let block = sepolia_host
@@ -345,14 +298,6 @@ async fn test_alloy_flashbots_sepolia() {
345298 let bundle = EthSendBundle {
346299 txs : vec ! [ tx_bytes. clone( ) . into( ) ] ,
347300 block_number : target_block,
348- min_timestamp : None ,
349- max_timestamp : None ,
350- reverting_tx_hashes : vec ! [ ] ,
351- replacement_uuid : None ,
352- dropping_tx_hashes : vec ! [ ] ,
353- refund_percent : None ,
354- refund_recipient : None ,
355- refund_tx_hashes : vec ! [ ] ,
356301 ..Default :: default ( )
357302 } ;
358303
@@ -372,7 +317,7 @@ async fn test_alloy_flashbots_sepolia() {
372317
373318#[ tokio:: test]
374319#[ ignore = "integration test" ]
375- async fn test_mev_endpoints ( ) {
320+ async fn test_mev_endpoints_sepolia ( ) {
376321 setup_logging ( ) ;
377322
378323 let raw_key = env:: var ( "BUILDER_KEY" ) . expect ( "BUILDER_KEY must be set" ) ;
@@ -384,6 +329,7 @@ async fn test_mev_endpoints() {
384329 . wallet ( builder_key. clone ( ) )
385330 . connect_http ( "https://relay-sepolia.flashbots.net" . parse ( ) . unwrap ( ) ) ;
386331
332+ // TEMP: Keeping this around because alloy flashbots doesn't have a simulate endpoint for `mev_simBundle`.
387333 let old_flashbots = Flashbots :: new (
388334 "https://relay-sepolia.flashbots.net" . parse ( ) . unwrap ( ) ,
389335 builder_key. clone ( ) ,
@@ -404,7 +350,7 @@ async fn test_mev_endpoints() {
404350 . value ( U256 :: from ( 0u64 ) )
405351 . gas_limit ( 21_000 )
406352 . max_fee_per_gas ( ( 50 * GWEI_TO_WEI ) . into ( ) )
407- . max_priority_fee_per_gas ( ( 2 * GWEI_TO_WEI ) . into ( ) )
353+ . max_priority_fee_per_gas ( ( 20 * GWEI_TO_WEI ) . into ( ) )
408354 . from ( builder_key. address ( ) ) ;
409355
410356 let SendableTx :: Envelope ( tx) = sepolia_host. fill ( req. clone ( ) ) . await . unwrap ( ) else {
@@ -430,15 +376,6 @@ async fn test_mev_endpoints() {
430376 . send_mev_bundle ( bundle)
431377 . with_auth ( builder_key. clone ( ) ) ;
432378 dbg ! ( "send mev bundle:" , result. await . unwrap( ) ) ;
433-
434- let result = flashbots
435- . send_private_transaction ( EthSendPrivateTransaction {
436- tx : tx_bytes. into ( ) ,
437- max_block_number : Some ( target_block + 5 ) ,
438- preferences : PrivateTransactionPreferences :: default ( ) ,
439- } )
440- . with_auth ( builder_key. clone ( ) ) ;
441- dbg ! ( "send private transaction" , result. await . unwrap( ) ) ;
442379}
443380
444381#[ tokio:: test]
@@ -453,9 +390,11 @@ async fn test_alloy_flashbots_mainnet() {
453390
454391 let flashbots = ProviderBuilder :: new ( )
455392 . wallet ( builder_key. clone ( ) )
456- . connect_http ( "https://relay-sepolia .flashbots.net" . parse ( ) . unwrap ( ) ) ;
393+ . connect_http ( "https://relay.flashbots.net" . parse ( ) . unwrap ( ) ) ;
457394
458- let sepolia_host = get_sepolia_host ( builder_key. clone ( ) ) ;
395+ let mainnet = ProviderBuilder :: new ( )
396+ . wallet ( builder_key. clone ( ) )
397+ . connect_http ( "https://ethereum-rpc.publicnode.com" . parse ( ) . unwrap ( ) ) ;
459398
460399 let req = TransactionRequest :: default ( )
461400 . to ( builder_key. address ( ) )
@@ -465,18 +404,14 @@ async fn test_alloy_flashbots_mainnet() {
465404 . max_priority_fee_per_gas ( ( 2 * GWEI_TO_WEI ) . into ( ) )
466405 . from ( builder_key. address ( ) ) ;
467406
468- let block = sepolia_host
469- . get_block ( BlockId :: latest ( ) )
470- . await
471- . unwrap ( )
472- . unwrap ( ) ;
407+ let block = mainnet. get_block ( BlockId :: latest ( ) ) . await . unwrap ( ) . unwrap ( ) ;
473408 let target_block = block. number ( ) + 1 ;
474409 dbg ! ( "preparing bundle for" , target_block) ;
475410
476411 let target_block = block. number ( ) + 1 ;
477412 dbg ! ( "preparing bundle for" , target_block) ;
478413
479- let SendableTx :: Envelope ( tx) = sepolia_host . fill ( req. clone ( ) ) . await . unwrap ( ) else {
414+ let SendableTx :: Envelope ( tx) = mainnet . fill ( req. clone ( ) ) . await . unwrap ( ) else {
480415 panic ! ( "expected filled tx" ) ;
481416 } ;
482417 dbg ! ( "prepared transaction request" , tx. clone( ) ) ;
@@ -538,3 +473,49 @@ pub async fn test_send_single_tx_sepolia() {
538473 . unwrap ( ) ;
539474 dbg ! ( pending_tx) ;
540475}
476+
477+ /// Asserts that a tx was included in Sepolia within `deadline` seconds.
478+ async fn assert_tx_included ( sepolia : & SepoliaProvider , tx_hash : B256 , deadline : u64 ) {
479+ let now = Instant :: now ( ) ;
480+ let deadline = now + Duration :: from_secs ( deadline) ;
481+ let mut found = false ;
482+
483+ loop {
484+ let n = Instant :: now ( ) ;
485+ if n >= deadline {
486+ break ;
487+ }
488+
489+ match sepolia. get_transaction_by_hash ( tx_hash) . await {
490+ Ok ( Some ( _tx) ) => {
491+ found = true ;
492+ break ;
493+ }
494+ Ok ( None ) => {
495+ // Not yet present; wait and retry
496+ dbg ! ( "transaction not yet seen" ) ;
497+ tokio:: time:: sleep ( Duration :: from_secs ( 1 ) ) . await ;
498+ }
499+ Err ( err) => {
500+ // Transient error querying the provider; log and retry
501+ eprintln ! ( "warning: error querying tx: {}" , err) ;
502+ tokio:: time:: sleep ( Duration :: from_secs ( 1 ) ) . await ;
503+ }
504+ }
505+ }
506+
507+ assert ! (
508+ found,
509+ "transaction was not seen by the provider within {:?} seconds" ,
510+ deadline
511+ ) ;
512+ }
513+
514+ /// Initializes logger for printing during testing
515+ pub fn setup_logging ( ) {
516+ // Initialize logging
517+ let filter = EnvFilter :: from_default_env ( ) ;
518+ let fmt = fmt:: layer ( ) . with_filter ( filter) ;
519+ let registry = registry ( ) . with ( fmt) ;
520+ let _ = registry. try_init ( ) ;
521+ }
0 commit comments