|
66 | 66 |
|
67 | 67 | use std::{ops::RangeInclusive, sync::Arc}; |
68 | 68 |
|
69 | | -use std::sync::OnceLock; |
| 69 | +use std::sync::LazyLock; |
70 | 70 |
|
71 | 71 | use tokio::sync::{mpsc, oneshot}; |
72 | 72 | use tokio_stream::{StreamExt, wrappers::ReceiverStream}; |
@@ -290,14 +290,13 @@ impl<N: Network> ConnectedBlockRangeScanner<N> { |
290 | 290 | } |
291 | 291 | } |
292 | 292 |
|
293 | | -#[allow(dead_code)] |
294 | | -static TEST_HIST_LOCK: OnceLock<tokio::sync::Mutex<()>> = OnceLock::new(); |
| 293 | +#[cfg(test)] |
| 294 | +static TEST_HIST_LOCK: LazyLock<tokio::sync::Mutex<()>> = |
| 295 | + LazyLock::new(|| tokio::sync::Mutex::new(())); |
295 | 296 |
|
296 | | -#[allow(dead_code)] |
297 | | -#[allow(clippy::unused_async)] |
| 297 | +#[cfg(test)] |
298 | 298 | async fn lock_historical_for_testing() { |
299 | | - let lock = TEST_HIST_LOCK.get_or_init(|| tokio::sync::Mutex::new(())); |
300 | | - let _guard = lock.lock().await; |
| 299 | + let _guard = TEST_HIST_LOCK.lock().await; |
301 | 300 | } |
302 | 301 |
|
303 | 302 | struct Service<N: Network> { |
@@ -1414,7 +1413,7 @@ mod tests { |
1414 | 1413 | .await? |
1415 | 1414 | .run()?; |
1416 | 1415 |
|
1417 | | - let lock = super::TEST_HIST_LOCK.get_or_init(|| tokio::sync::Mutex::new(())).lock().await; |
| 1416 | + let lock = super::TEST_HIST_LOCK.lock().await; |
1418 | 1417 |
|
1419 | 1418 | let fut_stream = client |
1420 | 1419 | .stream_historical(BlockNumberOrTag::Number(0), BlockNumberOrTag::Number(end_num)); |
@@ -1484,7 +1483,7 @@ mod tests { |
1484 | 1483 | .await? |
1485 | 1484 | .run()?; |
1486 | 1485 |
|
1487 | | - let lock = super::TEST_HIST_LOCK.get_or_init(|| tokio::sync::Mutex::new(())).lock().await; |
| 1486 | + let lock = super::TEST_HIST_LOCK.lock().await; |
1488 | 1487 |
|
1489 | 1488 | let fut_stream = client |
1490 | 1489 | .stream_historical(BlockNumberOrTag::Number(0), BlockNumberOrTag::Number(end_num)); |
|
0 commit comments