@@ -30,6 +30,7 @@ mod for_guests {
3030 use crate :: common:: contexts:: torrent:: responses:: {
3131 Category , File , TorrentDetails , TorrentDetailsResponse , TorrentListResponse ,
3232 } ;
33+ use crate :: e2e:: contexts:: torrent:: asserts:: expected_torrent;
3334 use crate :: e2e:: contexts:: torrent:: steps:: upload_random_torrent_to_index;
3435 use crate :: e2e:: contexts:: user:: steps:: new_logged_in_user;
3536 use crate :: e2e:: environment:: TestEnv ;
@@ -125,25 +126,13 @@ mod for_guests {
125126 let client = Client :: unauthenticated ( & env. server_socket_addr ( ) . unwrap ( ) ) ;
126127
127128 let uploader = new_logged_in_user ( & env) . await ;
128- let ( test_torrent, uploaded_torrent ) = upload_random_torrent_to_index ( & uploader, & env) . await ;
129+ let ( test_torrent, torrent_listed_in_index ) = upload_random_torrent_to_index ( & uploader, & env) . await ;
129130
130- let response = client. download_torrent ( uploaded_torrent . torrent_id ) . await ;
131+ let response = client. download_torrent ( torrent_listed_in_index . torrent_id ) . await ;
131132
132133 let torrent = decode_torrent ( & response. bytes ) . unwrap ( ) ;
133- let mut expected_torrent = decode_torrent ( & test_torrent. index_info . torrent_file . contents ) . unwrap ( ) ;
134-
135- // code-review: The backend does not generate exactly the same torrent
136- // that was uploaded and created by the `imdl` command-line tool.
137- // So we need to update the expected torrent to match the one generated
138- // by the backend. For some of them it makes sense (`announce` and `announce_list`),
139- // for others it does not.
140- expected_torrent. info . private = Some ( 0 ) ;
141- expected_torrent. announce = Some ( "udp://tracker:6969" . to_string ( ) ) ;
142- expected_torrent. encoding = None ;
143- expected_torrent. announce_list = Some ( vec ! [ vec![ "udp://tracker:6969" . to_string( ) ] ] ) ;
144- expected_torrent. creation_date = None ;
145- expected_torrent. created_by = None ;
146-
134+ let uploaded_torrent = decode_torrent ( & test_torrent. index_info . torrent_file . contents ) . unwrap ( ) ;
135+ let expected_torrent = expected_torrent ( uploaded_torrent) ;
147136 assert_eq ! ( torrent, expected_torrent) ;
148137 assert ! ( response. is_bittorrent_and_ok( ) ) ;
149138 }
0 commit comments