Skip to content

Commit

Permalink
fix: client-test timeout (solana-labs#29364)
Browse files Browse the repository at this point in the history
* fix: retry counter doesn't count

* set timeout for wait_for
  • Loading branch information
yihau authored Dec 22, 2022
1 parent 0a5164d commit bf18613
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions client-test/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,13 @@ fn test_slot_subscription() {
async fn test_slot_subscription_async() {
let sync_service = Arc::new(AtomicU64::new(0));
let sync_client = Arc::clone(&sync_service);

fn wait_until(atomic: &Arc<AtomicU64>, value: u64) {
let now = Instant::now();
while atomic.load(Ordering::Relaxed) != value {
if now.elapsed() > Duration::from_secs(5) {
panic!("wait for too long")
}
sleep(Duration::from_millis(1))
}
}
Expand Down Expand Up @@ -605,12 +610,16 @@ async fn test_slot_subscription_async() {
unsubscribe().await;
}

fn check_server_is_ready_or_panic(socket_addr: &SocketAddr, retry: u8, sleep_duration: Duration) {
fn check_server_is_ready_or_panic(
socket_addr: &SocketAddr,
mut retry: u8,
sleep_duration: Duration,
) {
loop {
if retry == 0 {
break;
} else {
retry.checked_sub(1).unwrap();
retry = retry.checked_sub(1).unwrap();
}

if connect(format!("ws://{socket_addr}")).is_ok() {
Expand Down

0 comments on commit bf18613

Please sign in to comment.