use super::of;
use crate::ticket::{BackendHint, Ticket};
const KEY: [u8; 32] = [
0xd7, 0x5a, 0x98, 0x01, 0x82, 0xb1, 0x0a, 0xb7, 0xd5, 0x4b, 0xfe, 0xd3, 0xc9, 0x64, 0x07, 0x3a,
0x0e, 0xe1, 0x72, 0xf3, 0xda, 0xa6, 0x23, 0x25, 0xaf, 0x02, 0x1a, 0x68, 0xf7, 0x07, 0x51, 0x1a,
];
#[test]
fn a_fingerprint_is_the_first_six_bytes_in_hex() {
assert_eq!(of(&KEY), "d75a980182b1");
}
#[test]
fn a_fingerprint_reads_the_leading_bytes_and_only_those() {
let mut early = KEY;
early[0] ^= 0xff;
assert_ne!(of(&early), of(&KEY), "a change inside the prefix must show");
let mut late = KEY;
late[6] ^= 0xff;
assert_eq!(
of(&late),
of(&KEY),
"a change past the prefix cannot show — that is what truncation means"
);
}
#[test]
fn an_id_shorter_than_the_prefix_is_rendered_whole() {
assert_eq!(of(&KEY[..2]), "d75a");
assert_eq!(of(&[]), "");
}
#[test]
fn a_ticket_names_itself_by_the_same_rule() {
let ticket = Ticket::new(KEY, vec![], BackendHint::OpenAiCompatible);
assert_eq!(ticket.fingerprint(), of(&KEY));
}
#[test]
fn the_shared_rule_actually_renders_something() {
let ticket = Ticket::new(KEY, vec![], BackendHint::OpenAiCompatible);
assert_eq!(ticket.fingerprint().len(), 12);
assert!(ticket.fingerprint().chars().all(|c| c.is_ascii_hexdigit()));
}