Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoquick committed Jun 5, 2024
1 parent 64cc7f5 commit a3f003d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 86 deletions.
5 changes: 1 addition & 4 deletions src/backend/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ pub async fn write_file<'a>(
let segment_hashes: Vec<BaoHash> = file_stream
.map(move |segment: Result<Bytes>| {
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| {
Expand Down
82 changes: 0 additions & 82 deletions tests/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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(())
// }

0 comments on commit a3f003d

Please sign in to comment.