From 1a7df59c2fc3b4482a1a02847b56a73a51636ba3 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 05:12:36 +0000 Subject: remake: a test helper serving an epoch a node made up `testing::serve` switches a node to an epoch whose document is a snapshot it built itself, as a node serving a made-up epoch would. --- src/remake/api.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/remake') diff --git a/src/remake/api.rs b/src/remake/api.rs index 325f9ba..f2330e7 100644 --- a/src/remake/api.rs +++ b/src/remake/api.rs @@ -996,6 +996,21 @@ pub(crate) mod testing { into_json(abort_by_id(host, id.to_owned(), query, Some(user.to_owned())).await).await } + /// What a node serving an epoch it made up does: switches to `epoch`, its document + /// `doc` (that epoch's snapshot alone), written to by a fresh writer. + pub(crate) async fn serve( + host: &H, + epoch: crate::document::replica::Epoch, + doc: crate::document::Document, + ) { + let node = host.node_id(); + let mut doc = doc.with_actor(crate::document::ActorId::random()); + crate::document::replica::authored(&mut doc, &node); + host.switch_epoch(epoch, move |_| Ok::<_, ()>(doc)) + .await + .expect("switched to the epoch"); + } + /// What a coordinator proposing against the protocol does: proposes remake `id`'s /// proposal again, under a new ID, whatever is open. The new ID. pub(crate) async fn propose_again(host: &H, id: &str) -> String { -- cgit v1.3.1