Skip to content

Commit

Permalink
join on threads in integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antonilol committed Nov 4, 2023
1 parent 1ea9627 commit 4364815
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions integration_tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn test_sub_blocking(rpc: &Client) {

let (tx, rx) = mpsc::channel();

thread::spawn(move || {
let h = thread::spawn(move || {
subscribe_single_blocking(endpoints::HASHBLOCK, |msg| {
let msg = msg.expect("zmq message error");

Expand All @@ -93,6 +93,8 @@ fn test_sub_blocking(rpc: &Client) {

let zmq_hash = rx.recv_timeout(RECV_TIMEOUT).unwrap();

h.join().unwrap();

assert_eq!(rpc_hash, zmq_hash);
}

Expand All @@ -104,11 +106,10 @@ fn test_hashblock_async(rpc: &Client) {

let (tx, rx) = mpsc::channel();

thread::spawn(move || {
let h = thread::spawn(move || {
block_on(async {
while let Some(msg) = stream.next().await {
tx.send(msg).unwrap();
}
tx.send(stream.next().await.unwrap()).unwrap();
tx.send(stream.next().await.unwrap()).unwrap();
})
});

Expand All @@ -122,4 +123,6 @@ fn test_hashblock_async(rpc: &Client) {
panic!("invalid messages received: ({msg1}, {msg2})");
}
}

h.join().unwrap();
}

0 comments on commit 4364815

Please sign in to comment.