summaryrefslogtreecommitdiffstats
path: root/src/remake/api.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/remake/api.rs')
-rw-r--r--src/remake/api.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/remake/api.rs b/src/remake/api.rs
index 309bdbd..52338dd 100644
--- a/src/remake/api.rs
+++ b/src/remake/api.rs
@@ -1063,4 +1063,34 @@ pub(crate) mod testing {
let report = load_report(host, id).await?;
Some(serde_json::to_value(report).expect("report"))
}
+
+ /// One line per remake record, for test failures: phase, timing (relative to now),
+ /// decision and tally.
+ pub(crate) async fn describe<H: Host>(host: &H) -> Vec<String> {
+ let (all, register) = host
+ .read_doc(|doc| (records::load_all(doc), records::load_register(doc)))
+ .await;
+ let now = host.now_millis();
+ let grace = host.dormant_after().as_millis() as u64;
+ let relative = |at: UnixMillis| at.0 as i64 - now.0 as i64;
+ all.iter()
+ .map(|(id, record)| {
+ let proposal = &record.proposal;
+ format!(
+ "remake {id}: phase={:?} coordinator={} from={:?} proposed_at={}ms \
+ settle_until={}ms tally=({}) decision={:?} abort_requested={} \
+ contested={}",
+ record.phase(now, grace),
+ proposal.coordinator,
+ proposal.from_epoch,
+ relative(proposal.proposed_at),
+ relative(proposal.settle_until),
+ vote::tally(id, record, &all, &register),
+ record.decision,
+ record.abort_requested.is_some(),
+ record.contested,
+ )
+ })
+ .collect()
+ }
}