Skip to content

Commit

Permalink
tests: change from sha2 to blake3
Browse files Browse the repository at this point in the history
Signed-off-by: Soc Virnyl Estela <[email protected]>
  • Loading branch information
uncomfyhalomacro committed Nov 7, 2024
1 parent 7d21804 commit ccc236d
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions cargo/tests/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use libroast::{
};
use obs_service_cargo::cli::{self, Method, VendorArgs};
use rand::prelude::*;
use sha2::{digest::Digest, Sha256};
use blake3::Hasher;
use std::{io, path::PathBuf};
use test_log::test;
use tokio::fs;
Expand Down Expand Up @@ -188,16 +188,14 @@ async fn lockfile_does_not_change_if_update_is_false() -> io::Result<()> {
"https://github.com/openSUSE-Rust/obs-service-cargo/archive/refs/tags/v4.0.2.tar.gz";
let first = another_vendor_helper(source, false).await?;
let second = another_vendor_helper(source, false).await?;
let mut hasher1 = Sha256::default();
let mut hasher2 = Sha256::default();
let mut hasher1 = Hasher::default();
let mut hasher2 = Hasher::default();
let first_bytes = fs::read(&first).await?;
let second_bytes = fs::read(&second).await?;
hasher1.update(&first_bytes);
hasher2.update(&second_bytes);
let hash1 = hex::encode(hasher1.finalize());
let hash2 = hex::encode(hasher2.finalize());

assert!(hash1 == hash2);
assert!(hasher1.finalize() == hasher2.finalize());
Ok(())
}

Expand All @@ -208,16 +206,14 @@ async fn lockfile_does_change_if_update_is_true() -> io::Result<()> {
"https://github.com/openSUSE-Rust/obs-service-cargo/archive/refs/tags/v4.0.2.tar.gz";
let first = another_vendor_helper(source, true).await?;
let second = another_vendor_helper(source, true).await?;
let mut hasher1 = Sha256::default();
let mut hasher2 = Sha256::default();
let mut hasher1 = Hasher::default();
let mut hasher2 = Hasher::default();
let first_bytes = fs::read(&first).await?;
let second_bytes = fs::read(&second).await?;
hasher1.update(&first_bytes);
hasher2.update(&second_bytes);
let hash1 = hex::encode(hasher1.finalize());
let hash2 = hex::encode(hasher2.finalize());

assert!(hash1 == hash2);
assert!(hasher1.finalize() == hasher2.finalize());
Ok(())
}

Expand Down

0 comments on commit ccc236d

Please sign in to comment.