From a3f003d2ca9a24959079408e8e240d9ba3128141 Mon Sep 17 00:00:00 2001 From: Hunter Trujillo Date: Wed, 5 Jun 2024 14:49:30 -0600 Subject: [PATCH] Cleanup --- src/backend/fs.rs | 5 +-- tests/file.rs | 82 ----------------------------------------------- 2 files changed, 1 insertion(+), 86 deletions(-) diff --git a/src/backend/fs.rs b/src/backend/fs.rs index b5c98c3..096ac70 100755 --- a/src/backend/fs.rs +++ b/src/backend/fs.rs @@ -61,10 +61,7 @@ pub async fn write_file<'a>( let segment_hashes: Vec = file_stream .map(move |segment: Result| { let segment = segment?; - thread_file_hasher - // .write() - // .expect("write_file write lock") - .update(&segment); + thread_file_hasher.update(&segment); Ok(segment) }) .try_par_then(None, move |segment: Bytes| { diff --git a/tests/file.rs b/tests/file.rs index f54dd5f..3316d52 100755 --- a/tests/file.rs +++ b/tests/file.rs @@ -42,14 +42,10 @@ async fn write_read() -> Result<()> { let format = FileFormat::from_bytes(&file_bytes); let stage_mime_type = format.media_type().to_string(); - //let mime_type = stage_mime_type; let _ = mime_type_sender.send(stage_mime_type.clone()); info!("Writing file"); - // let (x_only, _) = write_pk.x_only_public_key(); - // let orig_hash = blake3::keyed_hash(&x_only.serialize(), &file_bytes); - let bao_hasher = BaoHasher::new(); bao_hasher.update(&file_bytes); let orig_hash = bao_hasher.finalize(); @@ -100,81 +96,3 @@ async fn write_read() -> Result<()> { Ok(()) } - -// #[tokio::test] -// async fn read_write_delete_file() -> Result<()> { -// carbonado::utils::init_logging(RUST_LOG); - -// let (mime_type_sender, mime_type_receiver) = watch::channel("init_mime_type".to_string()); - -// info!("Write Delete:: Reading file bytes"); -// let file_bytes = fs::read("tests/samples/cat.gif")?; -// debug!("{} Write Delete:: bytes read", file_bytes.len()); - -// let format = FileFormat::from_bytes(&file_bytes); -// let stage_mime_type = format.media_type().to_string(); - -// //let mime_type = stage_mime_type; -// let _ = mime_type_sender.send(stage_mime_type.clone()); - -// let file_stream = stream::iter(file_bytes.clone()) -// .chunks(1024 * 1024) -// .map(|chunk| Ok(Bytes::from(chunk))) -// .boxed(); - -// // first file to write -// let (_sk, pk) = generate_keypair(&mut thread_rng()); - -// // info!("Write Delete:: Writing file if not exists in order to test delete"); -// let file_did_write = write_file( -// &Secp256k1PubKey::new(pk), -// file_stream, -// FileName::PubKeyed, -// mime_type_receiver.clone(), -// ) -// .await -// .is_ok(); - -// if file_did_write { -// info!( -// "Write File Group One to Delete File as blake3_hash:: {} ", -// file_did_write.to_string() -// ); -// } - -// // second file to write -// let (_sk, pk) = generate_keypair(&mut thread_rng()); - -// let file_stream = stream::iter(file_bytes) -// .chunks(1024 * 1024) -// .map(|chunk| Ok(Bytes::from(chunk))) -// .boxed(); - -// info!("Write Delete:: Writing file if not exists in order to test delete"); -// let blake3_hash = write_file( -// &Secp256k1PubKey::new(pk), -// file_stream, -// FileName::PubKeyed, -// mime_type_receiver, -// ) -// .await -// .is_ok(); - -// if blake3_hash { -// info!( -// "Write File in Group Two to Delete File as blake3_hash:: {} ", -// blake3_hash.to_string() -// ); -// } - -// // TODO: This is not how you delete files -// // let new_file_bytes = delete_file(Secp256k1PubKey(pk), &file_bytes).is_err(); -// // debug!("Write Delete:: deleted file:: {:?}", new_file_bytes); - -// // TODO: Check number of files - -// debug!(" >>>> Public Key Generated :: {:?} :: {}", _sk, pk); -// info!("Write/Delete test finished successfully!"); - -// Ok(()) -// }