summaryrefslogtreecommitdiffstats
path: root/src/federation/judge.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/federation/judge.rs')
-rw-r--r--src/federation/judge.rs60
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.