From ec8fcb29ce059de726aed566af098c8901c5c1a3 Mon Sep 17 00:00:00 2001 From: damocles Date: Sun, 31 May 2026 21:08:12 +0200 Subject: [PATCH] test: add normalization test for bridge-IP subnet form (atlas note) --- hive-c0re/src/lifecycle.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hive-c0re/src/lifecycle.rs b/hive-c0re/src/lifecycle.rs index d59d063c..5f1139eb 100644 --- a/hive-c0re/src/lifecycle.rs +++ b/hive-c0re/src/lifecycle.rs @@ -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]