refactor(sim): move FrameBuf on dup; vary per-node obs; test disconnect/unreachable

This commit is contained in:
2026-10-17 23:58:15 -07:00
parent 1752bd23ff
commit 1257f227ce
3 changed files with 29 additions and 7 deletions
+3 -2
View File
@@ -57,10 +57,11 @@ impl Transport for SimTransport {
return Ok(());
}
let buf = FrameBuf::from_slice(frame).map_err(|_| SendError::TooLarge)?;
let dup = w.rng.gen::<f64>() < w.cfg.dup;
w.inboxes[*to].push_back(Event::Frame(self.me, buf.clone()));
w.frames_sent += 1;
if w.rng.gen::<f64>() < w.cfg.dup {
w.inboxes[*to].push_back(Event::Frame(self.me, buf.clone()));
if dup {
w.inboxes[*to].push_back(Event::Frame(self.me, buf));
w.frames_sent += 1;
}
Ok(())
+11 -4
View File
@@ -72,12 +72,19 @@ type Scenario = (usize, ContactTrace, Vec<(usize, Vec<u8>, Vec<u8>)>);
fn scenario() -> impl Strategy<Value = Scenario> {
(2..=6usize).prop_flat_map(|nodes| {
let trace = proptest::collection::vec(contact(nodes), 1..=12usize);
let obs = proptest::collection::vec(observation(), nodes..=nodes);
(trace, obs).prop_map(move |(contacts, per_node)| {
// Each node publishes 0..=10 observations, flattened to (node, topic,
// payload) triples so per-node counts vary across scenarios.
let per_node = proptest::collection::vec(
proptest::collection::vec(observation(), 0..=10usize),
nodes..=nodes,
);
(trace, per_node).prop_map(move |(contacts, per_node)| {
let trace = ContactTrace { contacts };
let mut list = Vec::new();
for (node, (topic, payload)) in per_node.into_iter().enumerate() {
list.push((node, topic, payload));
for (node, node_obs) in per_node.into_iter().enumerate() {
for (topic, payload) in node_obs {
list.push((node, topic, payload));
}
}
(nodes, trace, list)
})