@@ -11,7 +11,7 @@ use crate::statistics::UDP_TRACKER_CORE_REQUESTS_RECEIVED_TOTAL;
1111/// This function panics if the IP version does not match the event type.
1212pub async fn handle_event ( event : Event , stats_repository : & Repository , now : DurationSinceUnixEpoch ) {
1313 match event {
14- Event :: UdpConnect { context } => {
14+ Event :: UdpConnect { connection : context } => {
1515 // Global fixed metrics
1616
1717 match context. client_socket_addr . ip ( ) {
@@ -36,7 +36,7 @@ pub async fn handle_event(event: Event, stats_repository: &Repository, now: Dura
3636 Err ( err) => tracing:: error!( "Failed to increase the counter: {}" , err) ,
3737 } ;
3838 }
39- Event :: UdpAnnounce { context } => {
39+ Event :: UdpAnnounce { connection : context, .. } => {
4040 // Global fixed metrics
4141
4242 match context. client_socket_addr . ip ( ) {
@@ -61,7 +61,7 @@ pub async fn handle_event(event: Event, stats_repository: &Repository, now: Dura
6161 Err ( err) => tracing:: error!( "Failed to increase the counter: {}" , err) ,
6262 } ;
6363 }
64- Event :: UdpScrape { context } => {
64+ Event :: UdpScrape { connection : context } => {
6565 // Global fixed metrics
6666
6767 match context. client_socket_addr . ip ( ) {
@@ -96,11 +96,13 @@ mod tests {
9696 use std:: net:: { IpAddr , Ipv4Addr , Ipv6Addr , SocketAddr } ;
9797
9898 use torrust_tracker_clock:: clock:: Time ;
99+ use torrust_tracker_primitives:: peer:: PeerAnnouncement ;
99100 use torrust_tracker_primitives:: service_binding:: { Protocol , ServiceBinding } ;
100101
101102 use crate :: event:: { ConnectionContext , Event } ;
102103 use crate :: statistics:: event:: handler:: handle_event;
103104 use crate :: statistics:: repository:: Repository ;
105+ use crate :: tests:: sample_info_hash;
104106 use crate :: CurrentClock ;
105107
106108 #[ tokio:: test]
@@ -109,7 +111,7 @@ mod tests {
109111
110112 handle_event (
111113 Event :: UdpConnect {
112- context : ConnectionContext :: new (
114+ connection : ConnectionContext :: new (
113115 SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 203 , 0 , 113 , 195 ) ) , 8080 ) ,
114116 ServiceBinding :: new (
115117 Protocol :: UDP ,
@@ -134,14 +136,16 @@ mod tests {
134136
135137 handle_event (
136138 Event :: UdpAnnounce {
137- context : ConnectionContext :: new (
139+ connection : ConnectionContext :: new (
138140 SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 203 , 0 , 113 , 195 ) ) , 8080 ) ,
139141 ServiceBinding :: new (
140142 Protocol :: UDP ,
141143 SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 203 , 0 , 113 , 196 ) ) , 6969 ) ,
142144 )
143145 . unwrap ( ) ,
144146 ) ,
147+ info_hash : sample_info_hash ( ) ,
148+ announcement : PeerAnnouncement :: default ( ) ,
145149 } ,
146150 & stats_repository,
147151 CurrentClock :: now ( ) ,
@@ -159,7 +163,7 @@ mod tests {
159163
160164 handle_event (
161165 Event :: UdpScrape {
162- context : ConnectionContext :: new (
166+ connection : ConnectionContext :: new (
163167 SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 203 , 0 , 113 , 195 ) ) , 8080 ) ,
164168 ServiceBinding :: new (
165169 Protocol :: UDP ,
@@ -184,7 +188,7 @@ mod tests {
184188
185189 handle_event (
186190 Event :: UdpConnect {
187- context : ConnectionContext :: new (
191+ connection : ConnectionContext :: new (
188192 SocketAddr :: new ( IpAddr :: V6 ( Ipv6Addr :: new ( 0 , 0 , 0 , 0 , 203 , 0 , 113 , 195 ) ) , 8080 ) ,
189193 ServiceBinding :: new (
190194 Protocol :: UDP ,
@@ -209,14 +213,16 @@ mod tests {
209213
210214 handle_event (
211215 Event :: UdpAnnounce {
212- context : ConnectionContext :: new (
216+ connection : ConnectionContext :: new (
213217 SocketAddr :: new ( IpAddr :: V6 ( Ipv6Addr :: new ( 0 , 0 , 0 , 0 , 203 , 0 , 113 , 195 ) ) , 8080 ) ,
214218 ServiceBinding :: new (
215219 Protocol :: UDP ,
216220 SocketAddr :: new ( IpAddr :: V6 ( Ipv6Addr :: new ( 0 , 0 , 0 , 0 , 203 , 0 , 113 , 196 ) ) , 6969 ) ,
217221 )
218222 . unwrap ( ) ,
219223 ) ,
224+ info_hash : sample_info_hash ( ) ,
225+ announcement : PeerAnnouncement :: default ( ) ,
220226 } ,
221227 & stats_repository,
222228 CurrentClock :: now ( ) ,
@@ -234,7 +240,7 @@ mod tests {
234240
235241 handle_event (
236242 Event :: UdpScrape {
237- context : ConnectionContext :: new (
243+ connection : ConnectionContext :: new (
238244 SocketAddr :: new ( IpAddr :: V6 ( Ipv6Addr :: new ( 0 , 0 , 0 , 0 , 203 , 0 , 113 , 195 ) ) , 8080 ) ,
239245 ServiceBinding :: new (
240246 Protocol :: UDP ,
0 commit comments