From 3678bb1297e495f789cf269098f7689cec48af32 Mon Sep 17 00:00:00 2001 From: plebhash Date: Wed, 11 Dec 2024 16:35:15 +0700 Subject: [PATCH] fix unwrap on sv1-mining-device tcp connection.. Update roles/test-utils/mining-device-sv1/src/client.rs Co-authored-by: jbesraa --- roles/test-utils/mining-device-sv1/src/client.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/roles/test-utils/mining-device-sv1/src/client.rs b/roles/test-utils/mining-device-sv1/src/client.rs index be2e5062e7..4934bae449 100644 --- a/roles/test-utils/mining-device-sv1/src/client.rs +++ b/roles/test-utils/mining-device-sv1/src/client.rs @@ -102,9 +102,20 @@ impl Client { task::spawn(async move { let mut messages = BufReader::new(&*reader).lines(); while let Some(message) = messages.next().await { - let message = message.unwrap(); - sender_incoming.send(message).await.unwrap(); + match message { + Ok(msg) => { + if let Err(e) = sender_incoming.send(msg).await { + eprintln!("Failed to send message to receiver_incoming: {:?}", e); + break; // Exit the loop if sending fails + } + } + Err(e) => { + eprintln!("Error reading from socket: {:?}", e); + break; // Exit the loop on read failure + } + } } + eprintln!("Reader task terminated."); }); // Waits to receive a message from `sender_outgoing` and writes it to the socket for the