Skip to main content

tailfeather_testkit/
vectors.rs

1//! Synthetic vectors embedded in the published testkit.
2
3use sha2::{Digest, Sha256};
4
5pub struct Vector {
6    pub name: &'static str,
7    pub bytes: &'static [u8],
8    pub sha256: &'static str,
9}
10
11const HEALTH: &[u8] = include_bytes!("../fixtures/health.json");
12
13pub static ALL: &[Vector] = &[Vector {
14    name: "health",
15    bytes: HEALTH,
16    sha256: "c0b2cedfd8c94f54fc8f089589d07b2c3a238d5e18aae57453c57a6873cd8b79",
17}];
18
19pub fn sha256(bytes: &[u8]) -> String {
20    let digest = Sha256::digest(bytes);
21    let mut out = String::with_capacity(64);
22    for byte in digest {
23        use core::fmt::Write;
24        write!(out, "{byte:02x}").unwrap();
25    }
26    out
27}