aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/simtest/reach.rs54
1 files changed, 52 insertions, 2 deletions
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::<Vec<_>>()
+ .join("\n")
}
/// x, b and c, nothing between x and c: x's changes reach c through b, along x's tree.