@@ -89,8 +89,14 @@ impl AnnounceService {
8989 . announce ( & announce_request. info_hash , & mut peer, & remote_client_ip, & peers_wanted)
9090 . await ?;
9191
92- self . send_event ( remote_client_ip, opt_remote_client_port, server_service_binding. clone ( ) , peer)
93- . await ;
92+ self . send_event (
93+ announce_request. info_hash ,
94+ remote_client_ip,
95+ opt_remote_client_port,
96+ server_service_binding. clone ( ) ,
97+ peer,
98+ )
99+ . await ;
94100
95101 Ok ( announce_data)
96102 }
@@ -142,6 +148,7 @@ impl AnnounceService {
142148
143149 async fn send_event (
144150 & self ,
151+ info_hash : InfoHash ,
145152 remote_client_ip : IpAddr ,
146153 opt_peer_ip_port : Option < u16 > ,
147154 server_service_binding : ServiceBinding ,
@@ -150,6 +157,7 @@ impl AnnounceService {
150157 if let Some ( http_stats_event_sender) = self . opt_http_stats_event_sender . as_deref ( ) {
151158 let event = Event :: TcpAnnounce {
152159 connection : event:: ConnectionContext :: new ( remote_client_ip, opt_peer_ip_port, server_service_binding) ,
160+ info_hash,
153161 announcement,
154162 } ;
155163
@@ -327,13 +335,14 @@ mod tests {
327335 use torrust_tracker_test_helpers:: configuration;
328336
329337 use crate :: event;
338+ use crate :: event:: test:: events_match;
330339 use crate :: event:: { ConnectionContext , Event } ;
331340 use crate :: services:: announce:: tests:: {
332341 initialize_core_tracker_services, initialize_core_tracker_services_with_config, sample_announce_request_for_peer,
333342 MockHttpStatsEventSender ,
334343 } ;
335344 use crate :: services:: announce:: AnnounceService ;
336- use crate :: tests:: { sample_peer, sample_peer_using_ipv4, sample_peer_using_ipv6} ;
345+ use crate :: tests:: { sample_info_hash , sample_peer, sample_peer_using_ipv4, sample_peer_using_ipv6} ;
337346
338347 #[ tokio:: test]
339348 async fn it_should_return_the_announce_data ( ) {
@@ -394,22 +403,11 @@ mod tests {
394403
395404 let expected_event = Event :: TcpAnnounce {
396405 connection : ConnectionContext :: new ( remote_client_ip, Some ( 8080 ) , server_service_binding. clone ( ) ) ,
406+ info_hash : sample_info_hash ( ) ,
397407 announcement,
398408 } ;
399409
400- match ( event, expected_event) {
401- (
402- Event :: TcpAnnounce {
403- connection : a_conn,
404- announcement : a2,
405- } ,
406- Event :: TcpAnnounce {
407- connection : b_conn,
408- announcement : b2,
409- } ,
410- ) => * a_conn == b_conn && a2. peer_addr == b2. peer_addr ,
411- _ => false ,
412- }
410+ events_match ( event, & expected_event)
413411 } ) )
414412 . times ( 1 )
415413 . returning ( |_| Box :: pin ( future:: ready ( Some ( Ok ( 1 ) ) ) ) ) ;
@@ -479,22 +477,11 @@ mod tests {
479477
480478 let expected_event = Event :: TcpAnnounce {
481479 connection : ConnectionContext :: new ( remote_client_ip, Some ( 8080 ) , server_service_binding. clone ( ) ) ,
480+ info_hash : sample_info_hash ( ) ,
482481 announcement : peer_announcement,
483482 } ;
484483
485- match ( event, expected_event) {
486- (
487- Event :: TcpAnnounce {
488- connection : a_conn,
489- announcement : a2,
490- } ,
491- Event :: TcpAnnounce {
492- connection : b_conn,
493- announcement : b2,
494- } ,
495- ) => * a_conn == b_conn && a2. peer_addr == b2. peer_addr ,
496- _ => false ,
497- }
484+ events_match ( event, & expected_event)
498485 } ) )
499486 . times ( 1 )
500487 . returning ( |_| Box :: pin ( future:: ready ( Some ( Ok ( 1 ) ) ) ) ) ;
@@ -537,22 +524,10 @@ mod tests {
537524 . with ( predicate:: function ( move |event| {
538525 let expected_event = Event :: TcpAnnounce {
539526 connection : ConnectionContext :: new ( remote_client_ip, Some ( 8080 ) , server_service_binding. clone ( ) ) ,
527+ info_hash : sample_info_hash ( ) ,
540528 announcement : peer,
541529 } ;
542-
543- match ( event, expected_event) {
544- (
545- Event :: TcpAnnounce {
546- connection : a_conn,
547- announcement : a2,
548- } ,
549- Event :: TcpAnnounce {
550- connection : b_conn,
551- announcement : b2,
552- } ,
553- ) => * a_conn == b_conn && a2. peer_addr == b2. peer_addr ,
554- _ => false ,
555- }
530+ events_match ( event, & expected_event)
556531 } ) )
557532 . times ( 1 )
558533 . returning ( |_| Box :: pin ( future:: ready ( Some ( Ok ( 1 ) ) ) ) ) ;
0 commit comments