`sandbox demo` and `sandbox confidential` run no unit: they build a run report and seal it to show the receipt and attestation formats. They sealed literal records — CPU measured_uj Some(2_000) and GPU Some(50_000), both HwShunt — so every receipt claimed hardware readings of work that never happened (SPEC §6.3: HwShunt is read from a hardware interface for that device class). Each record is now `illustrative()`: the same estimated figure, graded Estimator, with no measured figure. The demo says it is illustrative, its measured line says "none (illustrative figures, sealed as estimates)" rather than "partial", and confidential prints each sealed run's energy record so its grade is visible. run-wasm, which meters a real unit, is unchanged. Tests: a unit test checks both reports carry only Estimator records with no measured figure; tests/illustrative_runs.rs runs the built binary and checks every printed record is [Estimator], none carries meas=, and no line says HwShunt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
27 lines
1.3 KiB
Rust
27 lines
1.3 KiB
Rust
//! `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}");
|
|
}
|
|
}
|