mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-23 12:09:37 +00:00
695d1f0ecf
* Remove subxt Removes ~20 crates from our Cargo.lock. Removes downloading the metadata and enables removing the getMetadata RPC route (relevant to #379). Moves forward #337. Done now due to distinctions in the subxt 0.32 API surface which make it justifiable to not update. * fmt, update due to deny triggering on a yanked crate * Correct the handling of substrate_block_notifier now that it's ephemeral, not long-lived * Correct URL in tests/coordinator from ws to http
28 lines
778 B
Rust
28 lines
778 B
Rust
use std::time::{Duration, SystemTime};
|
|
|
|
use tokio::time::sleep;
|
|
|
|
use serai_client::Serai;
|
|
|
|
mod common;
|
|
|
|
serai_test!(
|
|
time: (|serai: Serai| async move {
|
|
let mut number = serai.latest_finalized_block().await.unwrap().number();
|
|
let mut done = 0;
|
|
while done < 3 {
|
|
// Wait for the next block
|
|
let block = serai.latest_finalized_block().await.unwrap();
|
|
if block.number() == number {
|
|
sleep(Duration::from_secs(1)).await;
|
|
continue;
|
|
}
|
|
number = block.number();
|
|
|
|
// Make sure the time we extract from the block is within 5 seconds of now
|
|
let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs();
|
|
assert!(now.saturating_sub(block.time().unwrap()) < 5);
|
|
done += 1;
|
|
}
|
|
})
|
|
);
|