@@ -470,19 +470,19 @@ async fn test_flashblocks_number_contract_builder_tx(rbuilder: LocalInstance) ->
470
470
let flashblocks_listener = rbuilder. spawn_flashblocks_listener ( ) ;
471
471
let provider = rbuilder. provider ( ) . await ?;
472
472
473
- // Deploy flashblocks number contract
473
+ // Deploy flashblocks number contract which will be in flashblocks 1
474
474
let deploy_tx = driver
475
475
. create_transaction ( )
476
476
. deploy_flashblock_number_contract ( )
477
477
. with_bundle ( BundleOpts :: default ( ) )
478
478
. send ( )
479
479
. await ?;
480
480
481
- // Create transactions for flashblocks 2-4
482
- let transactions_phase1 = create_flashblock_transactions ( & driver, 2 ..5 ) . await ?;
481
+ // Create valid transactions for flashblocks 2-4
482
+ let user_transactions = create_flashblock_transactions ( & driver, 2 ..5 ) . await ?;
483
483
484
- // Build first block
485
- let block1 = driver. build_new_block_with_current_timestamp ( None ) . await ?;
484
+ // Build block with deploy tx in first flashblock, and a random valid transfer in every other flashblock
485
+ let block = driver. build_new_block_with_current_timestamp ( None ) . await ?;
486
486
487
487
// Verify contract deployment
488
488
let receipt = provider
@@ -499,29 +499,29 @@ async fn test_flashblocks_number_contract_builder_tx(rbuilder: LocalInstance) ->
499
499
) ;
500
500
501
501
// Verify first block structure
502
- assert_eq ! ( block1 . transactions. len( ) , 10 ) ;
503
- let block1_txs = block1
502
+ assert_eq ! ( block . transactions. len( ) , 10 ) ;
503
+ let txs = block
504
504
. transactions
505
505
. as_transactions ( )
506
506
. expect ( "transactions not in block" ) ;
507
507
508
- // Verify builder txs (should be regular since not registered)
508
+ // Verify builder txs (should be regular since builder tx is not registered yet )
509
509
verify_builder_txs (
510
- & block1_txs ,
510
+ & txs ,
511
511
& [ 1 , 2 , 4 , 6 , 8 ] ,
512
512
Some ( Address :: ZERO ) ,
513
513
"Should have regular builder tx" ,
514
514
) ;
515
515
516
516
// Verify deploy tx position
517
517
assert_eq ! (
518
- block1_txs [ 3 ] . inner. inner. tx_hash( ) ,
518
+ txs [ 3 ] . inner. inner. tx_hash( ) ,
519
519
* deploy_tx. tx_hash( ) ,
520
520
"Deploy tx not in correct position"
521
521
) ;
522
522
523
523
// Verify user transactions
524
- verify_tx_matches ( & block1_txs , & [ 5 , 7 , 9 ] , & transactions_phase1 ) ;
524
+ verify_user_tx_hashes ( & txs , & [ 5 , 7 , 9 ] , & user_transactions ) ;
525
525
526
526
// Initialize contract
527
527
let init_tx = driver
@@ -539,34 +539,35 @@ async fn test_flashblocks_number_contract_builder_tx(rbuilder: LocalInstance) ->
539
539
. await ?
540
540
. expect ( "init tx not mined" ) ;
541
541
542
- // Create transactions for testing contract calls
543
- let transactions_phase2 = create_flashblock_transactions ( & driver, 1 ..5 ) . await ?;
542
+ // Create user transactions for flashblocks 1 - 5
543
+ let user_transactions = create_flashblock_transactions ( & driver, 1 ..5 ) . await ?;
544
544
545
- // Build second block after initialization
546
- let block2 = driver. build_new_block_with_current_timestamp ( None ) . await ?;
547
- assert_eq ! ( block2. transactions. len( ) , 10 ) ;
548
- let block2_txs = block2
545
+ // Build second block after initialization which will call the flashblock number contract
546
+ // with builder registered
547
+ let block = driver. build_new_block_with_current_timestamp ( None ) . await ?;
548
+ assert_eq ! ( block. transactions. len( ) , 10 ) ;
549
+ let txs = block
549
550
. transactions
550
551
. as_transactions ( )
551
552
. expect ( "transactions not in block" ) ;
552
553
553
- // Fallback block should have regular builder tx
554
+ // Fallback block should have regular builder tx after deposit tx
554
555
assert_eq ! (
555
- block2_txs [ 1 ] . to( ) ,
556
+ txs [ 1 ] . to( ) ,
556
557
Some ( Address :: ZERO ) ,
557
558
"Fallback block should have regular builder tx"
558
559
) ;
559
560
560
561
// Other builder txs should call the contract
561
562
verify_builder_txs (
562
- & block2_txs ,
563
+ & txs ,
563
564
& [ 2 , 4 , 6 , 8 ] ,
564
565
Some ( contract_address) ,
565
566
"Should call flashblocks contract" ,
566
567
) ;
567
568
568
569
// Verify user transactions, 3 blocks in total built
569
- verify_tx_matches ( & block2_txs , & [ 3 , 5 , 7 , 9 ] , & transactions_phase2 ) ;
570
+ verify_user_tx_hashes ( & txs , & [ 3 , 5 , 7 , 9 ] , & user_transactions ) ;
570
571
571
572
// Verify flashblock number incremented correctly
572
573
let contract = FlashblocksNumber :: new ( contract_address, provider. clone ( ) ) ;
@@ -646,7 +647,7 @@ fn verify_builder_txs(
646
647
}
647
648
648
649
// Helper to verify transaction matches
649
- fn verify_tx_matches (
650
+ fn verify_user_tx_hashes (
650
651
block_txs : & [ impl AsRef < OpTxEnvelope > ] ,
651
652
indices : & [ usize ] ,
652
653
expected_txs : & [ TxHash ] ,
0 commit comments