diff options
| author | tv <tv@krebsco.de> | 2026-11-19 12:46:42 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-19 13:52:29 +0100 |
| commit | 03105d40322dff9c18f0571872ab0f643aded0f7 (patch) | |
| tree | a96b625f4d57d23ee12a6db72780446530b413cd /src/federation/judge.rs | |
| parent | e8f0760a9b08e6b1a7372e79c48744035d1e4e1a (diff) | |
federation: checked against the release a federation-<F>.<R> tag namesfederation-1.1
A corpus of generated histories, committed, said what this code made of them, right or
not, and held hundreds of kilobytes a revision; generated from code that changes, it
could only be checked, never written again.
Each release that makes a revision is tagged `federation-<F>.<R>`, the federation's
number and the revision's (`federation-1.1`, revision 1 of federation 1).
`scripts/federation-check` writes histories from this tree (`write_histories`, an ignored
test): of each revision it knows and each kind the properties generate, those of a few
seeds from a random one it says, and the attack tests' crafted ones, as each test offered
them where nothing but offers made them. It judges them with `continuum-party judge` here
and with the continuum the latest such tag names (or one given), built in a worktree and
kept between runs, leaves out those whose root the tagged one reads as none, and says
where the two differ. Run before a release, not by `cargo quick`.
The corpus and its test are gone; the test plan and `federation.md` say how a release is
checked.
Diffstat (limited to 'src/federation/judge.rs')
| -rw-r--r-- | src/federation/judge.rs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/federation/judge.rs b/src/federation/judge.rs index 4fc4ce8..2936bdc 100644 --- a/src/federation/judge.rs +++ b/src/federation/judge.rs @@ -142,7 +142,67 @@ fn reads(store: &Store<Federation>) -> String { #[cfg(test)] mod tests { use super::*; + use crate::federation::attacks; use crate::federation::harness::{self, Party, Spec}; + use crate::federation::properties::{self, Kind}; + use crate::federation::revision::Revision; + use crate::testrand::Rng; + + /// Of each revision and kind, how many seeds' histories are written, times + /// `CONTINUUM_TEST_CASES`. + const CASES: u64 = 25; + + /// Writes the histories to judge to the file `CONTINUUM_HISTORIES` names + /// (`scripts/federation-check`): of each revision this continuum knows and each kind + /// the properties generate, the histories of `CASES` seeds from `CONTINUUM_TEST_SEED` + /// on; and those the attack tests offer, where nothing but offers made them. + #[test] + #[ignore = "writes the file CONTINUUM_HISTORIES names: run by scripts/federation-check"] + fn write_histories() { + let path = std::env::var("CONTINUUM_HISTORIES").expect("CONTINUUM_HISTORIES: a file"); + let env = |name: &str| { + std::env::var(name) + .ok() + .and_then(|value| value.parse::<u64>().ok()) + }; + let first = env("CONTINUUM_TEST_SEED").unwrap_or(0); + let cases = CASES.saturating_mul(env("CONTINUUM_TEST_CASES").unwrap_or(1)); + let mut histories = Vec::new(); + for revision in Revision::known() { + for adversary in [false, true] { + for checkpoints in [false, true] { + for unread in [false, true] { + let kind = Kind { + adversary, + checkpoints, + unread, + }; + for seed in first..first.saturating_add(cases) { + let generated = + properties::generate_at(&mut Rng::new(seed), kind, Some(revision)); + histories.push(History { + label: format!("{revision}, seed {seed}, {kind:?}"), + root: generated.root, + events: generated.events, + }); + } + } + } + } + } + for (name, test) in attacks::TESTS { + for (n, recorded) in attacks::recording(*test).into_iter().enumerate() { + if recorded.offers_only { + histories.push(History { + label: format!("{name}, store {n}"), + root: recorded.root, + events: recorded.events, + }); + } + } + } + std::fs::write(&path, spelled(&histories)).expect("the histories written"); + } /// Histories read back as spelled, and judged as the format says: an event taken, one /// refused, and a root of a revision this continuum doesn't know read as none. |
