trying to make tests work with new metadata

This commit is contained in:
Igor Katson 2024-08-14 10:25:05 +01:00
parent 55649e181a
commit c196c11860
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
6 changed files with 45 additions and 29 deletions

View file

@ -1,11 +1,11 @@
use std::{
borrow::Cow,
net::{Ipv4Addr, SocketAddr},
time::Duration,
};
use anyhow::bail;
use futures::{stream::FuturesUnordered, StreamExt};
use librqbit_core::magnet::Magnet;
use rand::Rng;
use tokio::{
spawn,
@ -84,7 +84,7 @@ async fn test_e2e_download() {
let handle = session
.add_torrent(
crate::AddTorrent::TorrentFileBytes(Cow::Owned(torrent_file_bytes)),
crate::AddTorrent::TorrentFileBytes(torrent_file_bytes),
Some(AddTorrentOptions {
overwrite: true,
output_folder: Some(tempdir.to_str().unwrap().to_owned()),
@ -139,6 +139,8 @@ async fn test_e2e_download() {
.and_then(|v| v.parse().ok())
.unwrap_or(1usize);
let magnet = Magnet::from_id20(torrent_file.info_hash(), Vec::new()).to_string();
// 3. Start a client with the initial peers, and download the file.
for _ in 0..client_iters {
let outdir = tempfile::TempDir::with_prefix("rqbit_e2e_client").unwrap();
@ -163,7 +165,7 @@ async fn test_e2e_download() {
let (id, handle) = {
let r = session
.add_torrent(
crate::AddTorrent::TorrentFileBytes(Cow::Owned(torrent_file_bytes.clone())),
crate::AddTorrent::Url((&magnet).into()),
Some(AddTorrentOptions {
initial_peers: Some(peers.clone()),
// only_files: Some(vec![0]),
@ -235,7 +237,7 @@ async fn test_e2e_download() {
// 4. After downloading, recheck its integrity.
let handle = session
.add_torrent(
crate::AddTorrent::TorrentFileBytes(Cow::Owned(torrent_file_bytes.clone())),
crate::AddTorrent::TorrentFileBytes(torrent_file_bytes.clone()),
Some(AddTorrentOptions {
paused: true,
overwrite: true,