aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/attacks.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-16 23:49:56 +0000
committertv <tv@krebsco.de>2026-11-17 01:02:49 +0100
commitcd47b1fc79893507096d4b6b7e25f47ee8c7cdbb (patch)
treee553ded02d1c87f25ccc83e6859fa8186ba1c1c6 /src/federation/attacks.rs
parentd8b8f01b08b31f5a10dad0a0d23727a8eabc5499 (diff)
federation: each attack table checked whole, its rows marked sim too
One check of an attack table (`harness::every_row_has_its_test`), for the federation's and the store's: every row has its test among the sources of its kind, unit tests or the simulations (`simtest::holding`), but for the rows whose tests wait for later; a row marked `—` has none; no test names a row that isn't there, nor two tests one row. The rows waiting: forks, the remakes, flooding, what a node, a client or a tool does that isn't built yet, and a rule for two checkpoints proposed at once.
Diffstat (limited to 'src/federation/attacks.rs')
-rw-r--r--src/federation/attacks.rs56
1 files changed, 14 insertions, 42 deletions
diff --git a/src/federation/attacks.rs b/src/federation/attacks.rs
index a7efd50..707e0e7 100644
--- a/src/federation/attacks.rs
+++ b/src/federation/attacks.rs
@@ -1,8 +1,7 @@
//! The attacks of `docs/federation.md` marked unit, each a test named by its row
-//! (`docs/federation-tests.md`), on the federation's fold and the store in memory. A test
-//! checks that every such row has its test, or waits for a later stage.
-
-use std::collections::{BTreeMap, BTreeSet};
+//! (`docs/federation-tests.md`), on the federation's fold and the store in memory; those
+//! marked sim are simulations (`simtest::holding`). A test checks that every row has its
+//! test, or waits for a later stage.
use super::event::Checkpoint;
use super::fold::Federation;
@@ -12,9 +11,9 @@ use super::store::memory::{Offered, Refusal, Store};
use super::store::{Fold, Id};
use super::version::Version;
-/// Rows marked unit whose tests wait for a later stage: what a node, a party's client or
-/// a tool does (stage 3), and what a node tells of a fork (stage 4).
-const LATER: &[u32] = &[35, 36, 39, 45, 51, 58, 63, 65, 68];
+/// Rows whose tests wait: what a node, a party's client or a tool does (stage 3), forks
+/// (stage 4), a rule for two checkpoints proposed at once, and flooding.
+const LATER: &[u32] = &[30, 33, 35, 36, 39, 45, 51, 58, 59, 63, 65, 68];
fn tv() -> Party {
Party::new("tv", 1)
@@ -100,41 +99,14 @@ fn s(text: &str) -> Json {
}
#[test]
-fn every_row_marked_unit_has_its_test() {
- let doc = include_str!("../../docs/federation.md");
- let source = include_str!("attacks.rs");
- let rows: BTreeMap<u32, String> = doc
- .lines()
- .filter_map(|line| {
- let cells: Vec<&str> = line.split('|').map(str::trim).collect();
- let n = cells.get(1)?.parse().ok()?;
- Some((n, cells.get(4)?.to_string()))
- })
- .collect();
- let tested: BTreeSet<u32> = source
- .lines()
- .filter_map(|line| {
- line.trim()
- .strip_prefix("fn federation_attack_")?
- .split('(')
- .next()?
- .parse()
- .ok()
- })
- .collect();
- let missing: Vec<&u32> = rows
- .iter()
- .filter(|(n, kind)| kind.starts_with("unit") && !tested.contains(n) && !LATER.contains(n))
- .map(|(n, _)| n)
- .collect();
- assert!(missing.is_empty(), "rows without their test: {missing:?}");
- for n in &tested {
- assert!(rows.contains_key(n), "a test of row {n}, which isn't there");
- }
- for n in LATER {
- assert!(!tested.contains(n), "row {n} has its test now");
- assert!(rows[n].starts_with("unit"), "row {n} isn't marked unit");
- }
+fn every_row_has_its_test() {
+ harness::every_row_has_its_test(
+ include_str!("../../docs/federation.md"),
+ "federation_attack_",
+ &[include_str!("attacks.rs")],
+ &[include_str!("../simtest/holding.rs")],
+ LATER,
+ );
}
#[test]