"""Confirmatory data-collection executor — anti-fabrication guard + real pcap measurement. The heavy live-docker path is exercised by the operator rehearsal; here we pin the offline invariants that keep the confirmatory DVs honest. """ import struct import pytest from cmd_chat.sor import executor def test_run_battery_refuses_non_live(): # The executor collects DVs ONLY from real delivered circuits — never a # synthetic/dry confirmatory path. with pytest.raises(executor.ExecutorError): executor.run_battery("output/never", r_runs=1, c_circuits=1, live=False) def test_measure_flow_refuses_missing_pcap(): with pytest.raises(executor.ExecutorError): executor._measure_flow({0: "only-ingress"}, last_hop=2, bins=8) def test_bin_pcap_bytes_refuses_unreadable(tmp_path): bad = tmp_path / "not.pcap" bad.write_bytes(b"not a pcap file") with pytest.raises(executor.ExecutorError): executor.bin_pcap_bytes(bad, bins=8) def _write_minimal_pcap(path, packets): """A minimal little-endian pcap (LINKTYPE_RAW=101) with the given (ts, payload) packets, so we can exercise real binning without docker.""" with open(path, "wb") as f: # global header: magic, ver 2.4, tz/sig 0, snaplen, network=101 (RAW) f.write(struct.pack("