1pub mod benchmark;
10
11#[cfg(not(target_arch = "wasm32"))]
12pub mod artifacts;
13
14#[cfg(not(target_arch = "wasm32"))]
15pub mod pic;
16
17pub mod performance;
18use candid::Principal;
19
20pub struct Fake;
28
29impl Fake {
30 #[must_use]
34 pub fn principal(seed: u32) -> Principal {
35 let mut buf = [0u8; 29];
36 buf[..4].copy_from_slice(&seed.to_be_bytes());
37
38 Principal::from_slice(&buf)
39 }
40}
41
42#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn fake_principal_is_deterministic_and_unique() {
52 let p1 = Fake::principal(7);
53 let p2 = Fake::principal(7);
54 let q = Fake::principal(8);
55
56 assert_eq!(p1, p2, "Fake::principal should be deterministic");
57 assert_ne!(p1, q, "Fake::principal should differ for different seeds");
58
59 let bytes = p1.as_slice();
60 assert_eq!(bytes.len(), 29, "Principal must be 29 bytes");
61 }
62}