diff options
| author | tv <tv@krebsco.de> | 2026-11-19 04:02:52 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-19 05:13:51 +0100 |
| commit | 2c9d42ed955705a0207b047918f58ef258dcfa4f (patch) | |
| tree | b8d50ee2fdce459a4b61fff4e8bddff6d308da8e /src/federation/properties.rs | |
| parent | 0d2467e15ec0c9c035b1074a2dd4eece6b24c599 (diff) | |
federation: a corpus per revision, judged alike by every later continuum
Nothing checked that judging under a revision stays what it was: a change to the fold
that alters what an earlier revision takes, refuses or reads parts nodes running it from
nodes that don't, and the tests regenerate their expectations with the code.
For each revision this continuum knows, a file in `src/federation/corpus/` holds
histories generated at that revision, of every kind the properties generate, each event's
bytes with what became of it, by kind and never by a refusal's words, and what the store
reads after; its first line names the revision by its ID. It is written once, as the
revision is made (`write_the_corpus`, an ignored test run by hand), and never edited
after; every later continuum judges it alike (`every_revision_judges_as_its_corpus_says`),
which fails where a revision has no corpus yet, saying how to write it.
The test plan describes it.
Diffstat (limited to 'src/federation/properties.rs')
| -rw-r--r-- | src/federation/properties.rs | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/federation/properties.rs b/src/federation/properties.rs index 214bb27..b45b664 100644 --- a/src/federation/properties.rs +++ b/src/federation/properties.rs @@ -17,7 +17,7 @@ use super::harness::{self, Party, Spec}; use super::held::Holding; use super::jcs::Json; use super::model::{Model, Verdict}; -use super::revision::Feature; +use super::revision::{Feature, Revision}; use super::store::memory::{Offered, Refusal, Store}; use super::store::{Fold, Id}; use super::version::Version; @@ -30,9 +30,9 @@ const MOST: usize = 30; /// A root, and events in the order written. #[derive(Clone)] -struct History { - root: Vec<u8>, - events: Vec<Vec<u8>>, +pub(super) struct History { + pub(super) root: Vec<u8>, + pub(super) events: Vec<Vec<u8>>, } impl History { @@ -87,11 +87,11 @@ impl History { /// How a history is written: whether an adversary takes part, whether versions name /// checkpoints, and whether parties propose versions this continuum doesn't read, at /// which a store stops, which events then take in the order they come. -#[derive(Clone, Copy)] -struct Kind { - adversary: bool, - checkpoints: bool, - unread: bool, +#[derive(Clone, Copy, Debug)] +pub(super) struct Kind { + pub(super) adversary: bool, + pub(super) checkpoints: bool, + pub(super) unread: bool, } /// One of `ids`, of the latest five more often than not. @@ -104,6 +104,12 @@ fn pick(rng: &mut Rng, ids: &[Id]) -> Id { } fn generate(rng: &mut Rng, kind: Kind) -> History { + generate_at(rng, kind, None) +} + +/// A history of `kind`, its first version following `revision`, or, where none is given, +/// the base revision or one with merge events alike. +pub(super) fn generate_at(rng: &mut Rng, kind: Kind, revision: Option<Revision>) -> History { let count = rng.between(3, 5); let parties: Vec<Party> = (0..count) .map(|i| Party::new(&format!("p{i}"), i as u8 + 1)) @@ -112,9 +118,12 @@ fn generate(rng: &mut Rng, kind: Kind) -> History { let refs: Vec<&Party> = parties.iter().collect(); let mut first = Spec::first(&refs, &[("names/{party}", harness::str("{party}"))]); // Half the federations begin at a revision with merge events, which nodes then sign. - if rng.chance(0.5) { - first.revision = Feature::MergeEvents.revision(); - } + let merging = rng.chance(0.5); + first.revision = revision.unwrap_or(if merging { + Feature::MergeEvents.revision() + } else { + Revision::default() + }); let root = first.root(); let root_id = Id::of(&root); let mut world: Store<Federation> = Store::new(root.clone(), Vec::new()).expect("a root"); |
