11use {
22 crate :: { platform:: Flashblocks , tests:: assert_has_sequencer_tx} ,
3- itertools:: Itertools ,
43 rblib:: {
5- alloy:: primitives:: U256 ,
4+ alloy:: { consensus :: Transaction , primitives:: U256 } ,
65 test_utils:: { BlockResponseExt , TransactionRequestExt } ,
76 } ,
87 std:: time:: Duration ,
1716async fn txs_ordered_by_priority_fee ( ) -> eyre:: Result < ( ) > {
1817 let ( node, _) = Flashblocks :: test_node ( ) . await ?;
1918
20- let tx_tips = vec ! [ 100 , 300 , 200 , 500 , 400 ] ;
21- let mut sent_txs = Vec :: new ( ) ;
19+ let tx_tips = [ 100 , 300 , 200 , 500 , 400 ] ;
2220 for ( i, tip) in tx_tips. iter ( ) . enumerate ( ) {
23- let tx = node
21+ let _tx = node
2422 . send_tx (
2523 node
2624 . build_tx ( )
@@ -30,33 +28,30 @@ async fn txs_ordered_by_priority_fee() -> eyre::Result<()> {
3028 . max_priority_fee_per_gas ( * tip) ,
3129 )
3230 . await ?;
33- sent_txs. push ( * tx. tx_hash ( ) ) ;
3431 }
3532
3633 // We need to wait to build the block
3734 tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . await ;
3835
39- let sorted_sent_txs: Vec < _ > = tx_tips
40- . into_iter ( )
41- . zip ( sent_txs)
42- . inspect ( |( tip, hash) | println ! ( "tip: {tip}, hash: {hash}" ) )
43- . sorted_by_key ( |tuple| tuple. 0 )
44- . rev ( )
45- . map ( |( _tip, hash) | hash)
46- . collect ( ) ;
47-
4836 let block = node. next_block ( ) . await ?;
4937 assert_eq ! ( block. number( ) , 1 ) ;
5038 assert_has_sequencer_tx ! ( & block) ;
5139 assert_eq ! ( block. tx_count( ) , 6 ) ; // sequencer deposit tx + the 5 we sent
5240
53- let hashes: Vec < _ > = block
41+ let base_fee = block. header . base_fee_per_gas . unwrap ( ) ;
42+
43+ let tx_tips: Vec < _ > = block
5444 . transactions
5545 . into_transactions ( )
56- . map ( |tx| tx. inner . inner . tx_hash ( ) )
46+ . skip ( 1 ) // skip the deposit transaction
47+ . map ( |tx| tx. effective_tip_per_gas ( base_fee) )
48+ . rev ( ) // we want to check descending order
5749 . collect ( ) ;
5850
59- assert_eq ! ( sorted_sent_txs, hashes[ 1 ..] ) ;
51+ assert ! (
52+ tx_tips. is_sorted( ) ,
53+ "Transactions not ordered by fee priority"
54+ ) ;
6055
6156 Ok ( ( ) )
6257}
0 commit comments