diff options
| author | tv <tv@krebsco.de> | 2026-11-17 05:12:36 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-17 06:14:06 +0100 |
| commit | 1a7df59c2fc3b4482a1a02847b56a73a51636ba3 (patch) | |
| tree | d32c55e5889e61210ec93eaa52ef15d66c12036a /src/remake/api.rs | |
| parent | e4b709e823f70ee74574cb49367e7bee780d8584 (diff) | |
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.
Diffstat (limited to 'src/remake/api.rs')
| -rw-r--r-- | src/remake/api.rs | 15 |
1 files changed, 15 insertions, 0 deletions
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<H: Host>( + 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<H: Host>(host: &H, id: &str) -> String { |
