aboutsummaryrefslogtreecommitdiffstats
path: root/src/simtest
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-17 00:58:13 +0000
committertv <tv@krebsco.de>2026-11-17 02:03:19 +0100
commit283c6a131d0bbb8ea7b6ffe87da1a14d457fd63d (patch)
tree85bca3b029b7d7f62c34b2085bee59c5be4fecfe /src/simtest
parent983db446089bd35d34a273fc60aabd24b7d888eb (diff)
peer: a member's message before its handshake was taken asks for one
In a swarm holding a store, a node reads a peer's messages only by the party its handshake named. One whose handshake it hasn't taken (its reply lost, say) was cut off at its next message, as a non-member is, while the peer, which took ours, synced on, and neither said HELLO again. Now such a message goes unread, and the node says HELLO to the peer, as to any whose reply it waits for (`hello_again_now`): its reply names its party. What a peer refused as a non-member sends next is known to be a non-member's, its party kept, so that it asks for no HELLO. A simulation loses a's replies to b for a while.
Diffstat (limited to 'src/simtest')
-rw-r--r--src/simtest/holding.rs44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/simtest/holding.rs b/src/simtest/holding.rs
index 3ab8582..ed6a9a5 100644
--- a/src/simtest/holding.rs
+++ b/src/simtest/holding.rs
@@ -23,9 +23,11 @@ use crate::federation::version::Version;
use crate::federation::vote::Rules;
use crate::files::Files;
use crate::node::NodeConfig;
-use crate::state::AppState;
+use crate::state::{AppState, HelloState};
use crate::swarm::bootstrap::{Origin, Start};
use crate::swarm::topology;
+use crate::transport::MessageKind;
+use crate::transport::sim::LinkParams;
/// How long a test waits for what takes a few rounds of syncs, writes and reads.
const LONG: Duration = Duration::from_secs(30);
@@ -300,6 +302,46 @@ async fn the_events_put_on_a_member_reach_every_member_alone() {
assert!(events::ids(&d.doc.read().await.doc).is_empty());
}
+/// b's HELLO reaches a, a's reply doesn't: a takes b's handshake and syncs with it, and b,
+/// which hasn't taken a's, reads none of it, but says HELLO again; once a's replies come
+/// through, they sync.
+#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
+async fn a_member_whose_reply_was_lost_is_asked_for_its_handshake() {
+ let sim = Sim::with_identity(91);
+ let (tv, lass, _) = three();
+ let (_, root, id) = federation(&[(&tv, &["a"]), (&lass, &["b"])]);
+ sim.net.set_link(
+ "a",
+ "b",
+ LinkParams {
+ drop: vec![MessageKind::HelloReply],
+ ..LinkParams::default()
+ },
+ );
+ let a = sim.start_with("a", &[], Start::FromDocument(Origin::Root), |config| {
+ of_the_store(config, id, Some(&root), holding("tv"))
+ });
+ let b = sim.start_with("b", &["a"], Start::FromDocument(Origin::Root), |config| {
+ of_the_store(config, id, Some(&root), holding("lass"))
+ });
+ sim.wait_ready(&[&a, &b], SOON).await;
+ let (on_a, b_id) = (&a, b.local_id().to_owned());
+ sim.wait_until("a took b's handshake", SOON, move || {
+ let b_id = b_id.clone();
+ async move {
+ match on_a.get_peer_state(&b_id).await {
+ Some(peer) => peer.lock().await.hello_state == HelloState::Established,
+ None => false,
+ }
+ }
+ })
+ .await;
+ // What a sends meanwhile, b doesn't read.
+ tokio::time::sleep(Duration::from_secs(2)).await;
+ sim.net.set_link("a", "b", LinkParams::default());
+ sim.wait_converged(&[&a, &b], LONG).await;
+}
+
/// Different events to different peers: tv, lass and makefu, a node each, apart while
/// each is given its own: two writes of tv's at one place, a write of lass's, and a
/// proposal and the votes that pass it, each on another node. Together, they read the