@@ -151,4 +151,100 @@ mod tests {
151151
152152 assert_eq ! ( stats. udp6_scrapes_handled, 1 ) ;
153153 }
154+
155+ #[ tokio:: test]
156+ async fn should_increase_the_udp_abort_counter_when_it_receives_a_udp_abort_event ( ) {
157+ let stats_repository = Repository :: new ( ) ;
158+
159+ handle_event ( Event :: UdpRequestAborted , & stats_repository) . await ;
160+ let stats = stats_repository. get_stats ( ) . await ;
161+ assert_eq ! ( stats. udp_requests_aborted, 1 ) ;
162+ }
163+ #[ tokio:: test]
164+ async fn should_increase_the_udp_ban_counter_when_it_receives_a_udp_banned_event ( ) {
165+ let stats_repository = Repository :: new ( ) ;
166+
167+ handle_event ( Event :: UdpRequestBanned , & stats_repository) . await ;
168+ let stats = stats_repository. get_stats ( ) . await ;
169+ assert_eq ! ( stats. udp_requests_banned, 1 ) ;
170+ }
171+
172+ #[ tokio:: test]
173+ async fn should_increase_the_udp4_requests_counter_when_it_receives_a_udp4_request_event ( ) {
174+ let stats_repository = Repository :: new ( ) ;
175+
176+ handle_event ( Event :: Udp4Request , & stats_repository) . await ;
177+
178+ let stats = stats_repository. get_stats ( ) . await ;
179+
180+ assert_eq ! ( stats. udp4_requests, 1 ) ;
181+ }
182+
183+ #[ tokio:: test]
184+ async fn should_increase_the_udp4_responses_counter_when_it_receives_a_udp4_response_event ( ) {
185+ let stats_repository = Repository :: new ( ) ;
186+
187+ handle_event (
188+ Event :: Udp4Response {
189+ kind : crate :: packages:: udp_tracker_core:: statistics:: event:: UdpResponseKind :: Announce ,
190+ req_processing_time : std:: time:: Duration :: from_secs ( 1 ) ,
191+ } ,
192+ & stats_repository,
193+ )
194+ . await ;
195+
196+ let stats = stats_repository. get_stats ( ) . await ;
197+
198+ assert_eq ! ( stats. udp4_responses, 1 ) ;
199+ }
200+
201+ #[ tokio:: test]
202+ async fn should_increase_the_udp4_errors_counter_when_it_receives_a_udp4_error_event ( ) {
203+ let stats_repository = Repository :: new ( ) ;
204+
205+ handle_event ( Event :: Udp4Error , & stats_repository) . await ;
206+
207+ let stats = stats_repository. get_stats ( ) . await ;
208+
209+ assert_eq ! ( stats. udp4_errors_handled, 1 ) ;
210+ }
211+
212+ #[ tokio:: test]
213+ async fn should_increase_the_udp6_requests_counter_when_it_receives_a_udp6_request_event ( ) {
214+ let stats_repository = Repository :: new ( ) ;
215+
216+ handle_event ( Event :: Udp6Request , & stats_repository) . await ;
217+
218+ let stats = stats_repository. get_stats ( ) . await ;
219+
220+ assert_eq ! ( stats. udp6_requests, 1 ) ;
221+ }
222+
223+ #[ tokio:: test]
224+ async fn should_increase_the_udp6_response_counter_when_it_receives_a_udp6_response_event ( ) {
225+ let stats_repository = Repository :: new ( ) ;
226+
227+ handle_event (
228+ Event :: Udp6Response {
229+ kind : crate :: packages:: udp_tracker_core:: statistics:: event:: UdpResponseKind :: Announce ,
230+ req_processing_time : std:: time:: Duration :: from_secs ( 1 ) ,
231+ } ,
232+ & stats_repository,
233+ )
234+ . await ;
235+
236+ let stats = stats_repository. get_stats ( ) . await ;
237+
238+ assert_eq ! ( stats. udp6_responses, 1 ) ;
239+ }
240+ #[ tokio:: test]
241+ async fn should_increase_the_udp6_errors_counter_when_it_receives_a_udp6_error_event ( ) {
242+ let stats_repository = Repository :: new ( ) ;
243+
244+ handle_event ( Event :: Udp6Error , & stats_repository) . await ;
245+
246+ let stats = stats_repository. get_stats ( ) . await ;
247+
248+ assert_eq ! ( stats. udp6_errors_handled, 1 ) ;
249+ }
154250}
0 commit comments