Skip to content

Commit 6f14880

Browse files
committed
Address feedback from review
1 parent 35200e4 commit 6f14880

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

tests/rust/wasm32-wasip3/src/bin/clocks-sleep.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,26 @@ struct Component;
2323
export!(Component);
2424
impl exports::wasi::cli::run::Guest for Component {
2525
async fn run() -> Result<(), ()> {
26-
sleep_10ms().await;
26+
sleep_10ms_wait_for().await;
27+
sleep_10ms_wait_until().await;
2728
sleep_0ms();
2829
sleep_backwards_in_time();
2930
Ok(())
3031
}
3132
}
3233

33-
async fn sleep_10ms() {
34+
async fn sleep_10ms_wait_for() {
3435
let dur = 10_000_000;
35-
monotonic_clock::wait_until(monotonic_clock::now() + dur).await;
36+
let deadline = monotonic_clock::now() + dur;
3637
monotonic_clock::wait_for(dur).await;
38+
assert!(monotonic_clock::now() >= deadline, "wait_for never resolves before the deadline");
39+
}
40+
41+
async fn sleep_10ms_wait_until() {
42+
let dur = 10_000_000;
43+
let deadline = monotonic_clock::now() + dur;
44+
monotonic_clock::wait_until(deadline).await;
45+
assert!(monotonic_clock::now() >= deadline, "wait_until never resolves before the deadline");
3746
}
3847

3948
fn sleep_0ms() {

0 commit comments

Comments
 (0)