diff options
| author | tv <tv@krebsco.de> | 2026-11-08 23:18:53 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-09 00:19:28 +0100 |
| commit | b1e6c79bf40d879dd565eeaa5f48f00ae964f4ac (patch) | |
| tree | 53f9b008d3c27c3099562369661fce5f760df970 | |
| parent | 03348cdbc0e03f2fe78bdc5b550c60108fc2288b (diff) | |
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.
| -rw-r--r-- | src/document/sync.rs | 17 |
1 files changed, 17 insertions, 0 deletions
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()); } |
