Skip to content

Commit 29d8e5a

Browse files
committed
fix: simplify test loading and remove anyhow dependency
1 parent de61bd7 commit 29d8e5a

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

Cargo.lock

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

blake2/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ categories = ["cryptography", "no-std"]
1414

1515
[dependencies]
1616
digest = { version = "0.11.0-rc.0", features = ["mac"] }
17-
anyhow = "1.0"
1817

1918
[dev-dependencies]
2019
digest = { version = "0.11.0-rc.0", features = ["dev"] }

blake2/tests/blake2x.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
1010
#![cfg(feature = "blake2x")]
1111

12-
use anyhow::{Context, Result};
1312
use blake2::{Blake2xb, Blake2xs};
1413
use digest::block_api::VariableOutputCore;
1514
use digest::{ExtendableOutput, Update, XofReader};
@@ -38,30 +37,28 @@ fn parse_hex(s: &str) -> Vec<u8> {
3837
hex::decode(s).expect("Invalid hex string")
3938
}
4039

41-
fn load_test_vectors(path: &str) -> Result<Vec<TestVector>> {
40+
fn load_test_vectors(path: &str) -> Vec<TestVector> {
4241
let data = fs::read_to_string(path)
43-
.with_context(|| format!("Failed to read test vector file: {}", path))?;
42+
.unwrap_or_else(|e| panic!("Failed to read test vector file {}: {}", path, e));
4443
let raw: Vec<RawTestVector> = serde_json::from_str(&data)
45-
.with_context(|| format!("Failed to parse JSON in: {}", path))?;
46-
Ok(raw
44+
.unwrap_or_else(|e| panic!("Failed to parse JSON in {}: {}", path, e));
45+
raw
4746
.into_iter()
4847
.map(|r| TestVector {
4948
hash: r.hash,
5049
input: parse_hex(&r.input),
5150
key: parse_hex(&r.key),
5251
output: parse_hex(&r.output),
5352
})
54-
.collect())
53+
.collect()
5554
}
5655

5756
fn get_blake2xb_test_vectors() -> Vec<TestVector> {
5857
load_test_vectors("tests/data/blake2xb/blake2xb-kat.json")
59-
.expect("Failed to load blake2xb test vectors")
6058
}
6159

6260
fn get_blake2xs_test_vectors() -> Vec<TestVector> {
6361
load_test_vectors("tests/data/blake2xs/blake2xs-kat.json")
64-
.expect("Failed to load blake2xs test vectors")
6562
}
6663

6764
// ==== Blake2Xb Tests ====

0 commit comments

Comments
 (0)