test: add normalization test for bridge-IP subnet form (atlas note)

This commit is contained in:
damocles 2026-05-31 21:08:12 +02:00 committed by mara
commit ec8fcb29ce

View file

@ -1377,6 +1377,21 @@ mod tests {
assert!(agent_network_ip("alice", "10.0.0.0").is_none()); // no prefix
}
#[test]
fn agent_network_ip_normalizes_bridge_ip_subnet() {
// HIVE_NETWORK_SUBNET carries the bridge IP (10.42.0.1/24), not
// canonical network (10.42.0.0/24). Both must produce the same result
// after host-bit masking.
let from_bridge = agent_network_ip("alice", "10.42.0.1/24");
let from_canonical = agent_network_ip("alice", "10.42.0.0/24");
assert_eq!(from_bridge, from_canonical,
"bridge-IP and canonical-network form should normalize to the same result");
// Result must still be in .2-.254.
let ip = from_bridge.unwrap();
let last: u8 = ip.rsplit('.').next().unwrap().parse().unwrap();
assert!(last >= 2 && last <= 254, "host byte {last}");
}
/// `setup_proposed` is idempotent: calling it on an existing repo is a
/// no-op (the fresh guard skips all writes).
#[tokio::test]