panic when test timeout

This commit is contained in:
Haoran Yi
2022-04-04 16:43:23 -05:00
parent 302142bb25
commit 7e1374557f

View File

@ -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();
}