From fc29ee700110f379d815b39650ed2c8ce3c9aa7a Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 5 Mar 2021 13:52:20 +0000 Subject: [PATCH] Add timeout to prevent infinite loop (#15715) (#15735) (cherry picked from commit 1fc8836631ca541794d4c3d210ec867c6c934382) Co-authored-by: Tyera Eulberg --- local-cluster/tests/local_cluster.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/local-cluster/tests/local_cluster.rs b/local-cluster/tests/local_cluster.rs index abc16bdbbb..8efc02ee3c 100644 --- a/local-cluster/tests/local_cluster.rs +++ b/local-cluster/tests/local_cluster.rs @@ -59,7 +59,7 @@ use std::{ sync::atomic::{AtomicBool, Ordering}, sync::Arc, thread::{sleep, Builder, JoinHandle}, - time::Duration, + time::{Duration, Instant}, }; use tempfile::TempDir; @@ -1809,7 +1809,15 @@ fn do_test_optimistic_confirmation_violation_with_or_without_tower(with_tower: b // Step 1: // Let validator A, B, (D) run for a while. let (mut validator_a_finished, mut validator_b_finished) = (false, false); + let now = Instant::now(); while !(validator_a_finished && validator_b_finished) { + let elapsed = now.elapsed(); + if elapsed > Duration::from_secs(30) { + panic!( + "LocalCluster nodes failed to log enough tower votes in {} secs", + elapsed.as_secs() + ); + } sleep(Duration::from_millis(100)); if let Some(last_vote) = last_vote_in_tower(&val_a_ledger_path, &validator_a_pubkey) {