aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/held.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/federation/held.rs')
-rw-r--r--src/federation/held.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/federation/held.rs b/src/federation/held.rs
index cf3cf04..72633eb 100644
--- a/src/federation/held.rs
+++ b/src/federation/held.rs
@@ -2210,6 +2210,51 @@ mod tests {
assert!(holding.merge(&listed).is_empty());
}
+ /// Heads from before the version naming the revision with merge events, more than an
+ /// event may name: a merge event on the earliest of them alone would be written under
+ /// the version before, which has none, and refused. It builds on one holding the
+ /// current version too, so the backlog a revision was passed for gets merged.
+ #[test]
+ fn a_node_merges_heads_older_than_the_revision() {
+ let (tv, lass) = (Party::new("tv", 1), Party::new("lass", 2));
+ let first = Spec::first(&[&tv, &lass], &[]);
+ let root = first.root();
+ let on = first.hash();
+ let mut doc = events::started(Federation::NAME, &root, &[]).unwrap();
+ for n in 0..=event::DEPENDENCIES {
+ put(
+ &mut doc,
+ &tv.write(
+ &[Id::of(&root)],
+ &format!("home/tv/k{n}"),
+ harness::str("1"),
+ ),
+ );
+ }
+ let holding =
+ Holding::open(None, Arc::new(Files::default()), None, Some("tv".into())).unwrap();
+ read(&holding, &doc, 0);
+ // The revision passes: its version event is the head taken last.
+ let mut next = first.after(on);
+ next.revision = Feature::MergeEvents.revision();
+ let proposal = tv.propose(&[Id::of(&root)], &next.json());
+ let votes =
+ [&tv, &lass].map(|party| party.vote(&[Id::of(&proposal)], on, next.hash(), true));
+ let written = harness::version_event(&[Id::of(&votes[0]), Id::of(&votes[1])], next.hash());
+ for event in [&proposal, &votes[0], &votes[1], &written] {
+ put(&mut doc, event);
+ }
+ read(&holding, &doc, 0);
+ assert_eq!(
+ holding.with(|store| store.state().current().hash),
+ Some(next.hash())
+ );
+ let listed = crate::identity::NodeKey::from_seed([128; 32]);
+ assert!(holding.apart(&listed));
+ assert!(!holding.merge(&listed).is_empty());
+ assert!(!holding.apart(&listed));
+ }
+
/// Row 70 (`docs/federation.md`): a checkpoint's version proposed again, by an event
/// beside its heads. A node backs it all the same, as a proposal lapses with the move,
/// and votes on the event proposing it above the heads alone: a version event written