#![cfg(feature = "dangerous-test-hooks")]
use bvisor::__sim::{run_gate, GateScenario, GATE_SCENARIOS};
#[test]
fn grid_g1_through_g13_bites() -> Result<(), String> {
assert_eq!(GATE_SCENARIOS.len(), 13, "the grid must enumerate G1..G13");
for scenario in GATE_SCENARIOS {
let outcome = run_gate(scenario)
.map_err(|v| format!("gate {} must bite, not run vacuous: {v}", scenario.gate))?;
assert!(
outcome.caught,
"gate {} failed to catch its lie (vacuous gate)",
scenario.gate
);
}
Ok(())
}
#[test]
fn grid_is_deterministic() -> Result<(), String> {
for scenario in GATE_SCENARIOS {
let a = run_gate(scenario).map_err(|v| v.to_string())?;
let b = run_gate(scenario).map_err(|v| v.to_string())?;
assert_eq!(
a, b,
"PROPERTY: gate {} must run to an identical outcome + digest",
scenario.gate
);
}
Ok(())
}
#[cfg(gauntlet_red_fixture)]
#[test]
fn grid_red_fixture_lie_must_escape() -> Result<(), String> {
use bvisor::__sim::{GateKind, GateOutcome};
let g4 = GATE_SCENARIOS
.iter()
.copied()
.find(|s| s.gate == "G4")
.ok_or_else(|| "the grid must include G4 (no-spawn-when-denied)".to_string())?;
assert!(
matches!(g4.kind, GateKind::OracleCatch(_)),
"the red fixture must target an oracle-catch gate, got {:?}",
g4.kind
);
let outcome: GateOutcome = run_gate(g4).map_err(|v| v.to_string())?;
assert!(
!outcome.caught,
"RED FIXTURE: asserts the (illegal) lie-uncaught outcome on G4; MUST fail because the \
oracle always catches a spawn-despite-deny lie"
);
Ok(())
}
#[test]
fn grid_gate_ids_are_unique() {
let mut ids: Vec<&str> = GATE_SCENARIOS
.iter()
.map(|s: &GateScenario| s.gate)
.collect();
ids.sort_unstable();
let unique = {
let mut u = ids.clone();
u.dedup();
u
};
assert_eq!(ids, unique, "every grid gate id must be unique");
}