From be8518f1c69158e3ac4c1501fea027854cc45d13 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 11:39:08 +0000 Subject: simtest: row 15's made-up epoch is of a higher ID than the others' Of a lower one, the others try to rejoin it every so often, as in row 31, and f, rejoining their epoch, finds them away mid-sync and gives up for that, not for its checkpoint. Of a higher ID, they leave it alone; e, reaching only d, still takes it, as one joining takes the newer generation. --- src/simtest/holding.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/simtest') diff --git a/src/simtest/holding.rs b/src/simtest/holding.rs index 743e354..a7fc116 100644 --- a/src/simtest/holding.rs +++ b/src/simtest/holding.rs @@ -1407,12 +1407,13 @@ async fn store_attack_30() { } /// A swarm on the epoch of a compaction whose snapshot holds a checkpoint, and d, of -/// makefu, serving an epoch of that generation it made up, of a lower ID, whose snapshot -/// holds the root and tv's write alone, as the document stood before the checkpoint: -/// the simulation, its nodes (a, b, c, d), the federation's first version and ID, tv's -/// write, and the two epochs. +/// makefu, serving an epoch of that generation it made up, of a `lower` ID or a higher, +/// whose snapshot holds the root and tv's write alone, as the document stood before the +/// checkpoint: the simulation, its nodes (a, b, c, d), the federation's first version +/// and ID, tv's write, and the two epochs. async fn made_up_epoch( seed: u64, + lower: bool, ) -> ( Sim, Vec, @@ -1496,8 +1497,8 @@ async fn made_up_epoch( ) .expect("a snapshot") }) - .find(|snapshot| snapshot.epoch.id < honest.id) - .expect("a lower epoch"); + .find(|snapshot| (snapshot.epoch.id < honest.id) == lower) + .expect("an epoch"); let lower = made_up.epoch; assert!(events::checkpoint(&made_up.doc).is_none()); crate::remake::testing::serve(&nodes[3], lower, made_up.doc).await; @@ -1519,7 +1520,8 @@ fn not_followed(node: &AppState) -> bool { /// epoch, whose checkpoint it neither builds nor has pinned. #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn store_attack_15() { - let (sim, nodes, _, id, head, _, lower) = made_up_epoch(97).await; + // Of a higher ID than the others', which so leave it alone. + let (sim, nodes, _, id, head, _, made_up) = made_up_epoch(97, false).await; let away: [(&str, &[&str]); 2] = [("e", &["a", "b", "c", "f"]), ("f", &["d", "e"])]; for (joiner, others) in away { for other in others { @@ -1535,7 +1537,9 @@ async fn store_attack_15() { sim.wait_until( "e takes the made-up epoch, with tv's write", Duration::from_secs(60), - move || async move { e.local_epoch() == lower && e.is_ready().await && holds(e, &[head]) }, + move || async move { + e.local_epoch() == made_up && e.is_ready().await && holds(e, &[head]) + }, ) .await; let d = &nodes[3]; @@ -1559,7 +1563,7 @@ async fn store_attack_15() { /// pinned, and stays where it is, taking what is written on. #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn store_attack_31() { - let (sim, nodes, _, _, head, honest, _) = made_up_epoch(98).await; + let (sim, nodes, _, _, head, honest, _) = made_up_epoch(98, true).await; let all = &nodes; sim.wait_until( "a, b and c don't follow d's epoch", -- cgit v1.3.1