zombienet_orchestrator/generators/
jam_blobs.rs1use jam_std_common::hash_raw;
4use jam_types::{AuthConfig, Authorizer, AuthorizerHash};
5
6include!(concat!(env!("OUT_DIR"), "/jam_blobs.rs"));
11
12pub fn embedded_bootstrap_service() -> Option<(&'static [u8], &'static str)> {
15 #[cfg(feature = "jam")]
16 return Some((BOOTSTRAP_SERVICE_BLOB, BOOTSTRAP_SERVICE_SOURCE));
17 #[cfg(not(feature = "jam"))]
18 None
19}
20
21pub const NULL_AUTHORIZER_BLOB: &[u8] = jam_null_authorizer_bin::BLOB;
23
24pub const NULL_AUTHORIZER_HASH: [u8; 32] = jam_null_authorizer_bin::HASH;
26
27pub fn authorizer_hash(code: &[u8], config: &[u8]) -> AuthorizerHash {
29 Authorizer {
30 code_hash: hash_raw(code).into(),
31 config: AuthConfig(config.to_vec()),
32 }
33 .hash(hash_raw)
34}
35
36pub fn null_authorizer_hash() -> AuthorizerHash {
38 authorizer_hash(NULL_AUTHORIZER_BLOB, &[])
39}
40
41#[cfg(test)]
42mod tests {
43 use super::*;
44
45 #[test]
46 fn the_embedded_hashes_match_the_blobs() {
47 #[cfg(feature = "jam")]
48 assert_eq!(hash_raw(BOOTSTRAP_SERVICE_BLOB), BOOTSTRAP_SERVICE_HASH);
49 assert_eq!(hash_raw(NULL_AUTHORIZER_BLOB), NULL_AUTHORIZER_HASH);
50 }
51}