diff options
| author | tv <tv@krebsco.de> | 2026-11-04 21:38:19 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-04 21:38:19 +0100 |
| commit | 95fb8698528dc4149056f7cb6e9e1b67fe2d4cc9 (patch) | |
| tree | 7aad1f19a1ba961d85748f5bb8bfd0e3cc8c81da | |
| parent | f4a22877c8e2edbedae2d2485fc998d2891093ba (diff) | |
tests count the changes sent
| -rw-r--r-- | src/document/sync.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/document/sync.rs b/src/document/sync.rs index f2d6669..695f272 100644 --- a/src/document/sync.rs +++ b/src/document/sync.rs @@ -918,8 +918,10 @@ mod tests { a.receive(&mut ours, decode(&ask).unwrap()).unwrap(); a.resend_if_needed(&ours, "b"); + let sent_before = a.state.sent_hashes.clone(); let again = send(&mut a, &ours); - let carried = sync::Message::decode(&again.0).unwrap().changes.len(); + // What the message carried: the changes it added to what a counts as sent. + let carried = a.state.sent_hashes.difference(&sent_before).count(); assert_eq!( carried, 1, "only the first again, not the second, on its way" @@ -956,9 +958,9 @@ mod tests { // As `resend_if_needed` does when the peer needs what we sent. a.state.sent_hashes.clear(); change(&mut ours, |doc| doc.put(ROOT, "news", 6).unwrap()); - let message = a.generate(&ours, now, bytes).unwrap(); - let carried = sync::Message::decode(&message.0).unwrap().changes.len(); - assert_eq!(carried, 1, "only the news"); + a.generate(&ours, now, bytes).unwrap(); + // What the message carried: what a counts as sent now (nothing before). + assert_eq!(a.state.sent_hashes.len(), 1, "only the news"); } /// Three messages arrive in reverse order: once the first is in, all three apply, @@ -986,7 +988,7 @@ mod tests { } assert_eq!(theirs.get_heads(), ours.get_heads()); if let Some(answer) = b.generate(&theirs, now, bytes) { - let carried = sync::Message::decode(&answer.0).unwrap().changes.len(); + let (carried, _) = decode(&answer).unwrap().sizes(); assert_eq!(carried, 0, "a's own changes went back to it"); } } |
