|
9 | 9 |
|
10 | 10 | #![cfg(feature = "blake2x")]
|
11 | 11 |
|
12 |
| -use anyhow::{Context, Result}; |
13 | 12 | use blake2::{Blake2xb, Blake2xs};
|
14 | 13 | use digest::block_api::VariableOutputCore;
|
15 | 14 | use digest::{ExtendableOutput, Update, XofReader};
|
@@ -38,30 +37,28 @@ fn parse_hex(s: &str) -> Vec<u8> {
|
38 | 37 | hex::decode(s).expect("Invalid hex string")
|
39 | 38 | }
|
40 | 39 |
|
41 |
| -fn load_test_vectors(path: &str) -> Result<Vec<TestVector>> { |
| 40 | +fn load_test_vectors(path: &str) -> Vec<TestVector> { |
42 | 41 | 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)); |
44 | 43 | 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 |
47 | 46 | .into_iter()
|
48 | 47 | .map(|r| TestVector {
|
49 | 48 | hash: r.hash,
|
50 | 49 | input: parse_hex(&r.input),
|
51 | 50 | key: parse_hex(&r.key),
|
52 | 51 | output: parse_hex(&r.output),
|
53 | 52 | })
|
54 |
| - .collect()) |
| 53 | + .collect() |
55 | 54 | }
|
56 | 55 |
|
57 | 56 | fn get_blake2xb_test_vectors() -> Vec<TestVector> {
|
58 | 57 | load_test_vectors("tests/data/blake2xb/blake2xb-kat.json")
|
59 |
| - .expect("Failed to load blake2xb test vectors") |
60 | 58 | }
|
61 | 59 |
|
62 | 60 | fn get_blake2xs_test_vectors() -> Vec<TestVector> {
|
63 | 61 | load_test_vectors("tests/data/blake2xs/blake2xs-kat.json")
|
64 |
| - .expect("Failed to load blake2xs test vectors") |
65 | 62 | }
|
66 | 63 |
|
67 | 64 | // ==== Blake2Xb Tests ====
|
|
0 commit comments