From b1e6c79bf40d879dd565eeaa5f48f00ae964f4ac Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 8 Nov 2026 23:18:53 +0000 Subject: sync: a test exchanging until level, not one answer delivered_messages_are_answered_with_changes_we_lack failed now and then: after the answer, the node still lacked the peer's change. Automerge's sync tells what each side has by a Bloom filter, whose false positives take more rounds. The test now exchanges up to four rounds more, each asking for what is still missing, until both are level. --- src/document/sync.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/document/sync.rs b/src/document/sync.rs index 440718c..a7a466b 100644 --- a/src/document/sync.rs +++ b/src/document/sync.rs @@ -1707,6 +1707,23 @@ mod tests { let answer = b.generate(&theirs, now, bytes).expect("b answers"); b.send_succeeded(b.id()); a.receive(&mut ours, decode(&answer).unwrap()).unwrap(); + // The answer may not bring what we lack: Automerge's sync tells what each side has + // by a Bloom filter, whose false positives (about one in a hundred) take more + // rounds, each asking for what is still missing. + for _ in 0..4 { + if ours.get_heads() == theirs.get_heads() { + break; + } + let ask = a + .generate(&ours, now, bytes) + .expect("a asks for what it lacks"); + a.send_succeeded(a.id()); + b.receive(&mut theirs, decode(&ask).unwrap()).unwrap(); + if let Some(lacking) = b.generate(&theirs, now, bytes) { + b.send_succeeded(b.id()); + a.receive(&mut ours, decode(&lacking).unwrap()).unwrap(); + } + } assert_eq!(ours.get_heads(), theirs.get_heads()); } -- cgit v1.3.1