//! `sandbox demo` and `sandbox confidential` run no unit: every energy record //! of the receipts they seal, as the binary prints them back, is an estimate — //! `[Estimator]`, with no measured figure — and no line claims a hardware //! reading. Run as a user runs them, through the built binary. use std::process::Command; fn run(cmd: &str) -> String { let out = Command::new(env!("CARGO_BIN_EXE_sandbox")).arg(cmd).output().expect("run the sandbox binary"); assert!(out.status.success(), "sandbox {cmd} failed: {}", String::from_utf8_lossy(&out.stderr)); String::from_utf8(out.stdout).expect("utf-8 output") } #[test] fn the_illustrative_runs_print_estimates_only() { for cmd in ["demo", "confidential"] { let out = run(cmd); eprintln!("sandbox {cmd}:\n{out}"); let records: Vec<&str> = out.lines().filter(|l| l.contains(" est=")).collect(); assert!(!records.is_empty(), "sandbox {cmd} printed no energy record:\n{out}"); for r in &records { assert!(r.trim_end().ends_with("[Estimator]"), "sandbox {cmd}: a record of no work not graded an estimate: {r}"); assert!(!r.contains("meas="), "sandbox {cmd}: a measured figure nothing read: {r}"); } assert!(!out.contains("HwShunt"), "sandbox {cmd} claims a hardware reading:\n{out}"); } }