diff options
| author | tv <tv@krebsco.de> | 2026-11-18 17:23:18 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-18 18:30:32 +0100 |
| commit | f261a80b88c1fb640f4c892934809e15a7e05a95 (patch) | |
| tree | b899d8994ab6fd320d0094c8e6e56487c73cc53d /src/federation/client.rs | |
| parent | d130c0612b4c63f2d30da65ebcc231018c1f2606 (diff) | |
attacks: rows 45, 58 and 65 tested beside the code they test
The check that every attack row of the federation has its test looks
beside the code a row is about too: a node's (`held`), a party's client's
(`client`), and a node voting by itself (`vote`). Rows 45 (a version
written on the side a node doesn't read, refused as its own and reported
apart, the change that put it taken), 58 (a node following on
checkpoints only, unless its operator chose any version) and 65 (a
client keeping the nays that freed its `true`) have their tests there,
and wait no more.
Diffstat (limited to 'src/federation/client.rs')
| -rw-r--r-- | src/federation/client.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/federation/client.rs b/src/federation/client.rs index 88e370f..c5d3651 100644 --- a/src/federation/client.rs +++ b/src/federation/client.rs @@ -719,6 +719,38 @@ mod tests { assert!(again.contains(&Id::of(&later)) && again.contains(&Id::of(&keys))); } + /// Row 65 (`docs/federation.md`): after a checkpoint, a party backs a second proposal + /// once its first is dead, and those who killed the first withhold their nays: its + /// client kept them with its `true`, so its record doesn't name it as voting twice. + #[test] + fn federation_attack_65() { + let (tv, lass, makefu, first, current, one, two) = three(); + let root = Id::of(b"root"); + let mut record = Record::begin(root, "tv", ¤t); + record.began = Id::of(b"earlier").to_string(); + record.cast( + ¤t, + &tv.vote(&[root], first.hash(), one.hash(), true), + Vec::new(), + ); + let nays = [ + lass.vote(&[root], first.hash(), one.hash(), false), + makefu.vote(&[root], first.hash(), one.hash(), false), + ]; + let kept = record + .may_vote(¤t, two.hash(), &two.json(), true, &nays) + .unwrap(); + record.cast( + ¤t, + &tv.vote(&[root], first.hash(), two.hash(), true), + kept, + ); + assert!(voted_twice(std::slice::from_ref(&record)).is_empty()); + // Without the nays it kept, its two `true` are voting twice. + record.nays.clear(); + assert_eq!(voted_twice(&[record]).len(), 1); + } + /// A party backs, and proposes, only a version changing the current one whose /// checkpoint, where it names one, names none of the current checkpoint's heads. #[test] |
