aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/attacks.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/federation/attacks.rs')
-rw-r--r--src/federation/attacks.rs48
1 files changed, 45 insertions, 3 deletions
diff --git a/src/federation/attacks.rs b/src/federation/attacks.rs
index 531dca7..e1d2936 100644
--- a/src/federation/attacks.rs
+++ b/src/federation/attacks.rs
@@ -5,15 +5,16 @@
use super::event::Checkpoint;
use super::fold::Federation;
+use super::fork;
use super::harness::{self, Party, Spec};
use super::jcs::Json;
use super::store::memory::{Offered, Refusal, Store};
use super::store::{Fold, Id};
use super::version::Version;
-/// Rows whose tests wait: what a node, a party's client or a tool does (stage 3), forks
-/// (stage 4), and flooding.
-const LATER: &[u32] = &[30, 33, 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), a fork
+/// whose root differs, simulated (stage 4), and flooding.
+const LATER: &[u32] = &[30, 33, 39, 45, 51, 58, 63, 65, 68];
fn tv() -> Party {
Party::new("tv", 1)
@@ -688,6 +689,47 @@ fn federation_attack_34() {
assert!(fed.store.fork(&[here], &elsewhere.json().bytes()).is_err());
}
+/// A fork at heads of its founder's choosing, leaving out a write of lass's: a node
+/// holding the federation builds its root, and is told what those heads lack.
+#[test]
+fn federation_attack_35() {
+ let mut fed = three();
+ let root = fed.root();
+ let here = fed.take(tv().write(&[root], "home/tv/a", s("1")));
+ let beside = fed.take(lass().write(&[root], "home/lass/b", s("1")));
+ let mut forking = fed.first.after(fed.first.hash());
+ forking.parties[0].nodes_since = 1;
+ let file = fork::make(&fed.store, &[here], &forking.json()).expect("a fork");
+ let (fork_root, _) = fork::read_root_file(&file);
+ let check = fork::check(&fed.store, &fork_root).expect("checked");
+ assert!(check.builds);
+ assert_eq!(check.lacking, vec![beside]);
+}
+
+/// A fork's version giving lass, who didn't go, a key of its founder's: a node holding
+/// the federation is told, party by party.
+#[test]
+fn federation_attack_36() {
+ let mut fed = three();
+ let root = fed.root();
+ let here = fed.take(tv().write(&[root], "home/tv/a", s("1")));
+ let mut forking = fed.first.after(fed.first.hash());
+ forking.parties[1].keys = vec![harness::key_line(9)];
+ forking.parties[1].keys_since = 1;
+ let file = fork::make(&fed.store, &[here], &forking.json()).expect("a fork");
+ let (fork_root, _) = fork::read_root_file(&file);
+ let check = fork::check(&fed.store, &fork_root).expect("checked");
+ assert!(check.builds);
+ assert_eq!(
+ check.keys,
+ vec![(
+ "lass".to_owned(),
+ vec![lass().key_line()],
+ vec![harness::key_line(9)]
+ )]
+ );
+}
+
#[test]
fn federation_attack_37() {
let mut fed = three();