From 7e1374557f07ad7b612d596d45e2c4a3b5614f4f Mon Sep 17 00:00:00 2001 From: Haoran Yi Date: Mon, 4 Apr 2022 16:43:23 -0500 Subject: [PATCH] panic when test timeout --- core/src/validator.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/src/validator.rs b/core/src/validator.rs index 49d3a11c68..54cdf11711 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -1868,7 +1868,20 @@ mod tests { *start_progress.read().unwrap(), ValidatorStartProgress::Running ); - validator.close(); + + // spawn a new thread to wait for validator close + let (sender, receiver) = bounded(0); + let _ = thread::spawn(move || { + validator.close(); + sender.send(()).unwrap(); + }); + + // timeout of 30s for shutting down the validators + let timeout = Duration::from_secs(30); + if let Err(RecvTimeoutError::Timeout) = receiver.recv_timeout(timeout) { + panic!("timeout for closing validator"); + } + remove_dir_all(validator_ledger_path).unwrap(); }