@@ -20,7 +20,11 @@ pub const HTTP_TRACKER_LOG_TARGET: &str = "HTTP TRACKER";
2020
2121#[ cfg( test) ]
2222pub ( crate ) mod tests {
23+ use std:: net:: { IpAddr , Ipv4Addr , Ipv6Addr , SocketAddr } ;
24+
25+ use aquatic_udp_protocol:: { AnnounceEvent , NumberOfBytes , PeerId } ;
2326 use bittorrent_primitives:: info_hash:: InfoHash ;
27+ use torrust_tracker_primitives:: { peer, DurationSinceUnixEpoch } ;
2428
2529 /// # Panics
2630 ///
@@ -31,4 +35,29 @@ pub(crate) mod tests {
3135 . parse :: < InfoHash > ( )
3236 . expect ( "String should be a valid info hash" )
3337 }
38+
39+ pub fn sample_peer_using_ipv4 ( ) -> peer:: Peer {
40+ sample_peer ( )
41+ }
42+
43+ pub fn sample_peer_using_ipv6 ( ) -> peer:: Peer {
44+ let mut peer = sample_peer ( ) ;
45+ peer. peer_addr = SocketAddr :: new (
46+ IpAddr :: V6 ( Ipv6Addr :: new ( 0x6969 , 0x6969 , 0x6969 , 0x6969 , 0x6969 , 0x6969 , 0x6969 , 0x6969 ) ) ,
47+ 8080 ,
48+ ) ;
49+ peer
50+ }
51+
52+ pub fn sample_peer ( ) -> peer:: Peer {
53+ peer:: Peer {
54+ peer_id : PeerId ( * b"-qB00000000000000000" ) ,
55+ peer_addr : SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 126 , 0 , 0 , 1 ) ) , 8080 ) ,
56+ updated : DurationSinceUnixEpoch :: new ( 1_669_397_478_934 , 0 ) ,
57+ uploaded : NumberOfBytes :: new ( 0 ) ,
58+ downloaded : NumberOfBytes :: new ( 0 ) ,
59+ left : NumberOfBytes :: new ( 0 ) ,
60+ event : AnnounceEvent :: Started ,
61+ }
62+ }
3463}
0 commit comments