Skip to content

Commit 89614ef

Browse files
committed
Add assertions to zmq_same_thread test
1 parent f37baed commit 89614ef

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

wingfoil/src/adapters/zmq.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ mod tests {
199199
use std::time::Duration;
200200

201201
#[test]
202-
fn zmq_works() {
202+
fn zmq_same_thread() {
203203
_ = env_logger::try_init();
204204
let period = Duration::from_millis(50);
205205
for run_mode in [
@@ -212,15 +212,27 @@ mod tests {
212212
let send = ticker(period).count().logged("pub", Info).zmq_send(port);
213213
let rec = zmq_rec::<u64>(address.as_str())
214214
.logged("sub", Info)
215-
.as_node();
215+
.collect()
216+
.finally(|res, _| {
217+
let res: Vec<u64> = res.into_iter().flat_map(|item| item.value).collect();
218+
println!("{res:?}");
219+
assert!(
220+
res.len() >= 5,
221+
"expected at least 5 items, got {}",
222+
res.len()
223+
);
224+
for window in res.windows(2) {
225+
assert_eq!(window[1], window[0] + 1, "expected consecutive integers");
226+
}
227+
});
216228
let nodes = vec![send, rec];
217229
let run_for = RunFor::Duration(period * 10);
218230
Graph::new(nodes, run_mode, run_for).print().run().unwrap();
219231
}
220232
}
221233

222234
#[test]
223-
fn zmq_really_works() {
235+
fn zmq_seperate_threads() {
224236
_ = env_logger::try_init();
225237
let period = Duration::from_millis(10);
226238
for run_mode in [

0 commit comments

Comments
 (0)