()
| 522 | } |
| 523 | |
| 524 | fn read_test_vectors() -> Vec<(Vec<u8>, [u8; 32])> { |
| 525 | let path = "src/hash/blake3_official_test_vectors.json"; |
| 526 | let file = File::open(path).unwrap(); |
| 527 | let reader = BufReader::new(file); |
| 528 | |
| 529 | let test_vectors: TestVectors = serde_json::from_reader(reader).unwrap(); |
| 530 | test_vectors |
| 531 | .cases |
| 532 | .iter() |
| 533 | .filter(|vector| vector.input_len <= 1024) |
| 534 | .map(|vector| { |
| 535 | let message = (0..251u8).cycle().take(vector.input_len).collect(); |
| 536 | let expected_hash = <[u8; 32]>::from_hex(&vector.hash[0..64]).unwrap(); |
| 537 | (message, expected_hash) |
| 538 | }) |
| 539 | .collect() |
| 540 | } |
| 541 | |
| 542 | let test_vectors = read_test_vectors(); |
| 543 | for (message, expected_hash) in test_vectors { |
no outgoing calls