tests: a run_world past the allowance spends nothing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-12-03 13:36:50 +01:00
commit d34a8f6ffa

View file

@ -972,7 +972,7 @@ pub(crate) mod tests {
/// What `run_world` of the gatehouse does to a timeline whose clock
/// has not moved, with the wave lane allowing `wave` tokens: the wave it
/// froze, whether the Warden acted, and the knobs after.
async fn forced_wave(wave: u64) -> (WaveRecord, bool, DmKnobs, usize) {
async fn forced_wave(wave: u64) -> (WaveRecord, bool, DmKnobs, u64) {
let fixture = Fixture::unwatched().await;
let port = ScriptedPort::new(vec![]);
let (timelines, _stopped) = fixture.open(port.clone());
@ -991,7 +991,9 @@ pub(crate) mod tests {
let log = host.world.operator_log().await.unwrap();
let wave = wave_of(&host, seq).await.expect("the asked-for node froze a wave though nothing was due");
let acted = log.iter().any(|act| act.speaker_label == "Warden");
(wave, acted, host.knobs.lock().await.current(), port.seen_requests().len())
let window = ghostlight::RunId::new(&format!("window-{}", wave.revision)).unwrap();
let spent = host.background.lane_spent(&window).unwrap().wave;
(wave, acted, host.knobs.lock().await.current(), spent)
}
/// Spec test `run_world forces within allowance`: a node the DM named runs
@ -999,7 +1001,7 @@ pub(crate) mod tests {
/// the request with it.
#[tokio::test]
async fn run_world_runs_a_node_that_is_not_due() {
let (wave, acted, after, requests) = forced_wave(200_000).await;
let (wave, acted, after, spent) = forced_wave(200_000).await;
let report = wave.report.expect("closed");
assert_eq!(report.nodes.len(), 1);
assert_eq!(report.nodes[0].label, "Gatehouse");
@ -1007,7 +1009,7 @@ pub(crate) mod tests {
assert_eq!(wave.opened_now, 0, "no time had passed: only the DM's ask made it due");
assert_eq!(wave.forced.len(), 1);
assert!(after.forced.is_empty(), "the wave took the request");
assert_eq!(requests, 3, "the DM's round, its narration and the Warden's turn");
assert!(spent > 0, "the turn was charged to the wave lane");
}
/// The same ask with the wave allowance spent: the node is reported
@ -1015,11 +1017,11 @@ pub(crate) mod tests {
/// is still the wave's, not carried to the next.
#[tokio::test]
async fn a_run_world_past_the_allowance_is_reported_deferred() {
let (wave, acted, after, requests) = forced_wave(0).await;
let (wave, acted, after, spent) = forced_wave(0).await;
let report = wave.report.expect("a budget stop closes the wave");
assert!(report.out_of_allowance);
assert!(report.waiting.iter().any(|node| node.reason == Deferral::Allowance), "{report:?}");
assert!(!acted && requests == 2, "the Warden never reached the provider");
assert!(!acted && spent == 0, "the call was refused before the provider: nothing committed, nothing spent");
assert!(after.forced.is_empty());
}