aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/topology/tests.rs
diff options
context:
space:
mode:
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()));
+}