Skip to content

Commit f4e8686

Browse files
committed
f complete test
1 parent d2e8a0c commit f4e8686

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lightning/src/util/wakers.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ mod tests {
447447

448448
// If we get a future and don't touch it we're definitely still notify-required.
449449
notifier.get_future();
450-
assert!(notifier.wait_timeout(Duration::from_secs(1)));
451-
assert!(!notifier.wait_timeout(Duration::from_secs(1)));
450+
assert!(notifier.wait_timeout(Duration::from_millis(1)));
451+
assert!(!notifier.wait_timeout(Duration::from_millis(1)));
452452

453453
// Even if we poll'd once but didn't observe a `Ready`, we should be notify-required.
454454
let mut future = notifier.get_future();
@@ -457,10 +457,16 @@ mod tests {
457457

458458
notifier.notify();
459459
assert!(woken.load(Ordering::SeqCst));
460-
assert!(notifier.wait_timeout(Duration::from_secs(1)));
460+
assert!(notifier.wait_timeout(Duration::from_millis(1)));
461461

462-
notifier.notify();
462+
// However, once we do poll `Ready` it should wipe the notify-required flag.
463+
let mut future = notifier.get_future();
464+
let (woken, waker) = create_waker();
465+
assert_eq!(Pin::new(&mut future).poll(&mut Context::from_waker(&waker)), Poll::Pending);
463466

464467
notifier.notify();
468+
assert!(woken.load(Ordering::SeqCst));
469+
assert_eq!(Pin::new(&mut future).poll(&mut Context::from_waker(&waker)), Poll::Ready(()));
470+
assert!(!notifier.wait_timeout(Duration::from_millis(1)));
465471
}
466472
}

0 commit comments

Comments
 (0)