Skip to content

Commit 33c2dae

Browse files
committed
f Use OnceCell for MINER_LOCK
1 parent d6b0493 commit 33c2dae

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lightning-transaction-sync/src/tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::collections::{HashMap, HashSet};
2222
static BITCOIND: OnceCell<BitcoinD> = OnceCell::new();
2323
static ELECTRSD: OnceCell<ElectrsD> = OnceCell::new();
2424
static PREMINE: OnceCell<()> = OnceCell::new();
25-
static MINER_LOCK: Mutex<()> = Mutex::new(());
25+
static MINER_LOCK: OnceCell<Mutex<()>> = OnceCell::new();
2626

2727
fn get_bitcoind() -> &'static BitcoinD {
2828
BITCOIND.get_or_init(|| {
@@ -51,7 +51,8 @@ fn get_electrsd() -> &'static ElectrsD {
5151
}
5252

5353
fn generate_blocks_and_wait(num: usize) {
54-
let _miner = MINER_LOCK.lock().unwrap();
54+
let miner_lock = MINER_LOCK.get_or_init(|| Mutex::new(()));
55+
let _miner = miner_lock.lock().unwrap();
5556
let cur_height = get_bitcoind().client.get_block_count().unwrap();
5657
let address = get_bitcoind().client.get_new_address(Some("test"), Some(AddressType::Legacy)).unwrap();
5758
let _block_hashes = get_bitcoind().client.generate_to_address(num as u64, &address).unwrap();

0 commit comments

Comments
 (0)