diff options
Diffstat (limited to 'src/federation/properties.rs')
| -rw-r--r-- | src/federation/properties.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/federation/properties.rs b/src/federation/properties.rs index 02c7799..214bb27 100644 --- a/src/federation/properties.rs +++ b/src/federation/properties.rs @@ -1,7 +1,7 @@ //! The federation's properties over generated histories (`docs/federation-tests.md`, //! Properties): three to five parties write, change their key sets and node lists, propose //! versions and checkpoints, vote, and write the versions that pass, each on what it last -//! caught up with; an adversary signs with its keys or stolen ones whatever it likes. The +//! caught up with, and their nodes merge; an adversary signs with its keys or stolen ones whatever it likes. The //! store is checked against the model, which reads every history anew, against itself in //! other orders, and read from a document against itself given the events alone. A //! failing history is cut down, events taken out with what builds on them for as long as @@ -17,6 +17,7 @@ use super::harness::{self, Party, Spec}; use super::held::Holding; use super::jcs::Json; use super::model::{Model, Verdict}; +use super::revision::Feature; use super::store::memory::{Offered, Refusal, Store}; use super::store::{Fold, Id}; use super::version::Version; @@ -109,7 +110,11 @@ fn generate(rng: &mut Rng, kind: Kind) -> History { .collect(); let adversary = count - 1; let refs: Vec<&Party> = parties.iter().collect(); - let first = Spec::first(&refs, &[("names/{party}", harness::str("{party}"))]); + let mut first = Spec::first(&refs, &[("names/{party}", harness::str("{party}"))]); + // Half the federations begin at a revision with merge events, which nodes then sign. + if rng.chance(0.5) { + first.revision = Feature::MergeEvents.revision(); + } let root = first.root(); let root_id = Id::of(&root); let mut world: Store<Federation> = Store::new(root.clone(), Vec::new()).expect("a root"); @@ -146,7 +151,10 @@ fn generate(rng: &mut Rng, kind: Kind) -> History { .filter(|(id, ..)| known[w].contains(id)) .collect(); let roll = rng.below(100); - let event = if roll < 35 || (roll >= 60 && mine.is_empty()) { + let event = if roll < 4 { + // A node merges, its party's or not. + harness::merge(&party.name, rng.below(10) as u8, &deps) + } else if roll < 35 || (roll >= 60 && mine.is_empty()) { let path = format!("home/{}/k{}", party.name, rng.below(3)); writer.write(&deps, &path, harness::str(&step.to_string())) } else if roll < 43 { |
