From 2cf50c0da52da31a8e2c80a24c5582a525f02a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=AD=90=EF=B8=8FNINIKA=E2=AD=90=EF=B8=8F?= Date: Tue, 7 May 2024 09:44:44 +0300 Subject: [PATCH] fix: Report if a request to check peer status in test_network fails (#4543) Signed-off-by: Nikita Strygin --- core/test_network/src/lib.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/core/test_network/src/lib.rs b/core/test_network/src/lib.rs index 1816fdff7d3..483332a6a0d 100644 --- a/core/test_network/src/lib.rs +++ b/core/test_network/src/lib.rs @@ -17,7 +17,7 @@ pub use iroha_core::state::StateReadOnly; use iroha_crypto::KeyPair; use iroha_data_model::{query::QueryOutputBox, ChainId}; use iroha_genesis::{GenesisNetwork, RawGenesisBlockFile}; -use iroha_logger::InstrumentFutures; +use iroha_logger::{warn, InstrumentFutures}; use iroha_primitives::{ addr::{socket_addr, SocketAddr}, unique_vec, @@ -345,12 +345,20 @@ pub fn wait_for_genesis_committed_with_max_retries( const POLL_PERIOD: Duration = Duration::from_millis(1000); for _ in 0..max_retries { - let without_genesis_peers = clients.iter().fold(0_u32, |acc, client| { - client.get_status().map_or( - acc + 1, - |status| if status.blocks < 1 { acc + 1 } else { acc }, - ) - }); + let ready_peers = clients + .iter() + .map(|client| { + let is_ready = match client.get_status() { + Ok(status) => status.blocks >= 1, + Err(error) => { + warn!("Error retrieving peer status: {:?}", error); + false + } + }; + is_ready as u32 + }) + .sum::(); + let without_genesis_peers = clients.len() as u32 - ready_peers; if without_genesis_peers <= offline_peers { return; }