Skip to content

Commit f4e4603

Browse files
committed
f drop needless extra fn
1 parent 2d0756d commit f4e4603

File tree

1 file changed

+7
-17
lines changed
  • lightning-background-processor/src

1 file changed

+7
-17
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -303,20 +303,8 @@ mod tests {
303303
}}
304304
}
305305

306-
fn connect_blocks(node: &mut Node, block_count: u32) {
307-
for i in 1..=block_count {
308-
let prev_blockhash = node.best_block.block_hash();
309-
let height = node.best_block.height() + 1;
310-
let header = BlockHeader { version: 0x20000000, prev_blockhash, merkle_root: Default::default(), time: height, bits: 42, nonce: 42 };
311-
node.best_block = BestBlock::new(header.block_hash(), height);
312-
if i == block_count {
313-
node.node.best_block_updated(&header, height);
314-
node.chain_monitor.best_block_updated(&header, height);
315-
}
316-
}
317-
}
318-
fn confirm_transaction(node: &mut Node, tx: &Transaction) {
319-
for i in 1..=ANTI_REORG_DELAY {
306+
fn confirm_transaction_depth(node: &mut Node, tx: &Transaction, depth: u32) {
307+
for i in 1..=depth {
320308
let prev_blockhash = node.best_block.block_hash();
321309
let height = node.best_block.height() + 1;
322310
let header = BlockHeader { version: 0x20000000, prev_blockhash, merkle_root: Default::default(), time: height, bits: 42, nonce: 42 };
@@ -327,14 +315,17 @@ mod tests {
327315
node.node.transactions_confirmed(&header, &txdata, height);
328316
node.chain_monitor.transactions_confirmed(&header, &txdata, height);
329317
},
330-
ANTI_REORG_DELAY => {
318+
x if x == depth => {
331319
node.node.best_block_updated(&header, height);
332320
node.chain_monitor.best_block_updated(&header, height);
333321
},
334322
_ => {},
335323
}
336324
}
337325
}
326+
fn confirm_transaction(node: &mut Node, tx: &Transaction) {
327+
confirm_transaction_depth(node, tx, ANTI_REORG_DELAY);
328+
}
338329

339330
#[test]
340331
fn test_background_processor() {
@@ -466,8 +457,7 @@ mod tests {
466457
// Force close the channel and check that the SpendableOutputs event was handled.
467458
nodes[0].node.force_close_channel(&nodes[0].node.list_channels()[0].channel_id).unwrap();
468459
let commitment_tx = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().pop().unwrap();
469-
confirm_transaction(&mut nodes[0], &commitment_tx);
470-
connect_blocks(&mut nodes[0], BREAKDOWN_TIMEOUT as u32 - 1);
460+
confirm_transaction_depth(&mut nodes[0], &commitment_tx, BREAKDOWN_TIMEOUT as u32);
471461
let event = receiver
472462
.recv_timeout(Duration::from_secs(EVENT_DEADLINE))
473463
.expect("SpendableOutputs not handled within deadline");

0 commit comments

Comments
 (0)