diff options
Diffstat (limited to 'src/simtest/holding.rs')
| -rw-r--r-- | src/simtest/holding.rs | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/src/simtest/holding.rs b/src/simtest/holding.rs index 6da7a90..66d5d15 100644 --- a/src/simtest/holding.rs +++ b/src/simtest/holding.rs @@ -1822,7 +1822,11 @@ fn start_on_a_set( let party = party.to_owned(); let adjust = move |config: &mut NodeConfig| { config.store = Some(id); - config.holding = holding(&party).carrying_if(Some(set), path, Arc::new(Files::default())); + config.holding = holding(&party).carrying_if( + Some(held::Begun::Set(Box::new(set))), + path, + Arc::new(Files::default()), + ); }; if restart { sim.restart_with(name, &seeds, Start::FromDocument(Origin::Root), adjust) @@ -1928,3 +1932,54 @@ async fn a_node_of_a_set_goes_on_from_its_file() { }) .await; } + +/// a and b hold the store and a write; c is given the store's ID alone, and nothing of +/// the store: it asks the members it reaches for the root by its name, begins its set +/// from it, and catches up as any node behind. +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn a_node_of_a_set_joins_with_nothing_but_the_stores_id() { + use crate::federation::store::passing; + + let sim = Sim::with_identity(94); + let (tv, lass, _) = three(); + let (_, root, id) = federation(&[(&tv, &["a", "b"]), (&lass, &["c"])]); + let a = start_on_a_set(&sim, "a", "tv", id, a_set(&root), None, false); + let b = start_on_a_set(&sim, "b", "tv", id, a_set(&root), None, false); + sim.wait_ready(&[&a, &b], SOON).await; + let write = tv.write(&[id], "home/tv/x", s("1")); + let ids = [Id::of(&write)]; + put(&a, &[&write]).await; + + let c = sim.start_with( + "c", + &["a"], + Start::FromDocument(Origin::Root), + move |config| { + config.store = Some(id); + config.holding = holding("lass").carrying_if( + Some(held::Begun::Start(passing::Start::new( + id, + id, + Duration::from_secs(600), + ))), + None, + Arc::new(Files::default()), + ); + }, + ); + assert_eq!(c.kind(), crate::federation::store::set::KIND); + assert!(read(&c, |_| ()).is_none()); + sim.wait_ready(&[&c], SOON).await; + let (all, ids) = (&[&a, &b, &c], &ids); + sim.wait_until( + "c holds the store, the write and the entries", + SOON, + move || async move { holds(all[2], ids) && all.iter().all(|node| entries(node) == 3) }, + ) + .await; + sim.wait_until("all stand alike", SOON, move || async move { + let first = stands(all[0]); + first.is_some() && all.iter().all(|node| stands(node) == first) + }) + .await; +} |
