This commit is contained in:
aniketfuryrocks 2023-03-04 03:07:44 +05:30
parent 84bd7356e8
commit b1885e0ea2
No known key found for this signature in database
GPG Key ID: FA6BFCFAA7D4B764
1 changed files with 5 additions and 3 deletions

View File

@ -1,21 +1,23 @@
use lite_rpc::DEFAULT_LITE_RPC_ADDR;
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
const BLOCKHASH_INTERVAL_MS: u64 = 3000;
#[tokio::test]
async fn blockhash() -> anyhow::Result<()> {
let lite_rpc = RpcClient::new(DEFAULT_LITE_RPC_ADDR.to_string());
let mut prev_blockhash = lite_rpc.get_latest_blockhash().await.unwrap();
for _ in 0..60 {
tokio::time::sleep(tokio::time::Duration::from_millis(3000)).await;
for _ in 0..10 {
tokio::time::sleep(tokio::time::Duration::from_millis(BLOCKHASH_INTERVAL_MS)).await;
let blockhash = lite_rpc.get_latest_blockhash().await.unwrap();
if prev_blockhash != blockhash {
prev_blockhash = blockhash;
} else {
panic!("Blockhash didn't change in appx 500ms");
panic!("Blockhash didn't change in appx {BLOCKHASH_INTERVAL_MS}ms");
}
}