diff options
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] |
