@@ -21,25 +21,23 @@ async fn collect_events(
2121 loop {
2222 match stream. next ( ) . await {
2323 Some ( EventScannerMessage :: Data ( logs) ) => return logs,
24- Some ( EventScannerMessage :: Error ( _) ) => continue ,
25- Some ( EventScannerMessage :: Status ( _) ) => continue ,
2624 None => return vec ! [ ] ,
25+ _ => { }
2726 }
2827 }
2928}
3029
3130fn assert_ordering (
32- logs : Vec < Log > ,
31+ logs : & [ Log ] ,
3332 expected_first_count : u64 ,
34- expected_hashes : Vec < FixedBytes < 32 > > ,
33+ expected_hashes : & [ FixedBytes < 32 > ] ,
3534 expected_address : & Address ,
3635) {
3736 let mut expected_count = U256 :: from ( expected_first_count) ;
3837 for ( log, & expected_hash) in logs. iter ( ) . zip ( expected_hashes. iter ( ) ) {
39- let event = log. log_decode :: < TestCounter :: CountIncreased > ( ) . expect (
40- format ! ( "expected sig: 'TestCounter::CountIncreased', got: {:?}" , log. topic0( ) )
41- . as_str ( ) ,
42- ) ;
38+ let event = log. log_decode :: < TestCounter :: CountIncreased > ( ) . unwrap_or_else ( |_| {
39+ panic ! ( "expected sig: 'TestCounter::CountIncreased', got: {:?}" , log. topic0( ) )
40+ } ) ;
4341 assert_eq ! ( & event. address( ) , expected_address) ;
4442 assert_eq ! ( event. transaction_hash. unwrap( ) , expected_hash) ;
4543 assert_eq ! ( expected_count, event. inner. newCount) ;
@@ -70,9 +68,9 @@ async fn scan_latest_exact_count_returns_last_events_in_order() -> anyhow::Resul
7068
7169 // Verify exact events (address, signature, tx hashes)
7270 let expected_first_count = 4 ;
73- let expected_hashes = tx_hashes[ 3 ..8 ] . to_vec ( ) ;
71+ let expected_hashes = & tx_hashes[ 3 ..8 ] ;
7472
75- assert_ordering ( logs, expected_first_count, expected_hashes, contract. address ( ) ) ;
73+ assert_ordering ( & logs, expected_first_count, expected_hashes, contract. address ( ) ) ;
7674
7775 Ok ( ( ) )
7876}
@@ -100,7 +98,7 @@ async fn scan_latest_fewer_available_than_count_returns_all() -> anyhow::Result<
10098 // Verify exact events
10199 let expected_first_count = 1 ;
102100
103- assert_ordering ( logs, expected_first_count, tx_hashes, contract. address ( ) ) ;
101+ assert_ordering ( & logs, expected_first_count, & tx_hashes, contract. address ( ) ) ;
104102
105103 Ok ( ( ) )
106104}
@@ -155,10 +153,10 @@ async fn scan_latest_respects_range_subset() -> anyhow::Result<()> {
155153 // Expect last 4 emitted events exactly (the 2 empty blocks contain no events)
156154 assert_eq ! ( logs. len( ) , 2 ) ;
157155
158- let expected_hashes = tx_hashes[ 4 ..6 ] . to_vec ( ) ; // counts 5..6
156+ let expected_hashes = & tx_hashes[ 4 ..6 ] ; // counts 5..6
159157 let expected_first_count = 5 ;
160158
161- assert_ordering ( logs, expected_first_count, expected_hashes, contract. address ( ) ) ;
159+ assert_ordering ( & logs, expected_first_count, expected_hashes, contract. address ( ) ) ;
162160
163161 Ok ( ( ) )
164162}
@@ -193,9 +191,9 @@ async fn scan_latest_multiple_listeners_to_same_event_receive_same_results() ->
193191 // since logs are equal, asserting for one, asserts for both
194192 assert_eq ! ( 5 , logs1. len( ) ) ;
195193
196- let expected_hashes = tx_hashes[ 2 ..7 ] . to_vec ( ) ;
194+ let expected_hashes = & tx_hashes[ 2 ..7 ] ;
197195 let expected_first_count = 3 ;
198- assert_ordering ( logs1, expected_first_count, expected_hashes, contract. address ( ) ) ;
196+ assert_ordering ( & logs1, expected_first_count, expected_hashes, contract. address ( ) ) ;
199197
200198 Ok ( ( ) )
201199}
@@ -243,7 +241,7 @@ async fn scan_latest_different_filters_receive_different_results() -> anyhow::Re
243241
244242 // Validate increases: expect counts 3,4,5 and the corresponding tx hashes from inc_hashes[2..5]
245243 let expected_hashes_inc = inc_hashes[ 2 ..5 ] . to_vec ( ) ;
246- assert_ordering ( logs_inc, 3 , expected_hashes_inc, contract. address ( ) ) ;
244+ assert_ordering ( & logs_inc, 3 , & expected_hashes_inc, contract. address ( ) ) ;
247245
248246 // Validate decreases: expect counts 4,3 (after two decreases)
249247 let mut expected_count_dec = U256 :: from ( 4 ) ;
@@ -397,7 +395,7 @@ async fn scan_latest_large_gaps_and_empty_ranges() -> anyhow::Result<()> {
397395
398396 assert_eq ! ( logs. len( ) , 3 ) ;
399397 // Expect counts 1,2,3 and hashes in order
400- assert_ordering ( logs, 1 , hashes, contract. address ( ) ) ;
398+ assert_ordering ( & logs, 1 , & hashes, contract. address ( ) ) ;
401399
402400 Ok ( ( ) )
403401}
0 commit comments