From aac0d4bafc2f28bbb07bb10e9c8d85b7bea1370e Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 4 Nov 2026 05:50:01 +0100 Subject: bump pulled_changes_go_along_their_writers_trees --- src/simtest/reach.rs | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'src/simtest/reach.rs') diff --git a/src/simtest/reach.rs b/src/simtest/reach.rs index eca0a47..e538679 100644 --- a/src/simtest/reach.rs +++ b/src/simtest/reach.rs @@ -129,7 +129,7 @@ async fn pulled_changes_go_along_their_writers_trees() { let x = sim.start_on_with("x", &["sim"], &["b"], Start::Join, slow); sim.wait_ready(&[&b, &c, &d, &x], SOON).await; sim.wait_converged(&[&b, &c, &d, &x], SOON * 2).await; - let (b, c, x) = (&b, &c, &x); + let (b, c, d, x) = (&b, &c, &d, &x); let writer = topology::pair_key(x.local_id()); sim.wait_until("c under b in x's tree", SOON, move || async move { tree::children(b, writer).await == [c.local_id().to_owned()] @@ -138,13 +138,63 @@ async fn pulled_changes_go_along_their_writers_trees() { let (c_pulls, _) = counted(c); let (_, b_forwards) = counted(b); + // What b and c send and receive from now on, to show should c pull. + b.traffic.log.watch(true); + c.traffic.log.watch(true); super::write(x, "y", serde_json::json!(1)).await; + let written = super::heads(x).await; sim.wait_until("c has x's write", SOON, move || async move { super::read(c, "y").await == Some(serde_json::json!(1)) }) .await; assert!(counted(b).1 > b_forwards, "b passed it on along x's tree"); - assert_eq!(counted(c).0, c_pulls, "c pulled nothing"); + assert_eq!( + counted(c).0, + c_pulls, + "c pulled nothing; x's write is {written:?}; what b and c sent and received meanwhile:\n{}", + logged( + &[("b", b), ("c", c)], + &[("b", b), ("c", c), ("d", d), ("x", x)] + ) + ); +} + +/// What `nodes` sent and received, as their logs kept them (`MessageLog`), in order, +/// peers by their names in `names`: STATUSes and SYNCs written out, the others by type. +fn logged(nodes: &[(&str, &AppState)], names: &[(&str, &AppState)]) -> String { + let name = |id: &str| { + names + .iter() + .find(|(_, node)| node.local_id() == id) + .map_or(id.to_owned(), |(name, _)| (*name).to_owned()) + }; + let mut lines: Vec<(u64, String)> = Vec::new(); + for (node_name, node) in nodes { + for logged in node.traffic.log.after(0, 1000) { + let text = if logged.kind.starts_with("STATUS") || logged.kind == "SYNC" { + format!("\n{}", logged.text) + } else { + String::new() + }; + lines.push(( + logged.at, + format!( + "{} {node_name} {} {} {} {}{text}", + logged.at, + logged.way, + logged.kind, + if logged.way == "sent" { "to" } else { "from" }, + name(&logged.peer), + ), + )); + } + } + lines.sort_by_key(|(at, _)| *at); + lines + .into_iter() + .map(|(_, line)| line) + .collect::>() + .join("\n") } /// x, b and c, nothing between x and c: x's changes reach c through b, along x's tree. -- cgit v1.3.1