Skip to content

Commit d3fc6f8

Browse files
committed
f use check_added_monitors and start from tx conf height of 1 with explainer
1 parent 696725c commit d3fc6f8

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

lightning/src/ln/functional_tests.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9156,41 +9156,36 @@ fn test_coinbase_funding_tx() {
91569156
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &accept_channel);
91579157

91589158
// Create the coinbase funding transaction.
9159-
let (temporary_channel_id, tx, funding_output) = create_coinbase_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100000, 42);
9159+
let (temporary_channel_id, tx, _) = create_coinbase_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 100000, 42);
91609160

91619161
nodes[0].node.funding_transaction_generated(&temporary_channel_id, &nodes[1].node.get_our_node_id(), tx.clone()).unwrap();
91629162
check_added_monitors!(nodes[0], 0);
91639163
let funding_created = get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
91649164

91659165
nodes[1].node.handle_funding_created(&nodes[0].node.get_our_node_id(), &funding_created);
9166-
{
9167-
let mut added_monitors = nodes[1].chain_monitor.added_monitors.lock().unwrap();
9168-
assert_eq!(added_monitors.len(), 1);
9169-
assert_eq!(added_monitors[0].0, funding_output);
9170-
added_monitors.clear();
9171-
}
9166+
check_added_monitors!(nodes[1], 1);
91729167
expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id());
91739168

91749169
let funding_signed = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, nodes[0].node.get_our_node_id());
91759170

91769171
nodes[0].node.handle_funding_signed(&nodes[1].node.get_our_node_id(), &funding_signed);
9177-
{
9178-
let mut added_monitors = nodes[0].chain_monitor.added_monitors.lock().unwrap();
9179-
assert_eq!(added_monitors.len(), 1);
9180-
assert_eq!(added_monitors[0].0, funding_output);
9181-
added_monitors.clear();
9182-
}
9172+
check_added_monitors!(nodes[0], 1);
91839173

91849174
expect_channel_pending_event(&nodes[0], &nodes[1].node.get_our_node_id());
91859175
assert!(nodes[0].node.get_and_clear_pending_events().is_empty());
91869176

9187-
confirm_transaction_at(&nodes[0], &tx, 2);
9177+
// Starting at height 0, we "confirm" the coinbase at height 1.
9178+
confirm_transaction_at(&nodes[0], &tx, 1);
9179+
// We connect 98 more blocks to have 99 confirmations for the coinbase transaction.
91889180
connect_blocks(&nodes[0], COINBASE_MATURITY - 2);
9189-
assert!(nodes[0].node.get_and_clear_pending_events().is_empty());
9181+
// Check that we have no pending message events (we have not queued a `channel_ready` yet).
9182+
assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
9183+
// Now connect one more block which results in 100 confirmations of the coinbase transaction.
91909184
connect_blocks(&nodes[0], 1);
9185+
// There should now be a `channel_ready` which can be handled.
91919186
let _ = &nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &get_event_msg!(&nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id()));
91929187

9193-
confirm_transaction_at(&nodes[1], &tx, 2);
9188+
confirm_transaction_at(&nodes[1], &tx, 1);
91949189
connect_blocks(&nodes[1], COINBASE_MATURITY - 2);
91959190
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
91969191
connect_blocks(&nodes[1], 1);

0 commit comments

Comments
 (0)