From 345977eb749ebaa73632830cea42f19ce01e0ef1 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 03:32:39 +0000 Subject: events: the tests put events at time 0 The same events put by the same writer make the same change, so that a document built of them in a test is the same bytes on every run. --- src/document/events.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/document/events.rs') diff --git a/src/document/events.rs b/src/document/events.rs index 37f1c70..5cc9943 100644 --- a/src/document/events.rs +++ b/src/document/events.rs @@ -249,20 +249,22 @@ pub(crate) fn is_genesis(change: &Change, fold: &str, id: &Id) -> bool { root.is_some_and(|root| genesis(fold, &root).hash() == change.hash()) } -/// `events`, each at its ID, put into `doc` by one change. +/// `events`, each at its ID, put into `doc` by one change, at time 0: the same events put +/// by the same writer make the same change. #[cfg(test)] pub(crate) fn put(doc: &mut Document, events: &[&[u8]]) { - super::testing::change(doc, |doc| { + super::testing::try_change(doc, |doc| { for bytes in events { store::write_val_path( doc, &event(&Id::of(bytes)), &Val::Scalar(ScalarValue::Bytes(bytes.to_vec())), store::Writing::sticky(TimestampFormat::default()), - ) - .expect("an event written"); + )?; } - }); + Ok::<(), store::StoreError>(()) + }) + .expect("events written"); } #[cfg(test)] -- cgit v1.3.1