Skip to content

Commit ac079bf

Browse files
committed
(XXX: doc for one thing) update test!
1 parent be6edd9 commit ac079bf

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,7 +3264,7 @@ fn test_inverted_mon_completion_order() {
32643264
do_test_inverted_mon_completion_order(false, false);
32653265
}
32663266

3267-
fn do_test_durable_preimages_on_closed_channel(close_chans_before_reload: bool, close_only_a: bool) {
3267+
fn do_test_durable_preimages_on_closed_channel(close_chans_before_reload: bool, close_only_a: bool, hold_post_reload_mon_update: bool) {
32683268
// Test that we can apply a `ChannelMonitorUpdate` with a payment preimage even if the channel
32693269
// is force-closed between when we generate the update on reload and when we go to handle the
32703270
// update or prior to generating the update at all.
@@ -3360,8 +3360,14 @@ fn do_test_durable_preimages_on_closed_channel(close_chans_before_reload: bool,
33603360
// After a timer tick a payment preimage ChannelMonitorUpdate is applied to the A<->B
33613361
// ChannelMonitor (possible twice), even though the channel has since been closed.
33623362
check_added_monitors(&nodes[1], 0);
3363+
let mons_added = if close_chans_before_reload { if !close_only_a { 4 } else { 3 } } else { 2 };
3364+
if hold_post_reload_mon_update {
3365+
for _ in 0..mons_added {
3366+
persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
3367+
}
3368+
}
33633369
nodes[1].node.timer_tick_occurred();
3364-
check_added_monitors(&nodes[1], if close_chans_before_reload { if !close_only_a { 4 } else { 3 } } else { 2 });
3370+
check_added_monitors(&nodes[1], mons_added);
33653371

33663372
// Finally, check that B created a payment preimage transaction and close out the payment.
33673373
let bs_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
@@ -3381,11 +3387,36 @@ fn do_test_durable_preimages_on_closed_channel(close_chans_before_reload: bool,
33813387
mine_transactions(&nodes[0], &[&as_closing_tx[0], bs_preimage_tx]);
33823388
check_closed_broadcast(&nodes[0], 1, true);
33833389
expect_payment_sent(&nodes[0], payment_preimage, None, true, true);
3390+
3391+
if !close_chans_before_reload || close_only_a {
3392+
// Make sure the B<->C channel is still alive and well by sending a payment over it.
3393+
let mut reconnect_args = ReconnectArgs::new(&nodes[1], &nodes[2]);
3394+
reconnect_args.pending_htlc_adds.1 = if close_only_a {
3395+
// XXX If
3396+
-1
3397+
} else { -2 };
3398+
reconnect_args.pending_raa.1 = true;
3399+
3400+
reconnect_nodes(reconnect_args);
3401+
let (outpoint, ab_update_id, _) = nodes[1].chain_monitor.latest_monitor_update_id.lock().unwrap().get(&chan_id_ab).unwrap().clone();
3402+
nodes[1].chain_monitor.chain_monitor.force_channel_monitor_updated(outpoint, ab_update_id);
3403+
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(1000), true, false);
3404+
if !close_only_a {
3405+
// Once we call `process_pending_events` the final `ChannelMonitor` for the B<->C
3406+
// channel will fly, removing the payment preimage from it.
3407+
check_added_monitors(&nodes[1], 1);
3408+
}
3409+
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
3410+
send_payment(&nodes[1], &[&nodes[2]], 100_000);
3411+
}
33843412
}
33853413

33863414
#[test]
33873415
fn test_durable_preimages_on_closed_channel() {
3388-
do_test_durable_preimages_on_closed_channel(true, true);
3389-
do_test_durable_preimages_on_closed_channel(true, false);
3390-
do_test_durable_preimages_on_closed_channel(false, false);
3416+
do_test_durable_preimages_on_closed_channel(true, true, true);
3417+
do_test_durable_preimages_on_closed_channel(true, true, false);
3418+
do_test_durable_preimages_on_closed_channel(true, false, true);
3419+
do_test_durable_preimages_on_closed_channel(true, false, false);
3420+
do_test_durable_preimages_on_closed_channel(false, false, true);
3421+
do_test_durable_preimages_on_closed_channel(false, false, false);
33913422
}

0 commit comments

Comments
 (0)