use crate::{
ops::prelude::Principal,
storage::stable::registry::app::{AppRegistry, AppRegistryRecord},
};
pub struct AppRegistryOps;
impl AppRegistryOps {
pub fn upsert(subnet_pid: Principal, root_pid: Principal) {
AppRegistry::upsert(subnet_pid, root_pid);
}
#[must_use]
pub fn data() -> AppRegistryRecord {
AppRegistry::export()
}
}
#[cfg(test)]
mod tests {
use super::*;
fn p(id: u8) -> Principal {
Principal::from_slice(&[id; 29])
}
#[test]
fn upsert_records_subnet_root_binding() {
let subnet_pid = p(201);
let root_pid = p(202);
AppRegistryOps::upsert(subnet_pid, root_pid);
assert!(
AppRegistryOps::data()
.entries
.contains(&(subnet_pid, root_pid))
);
}
}