Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions clients/cli/tests/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ use {
path::PathBuf,
str::FromStr,
sync::Arc,
thread::sleep,
time::Duration,
},
tempfile::NamedTempFile,
};
Expand Down Expand Up @@ -272,10 +274,26 @@ async fn do_create_native_mint(rpc_client: &RpcClient, payer: &Keypair) {
&[payer],
rpc_client.get_latest_blockhash().await.unwrap(),
);
rpc_client
.send_and_confirm_transaction(&transaction)
.await
.unwrap();

// Actively check and wait till program is usable by the runtime (i.e.,
// no more "Program is not deployed" error)
const MAX_ATTEMPTS: u64 = 10;
let mut attempt = 0;
loop {
match rpc_client.send_and_confirm_transaction(&transaction).await {
Ok(_) => break,
Err(e) => {
if !format!("{:?}", e).contains("Program is not deployed") {
panic!("Unexpected error: {:?}", e);
}
attempt += 1;
if attempt > MAX_ATTEMPTS {
panic!("Timeout waiting for program to become deployable");
}
sleep(Duration::from_millis(100));
}
}
}
}
}

Expand Down