diff --git a/iroh-cli/tests/cli.rs b/iroh-cli/tests/cli.rs index 999d1be3a8..5b48ed2a02 100644 --- a/iroh-cli/tests/cli.rs +++ b/iroh-cli/tests/cli.rs @@ -209,8 +209,8 @@ fn cli_provide_tree_resume() -> Result<()> { Ok(()) } -#[test] #[ignore = "flaky"] +#[test] fn cli_provide_file_resume() -> Result<()> { use iroh::blobs::store::fs::test_support::{make_partial, MakePartialResult}; @@ -229,11 +229,14 @@ fn cli_provide_file_resume() -> Result<()> { let src_iroh_data_dir = tmp.join("src_iroh_data_dir"); let file = src.join("file"); let hash = make_rand_file(100000, &file)?; - // leave the provider running for the entire test + // import the files into an ephemeral iroh to use the generated blobs db in tests let provider = make_provider_in(&src_iroh_data_dir, Input::Path(file.clone()), false)?; let count = count_input_files(&src); let ticket = match_provide_output(&provider, count, BlobOrCollection::Blob)?; + drop(provider); + { + let provider = make_provider_in(&src_iroh_data_dir, Input::Path(file.clone()), false)?; println!("first test - empty work dir"); let get_iroh_data_dir = tmp.join("get_iroh_data_dir_01"); let get_output = run_get_cmd(&get_iroh_data_dir, &ticket, Some(tgt.clone()))?; @@ -242,6 +245,7 @@ fn cli_provide_file_resume() -> Result<()> { assert_eq!(Hash::new(std::fs::read(&tgt)?), hash); // compare_files(&src, &tgt)?; std::fs::remove_file(&tgt)?; + drop(provider); } // second test - full work dir @@ -249,11 +253,13 @@ fn cli_provide_file_resume() -> Result<()> { println!("second test - full work dir"); let get_iroh_data_dir = tmp.join("get_iroh_data_dir_02"); copy_blob_dirs(&src_iroh_data_dir, &get_iroh_data_dir)?; + let provider = make_provider_in(&src_iroh_data_dir, Input::Path(file.clone()), false)?; let get_output = run_get_cmd(&get_iroh_data_dir, &ticket, Some(tgt.clone()))?; let matches = explicit_matches(match_get_stderr(get_output.stderr)?); assert_eq!(matches, vec!["0 B"]); assert_eq!(Hash::new(std::fs::read(&tgt)?), hash); std::fs::remove_file(&tgt)?; + drop(provider); } // third test - partial work dir - truncate some large files @@ -261,6 +267,7 @@ fn cli_provide_file_resume() -> Result<()> { println!("fourth test - partial work dir - truncate some large files"); let get_iroh_data_dir = tmp.join("get_iroh_data_dir_04"); copy_blob_dirs(&src_iroh_data_dir, &get_iroh_data_dir)?; + let provider = make_provider_in(&src_iroh_data_dir, Input::Path(file.clone()), false)?; make_partial(&get_iroh_data_dir, |_hash, _size| { MakePartialResult::Truncate(1024 * 32) })?; @@ -269,8 +276,8 @@ fn cli_provide_file_resume() -> Result<()> { assert_eq!(matches, vec!["65.98 KiB"]); assert_eq!(Hash::new(std::fs::read(&tgt)?), hash); std::fs::remove_file(&tgt)?; + drop(provider); } - drop(provider); Ok(()) } @@ -619,7 +626,7 @@ fn iroh_bin() -> &'static str { env!("CARGO_BIN_EXE_iroh") } -/// Makes a provider process with it's home directory in `iroh_data_dir`. +/// Makes a provider process with its home directory in `iroh_data_dir`. fn make_provider_in(iroh_data_dir: &Path, input: Input, wrap: bool) -> Result { let mut args = vec!["--metrics-port", "disabled", "start"]; if wrap { diff --git a/iroh-net/src/netcheck.rs b/iroh-net/src/netcheck.rs index 2d42fbd97f..e8e731f0a0 100644 --- a/iroh-net/src/netcheck.rs +++ b/iroh-net/src/netcheck.rs @@ -327,7 +327,7 @@ pub(crate) enum Message { /// A report produced by the [`reportgen`] actor. ReportReady { report: Box }, /// The [`reportgen`] actor failed to produce a report. - ReportAborted, + ReportAborted { err: anyhow::Error }, /// An incoming STUN packet to parse. StunPacket { /// The raw UDP payload. @@ -458,8 +458,8 @@ impl Actor { Message::ReportReady { report } => { self.handle_report_ready(report); } - Message::ReportAborted => { - self.handle_report_aborted(); + Message::ReportAborted { err } => { + self.handle_report_aborted(err); } Message::StunPacket { payload, from_addr } => { self.handle_stun_packet(&payload, from_addr); @@ -547,10 +547,10 @@ impl Actor { } } - fn handle_report_aborted(&mut self) { + fn handle_report_aborted(&mut self, err: anyhow::Error) { self.in_flight_stun_requests.clear(); if let Some(ReportRun { report_tx, .. }) = self.current_report_run.take() { - report_tx.send(Err(anyhow!("report aborted"))).ok(); + report_tx.send(Err(err.context("report aborted"))).ok(); } } diff --git a/iroh-net/src/netcheck/reportgen.rs b/iroh-net/src/netcheck/reportgen.rs index 81e48d3dd7..0bdd77ee43 100644 --- a/iroh-net/src/netcheck/reportgen.rs +++ b/iroh-net/src/netcheck/reportgen.rs @@ -210,9 +210,8 @@ impl Actor { match self.run_inner().await { Ok(_) => debug!("reportgen actor finished"), Err(err) => { - error!("reportgen actor failed: {err:#}"); self.netcheck - .send(netcheck::Message::ReportAborted) + .send(netcheck::Message::ReportAborted { err }) .await .ok(); }