aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-16 23:45:31 +0000
committertv <tv@krebsco.de>2026-11-17 01:02:46 +0100
commitb7102d0296a1b06204a582ecedf3bfbabaf1109e (patch)
treef2b2a03f2010b683f8d55fa2a7d9d68168d2b287 /src
parent639364f4ac46b223ae32e7cc6d14954c5677f277 (diff)
simtest: a group naming many nodes is not every node's neighbours
`store_attack_19`: makefu lists five nodes, tv two, and lass one, whose operator names tv's too (`--store-neighbour-parties`); each node keeps two neighbours by the graph among all members. a and b keep each other, and c one of them, whatever makefu's nodes are. The simulations' nodes started from the root may have their configuration adjusted.
Diffstat (limited to 'src')
-rw-r--r--src/simtest/holding.rs52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/simtest/holding.rs b/src/simtest/holding.rs
index c5f8e96..e760c8a 100644
--- a/src/simtest/holding.rs
+++ b/src/simtest/holding.rs
@@ -24,6 +24,7 @@ use crate::files::Files;
use crate::node::NodeConfig;
use crate::state::AppState;
use crate::swarm::bootstrap::{Origin, Start};
+use crate::swarm::topology;
/// How long a test waits for what takes a few rounds of syncs, writes and reads.
const LONG: Duration = Duration::from_secs(30);
@@ -107,6 +108,16 @@ fn of_the_store(config: &mut NodeConfig, id: Id, root: Option<&[u8]>, holding: H
/// Starts `nodes`, each by its name with what it keeps of its store, from the store's
/// `root`, the first one the others' seed, and waits until each holds the store.
async fn started(sim: &Sim, root: &[u8], nodes: Vec<(&str, Holding)>) -> Vec<AppState> {
+ started_with(sim, root, nodes, |_| {}).await
+}
+
+/// [`started`], each node's configuration adjusted by `adjust` too.
+async fn started_with(
+ sim: &Sim,
+ root: &[u8],
+ nodes: Vec<(&str, Holding)>,
+ adjust: fn(&mut NodeConfig),
+) -> Vec<AppState> {
let id = Id::of(root);
let first = nodes[0].0.to_owned();
let states: Vec<AppState> = nodes
@@ -122,7 +133,10 @@ async fn started(sim: &Sim, root: &[u8], nodes: Vec<(&str, Holding)>) -> Vec<App
name,
&seeds,
Start::FromDocument(Origin::Root),
- move |config| of_the_store(config, id, Some(&root), holding),
+ move |config| {
+ of_the_store(config, id, Some(&root), holding);
+ adjust(config);
+ },
)
})
.collect();
@@ -536,3 +550,39 @@ async fn federation_attack_67() {
)
.await;
}
+
+/// A group naming many nodes, to be every node's neighbours: makefu lists five, tv two,
+/// and lass one, whose operator names tv's too (`--store-neighbour-parties`); each node
+/// keeps two neighbours by the graph among all members. a and b keep each other, and c
+/// one of them, whatever makefu's nodes are.
+#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
+async fn store_attack_19() {
+ let sim = Sim::with_identity(87);
+ let (tv, lass, makefu) = three();
+ let many = ["m1", "m2", "m3", "m4", "m5"];
+ let (_, root, _) = federation(&[(&tv, &["a", "b"]), (&lass, &["c"]), (&makefu, &many)]);
+ let mut named = vec![
+ ("a", holding("tv")),
+ ("b", holding("tv")),
+ ("c", holding("lass").near(vec!["tv".to_owned()])),
+ ];
+ named.extend(many.iter().map(|name| (*name, holding("makefu"))));
+ let nodes = started_with(&sim, &root, named, |config| config.neighbours_k = 2).await;
+ let [a, b, c] = [&nodes[0], &nodes[1], &nodes[2]];
+ let (a_id, b_id) = (a.local_id().to_owned(), b.local_id().to_owned());
+ sim.wait_until(
+ "a and b keep each other, and c one of them",
+ LONG,
+ move || {
+ let (a_id, b_id) = (a_id.clone(), b_id.clone());
+ async move {
+ let known = [a, b, c].iter().all(|node| topology::view_known(node));
+ known
+ && topology::is_neighbour(a, &b_id)
+ && topology::is_neighbour(b, &a_id)
+ && (topology::is_neighbour(c, &a_id) || topology::is_neighbour(c, &b_id))
+ }
+ },
+ )
+ .await;
+}