Putting a delay there is useless actually

This commit is contained in:
Kodi Craft 2024-06-21 12:07:56 +02:00
parent ffda8eb639
commit 3bbd385ee2
Signed by: kodi
GPG Key ID: 69D9EED60B242822

View File

@ -45,19 +45,12 @@ async fn main() {
server.abort(); server.abort();
} }
// Simulates a network delay or some other kind of slow-down in the communication.
// We don't want it to be too big not to slow down tests unnecessarily.
async fn random_sleep() {
tokio::time::sleep(std::time::Duration::from_millis(rand::random::<u64>() % 20)).await;
}
async fn server_loop( async fn server_loop(
mut qrx: Receiver<(u64, __TestProtocolQuestion)>, mut qrx: Receiver<(u64, __TestProtocolQuestion)>,
atx: Sender<(u64, __TestProtocolAnswer)>, atx: Sender<(u64, __TestProtocolAnswer)>,
) { ) {
loop { loop {
if let Some((nonce, q)) = qrx.recv().await { if let Some((nonce, q)) = qrx.recv().await {
random_sleep().await;
match q { match q {
__TestProtocolQuestion::addition((a, b)) => { __TestProtocolQuestion::addition((a, b)) => {
atx.send((nonce, __TestProtocolAnswer::addition(a + b))) atx.send((nonce, __TestProtocolAnswer::addition(a + b)))