Skip to content

Commit

Permalink
fix: Report if a request to check peer status in test_network fails (#…
Browse files Browse the repository at this point in the history
…4543)

Signed-off-by: Nikita Strygin <dcnick3@users.noreply.github.com>
  • Loading branch information
DCNick3 committed May 7, 2024
1 parent b00e102 commit 2cf50c0
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions core/test_network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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::<u32>();
let without_genesis_peers = clients.len() as u32 - ready_peers;
if without_genesis_peers <= offline_peers {
return;
}
Expand Down

0 comments on commit 2cf50c0

Please sign in to comment.