|
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,27 @@ 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 |
47 | | - .into_iter() |
| 44 | + .unwrap_or_else(|e| panic!("Failed to parse JSON in {}: {}", path, e)); |
| 45 | + raw.into_iter() |
48 | 46 | .map(|r| TestVector { |
49 | 47 | hash: r.hash, |
50 | 48 | input: parse_hex(&r.input), |
51 | 49 | key: parse_hex(&r.key), |
52 | 50 | output: parse_hex(&r.output), |
53 | 51 | }) |
54 | | - .collect()) |
| 52 | + .collect() |
55 | 53 | } |
56 | 54 |
|
57 | 55 | fn get_blake2xb_test_vectors() -> Vec<TestVector> { |
58 | 56 | load_test_vectors("tests/data/blake2xb/blake2xb-kat.json") |
59 | | - .expect("Failed to load blake2xb test vectors") |
60 | 57 | } |
61 | 58 |
|
62 | 59 | fn get_blake2xs_test_vectors() -> Vec<TestVector> { |
63 | 60 | load_test_vectors("tests/data/blake2xs/blake2xs-kat.json") |
64 | | - .expect("Failed to load blake2xs test vectors") |
65 | 61 | } |
66 | 62 |
|
67 | 63 | // ==== Blake2Xb Tests ==== |
|
0 commit comments