@@ -6,7 +6,7 @@ use alloy::{
66 providers:: ext:: AnvilApi ,
77 rpc:: types:: anvil:: { ReorgOptions , TransactionData } ,
88} ;
9- use event_scanner:: { ScannerStatus , assert_empty, assert_next} ;
9+ use event_scanner:: { ScannerStatus , assert_empty, assert_event_sequence , assert_next} ;
1010
1111#[ tokio:: test]
1212async fn reorg_rescans_events_within_same_block ( ) -> anyhow:: Result < ( ) > {
@@ -21,11 +21,16 @@ async fn reorg_rescans_events_within_same_block() -> anyhow::Result<()> {
2121 }
2222
2323 // assert initial events are emitted as expected
24- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 1 ) } ] ) ;
25- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 2 ) } ] ) ;
26- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 3 ) } ] ) ;
27- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 4 ) } ] ) ;
28- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 5 ) } ] ) ;
24+ assert_event_sequence ! (
25+ stream,
26+ & [
27+ CountIncreased { newCount: U256 :: from( 1 ) } ,
28+ CountIncreased { newCount: U256 :: from( 2 ) } ,
29+ CountIncreased { newCount: U256 :: from( 3 ) } ,
30+ CountIncreased { newCount: U256 :: from( 4 ) } ,
31+ CountIncreased { newCount: U256 :: from( 5 ) }
32+ ]
33+ ) ;
2934 let mut stream = assert_empty ! ( stream) ;
3035
3136 // reorg the chain
@@ -64,11 +69,16 @@ async fn reorg_rescans_events_with_ascending_blocks() -> anyhow::Result<()> {
6469 }
6570
6671 // assert initial events are emitted as expected
67- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 1 ) } ] ) ;
68- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 2 ) } ] ) ;
69- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 3 ) } ] ) ;
70- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 4 ) } ] ) ;
71- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 5 ) } ] ) ;
72+ assert_event_sequence ! (
73+ stream,
74+ & [
75+ CountIncreased { newCount: U256 :: from( 1 ) } ,
76+ CountIncreased { newCount: U256 :: from( 2 ) } ,
77+ CountIncreased { newCount: U256 :: from( 3 ) } ,
78+ CountIncreased { newCount: U256 :: from( 4 ) } ,
79+ CountIncreased { newCount: U256 :: from( 5 ) }
80+ ]
81+ ) ;
7282 let mut stream = assert_empty ! ( stream) ;
7383
7484 // reorg the chain
@@ -82,9 +92,14 @@ async fn reorg_rescans_events_with_ascending_blocks() -> anyhow::Result<()> {
8292
8393 // assert expected messages post-reorg
8494 assert_next ! ( stream, ScannerStatus :: ReorgDetected ) ;
85- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 2 ) } ] ) ;
86- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 3 ) } ] ) ;
87- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 4 ) } ] ) ;
95+ assert_event_sequence ! (
96+ stream,
97+ & [
98+ CountIncreased { newCount: U256 :: from( 2 ) } ,
99+ CountIncreased { newCount: U256 :: from( 3 ) } ,
100+ CountIncreased { newCount: U256 :: from( 4 ) }
101+ ]
102+ ) ;
88103 assert_empty ! ( stream) ;
89104
90105 Ok ( ( ) )
@@ -103,10 +118,15 @@ async fn reorg_depth_one() -> anyhow::Result<()> {
103118 }
104119
105120 // assert initial events are emitted as expected
106- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 1 ) } ] ) ;
107- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 2 ) } ] ) ;
108- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 3 ) } ] ) ;
109- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 4 ) } ] ) ;
121+ assert_event_sequence ! (
122+ stream,
123+ & [
124+ CountIncreased { newCount: U256 :: from( 1 ) } ,
125+ CountIncreased { newCount: U256 :: from( 2 ) } ,
126+ CountIncreased { newCount: U256 :: from( 3 ) } ,
127+ CountIncreased { newCount: U256 :: from( 4 ) }
128+ ]
129+ ) ;
110130 let mut stream = assert_empty ! ( stream) ;
111131
112132 // reorg the chain
@@ -136,10 +156,15 @@ async fn reorg_depth_two() -> anyhow::Result<()> {
136156 }
137157
138158 // assert initial events are emitted as expected
139- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 1 ) } ] ) ;
140- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 2 ) } ] ) ;
141- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 3 ) } ] ) ;
142- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 4 ) } ] ) ;
159+ assert_event_sequence ! (
160+ stream,
161+ & [
162+ CountIncreased { newCount: U256 :: from( 1 ) } ,
163+ CountIncreased { newCount: U256 :: from( 2 ) } ,
164+ CountIncreased { newCount: U256 :: from( 3 ) } ,
165+ CountIncreased { newCount: U256 :: from( 4 ) }
166+ ]
167+ ) ;
143168 let mut stream = assert_empty ! ( stream) ;
144169
145170 // reorg the chain
@@ -192,11 +217,14 @@ async fn block_confirmations_mitigate_reorgs() -> anyhow::Result<()> {
192217 provider. primary ( ) . anvil_mine ( Some ( 10 ) , None ) . await ?;
193218
194219 // no `ReorgDetected` should be emitted
195- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 1 ) } ] ) ;
196- assert_next ! ( stream, & [ CountIncreased { newCount: U256 :: from( 2 ) } ] ) ;
197- assert_next ! (
220+ assert_event_sequence ! (
198221 stream,
199- & [ CountIncreased { newCount: U256 :: from( 3 ) } , CountIncreased { newCount: U256 :: from( 4 ) } ]
222+ & [
223+ CountIncreased { newCount: U256 :: from( 1 ) } ,
224+ CountIncreased { newCount: U256 :: from( 2 ) } ,
225+ CountIncreased { newCount: U256 :: from( 3 ) } ,
226+ CountIncreased { newCount: U256 :: from( 4 ) }
227+ ]
200228 ) ;
201229 assert_empty ! ( stream) ;
202230
0 commit comments