diff options
Diffstat (limited to 'src/document/sync.rs')
| -rw-r--r-- | src/document/sync.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/document/sync.rs b/src/document/sync.rs index dc286fa..625d805 100644 --- a/src/document/sync.rs +++ b/src/document/sync.rs @@ -384,11 +384,12 @@ mod tests { /// trip (`answer_for_everything_since_shared`). #[test] fn missing_predecessors_go_at_once() { + use crate::document::testing::change; use automerge::transaction::Transactable; let mut a = Document::new(); let mut b = Document::new(); let (mut at_a, mut at_b) = (sync::State::new(), sync::State::new()); - a.put(automerge::ROOT, "early", 1).unwrap(); + change(&mut a, |a| a.put(automerge::ROOT, "early", 1).unwrap()); // Until in step. for _ in 0..10 { let to_b = a.sync().generate_sync_message(&mut at_a); @@ -406,12 +407,12 @@ mod tests { assert_eq!(a.get_heads(), b.get_heads()); // Five changes, whose message is lost; then a sixth, which arrives alone. for i in 0..5 { - a.put(automerge::ROOT, format!("lost{i}"), i).unwrap(); - a.commit(); + change(&mut a, |a| { + a.put(automerge::ROOT, format!("lost{i}"), i).unwrap() + }); } let _lost = a.sync().generate_sync_message(&mut at_a).unwrap(); - a.put(automerge::ROOT, "last", 6).unwrap(); - a.commit(); + change(&mut a, |a| a.put(automerge::ROOT, "last", 6).unwrap()); at_a.in_flight = false; // As after our reply timeout. let last = a.sync().generate_sync_message(&mut at_a).unwrap(); assert_eq!(last.changes.len(), 1); @@ -467,6 +468,7 @@ mod tests { /// overdue answer, gets the same changes in the next message. #[test] fn withdrawing_for_a_delta_keeps_the_changes_for_later() { + use crate::document::testing::change; use automerge::{ROOT, transaction::Transactable}; // 16 KiB of hex, about 8 KiB of information: Automerge compresses what it sends @@ -476,8 +478,7 @@ mod tests { .map(|_| format!("{:016x}", rng.next_u64())) .collect(); let mut ours = Document::new(); - ours.put(ROOT, "big", big).unwrap(); - ours.commit(); + change(&mut ours, |ours| ours.put(ROOT, "big", big).unwrap()); let mut theirs = Document::new(); let (mut a, mut b) = (session(), session()); let now = Instant::now(); @@ -515,6 +516,7 @@ mod tests { /// has everything (`have_all_theirs`). #[test] fn after_a_delta_the_peer_learns_our_heads() { + use crate::document::testing::change; use automerge::{ROOT, transaction::Transactable}; let mut rng = crate::testrand::Rng::new(2); @@ -522,8 +524,7 @@ mod tests { .map(|_| format!("{:016x}", rng.next_u64())) .collect(); let mut ours = Document::new(); - ours.put(ROOT, "big", big).unwrap(); - ours.commit(); + change(&mut ours, |ours| ours.put(ROOT, "big", big).unwrap()); let mut theirs = Document::new(); let (mut a, mut b) = (session(), session()); let now = Instant::now(); |
