Skip to content

Commit 05dab40

Browse files
committed
Async'ify our test suite
.. as LDK Node is moving towards a more `async` core, it starts to make sense to switch our test suite over to be `async`. This change should make our CI more efficient (as not every node will spawn its independent runtime, but we just have one runtime per test created) and also makes sure we won't run into any edge cases arising from blocking test threads that are executing other async tasks.
1 parent b8cf41c commit 05dab40

File tree

7 files changed

+402
-392
lines changed

7 files changed

+402
-392
lines changed

src/event.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,6 @@ mod tests {
16251625

16261626
// Check we get the expected event and that it is returned until we mark it handled.
16271627
for _ in 0..5 {
1628-
assert_eq!(event_queue.wait_next_event(), expected_event);
16291628
assert_eq!(event_queue.next_event_async().await, expected_event);
16301629
assert_eq!(event_queue.next_event(), Some(expected_event.clone()));
16311630
}
@@ -1640,7 +1639,7 @@ mod tests {
16401639
.unwrap();
16411640
let deser_event_queue =
16421641
EventQueue::read(&mut &persisted_bytes[..], (Arc::clone(&store), logger)).unwrap();
1643-
assert_eq!(deser_event_queue.wait_next_event(), expected_event);
1642+
assert_eq!(deser_event_queue.next_event_async().await, expected_event);
16441643

16451644
event_queue.event_handled().unwrap();
16461645
assert_eq!(event_queue.next_event(), None);
@@ -1709,32 +1708,5 @@ mod tests {
17091708
}
17101709
}
17111710
assert_eq!(event_queue.next_event(), None);
1712-
1713-
// Check we operate correctly, even when mixing and matching blocking and async API calls.
1714-
let (tx, mut rx) = tokio::sync::watch::channel(());
1715-
let thread_queue = Arc::clone(&event_queue);
1716-
let thread_event = expected_event.clone();
1717-
std::thread::spawn(move || {
1718-
let e = thread_queue.wait_next_event();
1719-
assert_eq!(e, thread_event);
1720-
thread_queue.event_handled().unwrap();
1721-
tx.send(()).unwrap();
1722-
});
1723-
1724-
let thread_queue = Arc::clone(&event_queue);
1725-
let thread_event = expected_event.clone();
1726-
std::thread::spawn(move || {
1727-
// Sleep a bit before we enqueue the events everybody is waiting for.
1728-
std::thread::sleep(Duration::from_millis(20));
1729-
thread_queue.add_event(thread_event.clone()).unwrap();
1730-
thread_queue.add_event(thread_event.clone()).unwrap();
1731-
});
1732-
1733-
let e = event_queue.next_event_async().await;
1734-
assert_eq!(e, expected_event.clone());
1735-
event_queue.event_handled().unwrap();
1736-
1737-
rx.changed().await.unwrap();
1738-
assert_eq!(event_queue.next_event(), None);
17391711
}
17401712
}

0 commit comments

Comments
 (0)