aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/topology/tests.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-06 04:15:59 +0100
committertv <tv@krebsco.de>2026-11-06 04:15:59 +0100
commit278ca3cd21397ffad07f0874b80b77f41088a3f2 (patch)
treee240d5d0874fba9008544c970ce7d26e22c22c2a /src/swarm/topology/tests.rs
parentf4db88178bdf3e8f28cd42502d6e0c6905988687 (diff)
swarm neighbours
Diffstat (limited to 'src/swarm/topology/tests.rs')
-rw-r--r--src/swarm/topology/tests.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/swarm/topology/tests.rs b/src/swarm/topology/tests.rs
index 4069c0e..1b9c75d 100644
--- a/src/swarm/topology/tests.rs
+++ b/src/swarm/topology/tests.rs
@@ -467,3 +467,25 @@ fn bench_writer_trees() {
}
}
}
+
+/// The neighbours a swarm records count; without one, or with one out of range, the
+/// node's own.
+#[test]
+fn the_swarms_neighbours_count() {
+ use crate::document::testing::change;
+ use crate::document::{Document, store};
+ let mut doc = Document::new();
+ assert_eq!(swarm_neighbours(&doc, 12), 12);
+ for (recorded, expected) in [
+ (serde_json::json!(8), 8),
+ (serde_json::json!(1), 12),
+ (serde_json::json!(1000), 12),
+ (serde_json::json!("eight"), 12),
+ ] {
+ change(&mut doc, |doc| {
+ store::write_path(doc, &neighbours_path(), &recorded).unwrap()
+ });
+ assert_eq!(swarm_neighbours(&doc, 12), expected, "{recorded}");
+ }
+ assert!(affects_neighbours(&neighbours_path()));
+}