Skip to content

Commit 8a1ec8b

Browse files
committed
Add test logger scope
1 parent f4317cc commit 8a1ec8b

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ use crate::ln::functional_test_utils::*;
4444

4545
use crate::util::test_utils;
4646

47-
use crate::prelude::*;
4847
use crate::sync::{Arc, Mutex};
48+
use crate::{prelude::*, test_scope};
4949
use bitcoin::hashes::Hash;
5050

5151
fn get_latest_mon_update_id<'a, 'b, 'c>(
@@ -3772,6 +3772,8 @@ fn test_inverted_mon_completion_order() {
37723772
fn do_test_durable_preimages_on_closed_channel(
37733773
close_chans_before_reload: bool, close_only_a: bool, hold_post_reload_mon_update: bool,
37743774
) {
3775+
test_scope!("Setup");
3776+
37753777
// Test that we can apply a `ChannelMonitorUpdate` with a payment preimage even if the channel
37763778
// is force-closed between when we generate the update on reload and when we go to handle the
37773779
// update or prior to generating the update at all.
@@ -3798,6 +3800,8 @@ fn do_test_durable_preimages_on_closed_channel(
37983800
let chan_id_ab = create_announced_chan_between_nodes(&nodes, 0, 1).2;
37993801
let chan_id_bc = create_announced_chan_between_nodes(&nodes, 1, 2).2;
38003802

3803+
test_scope!("Route payment");
3804+
38013805
// Route a payment from A, through B, to C, then claim it on C. Once we pass B the
38023806
// `update_fulfill_htlc` we have a monitor update for both of B's channels. We complete the one
38033807
// on the B<->C channel but leave the A<->B monitor update pending, then reload B.
@@ -3810,6 +3814,8 @@ fn do_test_durable_preimages_on_closed_channel(
38103814
check_added_monitors(&nodes[2], 1);
38113815
expect_payment_claimed!(nodes[2], payment_hash, 1_000_000);
38123816

3817+
test_scope!("Handle fulfill from C to B");
3818+
38133819
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
38143820
let mut cs_updates = get_htlc_update_msgs(&nodes[2], &node_b_id);
38153821
nodes[1].node.handle_update_fulfill_htlc(node_c_id, cs_updates.update_fulfill_htlcs.remove(0));
@@ -3822,6 +3828,8 @@ fn do_test_durable_preimages_on_closed_channel(
38223828
// Now step the Commitment Signed Dance between B and C forward a bit, ensuring we won't get
38233829
// the preimage when the nodes reconnect, at which point we have to ensure we get it from the
38243830
// ChannelMonitor.
3831+
test_scope!("Step commitment_signed from B to C forward");
3832+
38253833
nodes[1].node.handle_commitment_signed_batch_test(node_c_id, &cs_updates.commitment_signed);
38263834
check_added_monitors(&nodes[1], 1);
38273835
let _ = get_revoke_commit_msgs(&nodes[1], &node_c_id);
@@ -3830,6 +3838,8 @@ fn do_test_durable_preimages_on_closed_channel(
38303838

38313839
if close_chans_before_reload {
38323840
if !close_only_a {
3841+
test_scope!("Force close B<->C channel");
3842+
38333843
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
38343844
let message = "Channel force-closed".to_owned();
38353845
nodes[1]
@@ -3842,6 +3852,8 @@ fn do_test_durable_preimages_on_closed_channel(
38423852
check_closed_event(&nodes[1], 1, reason, &[node_c_id], 100000);
38433853
}
38443854

3855+
test_scope!("Force close A<->B channel");
3856+
38453857
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
38463858
let message = "Channel force-closed".to_owned();
38473859
nodes[1]
@@ -3854,6 +3866,8 @@ fn do_test_durable_preimages_on_closed_channel(
38543866
check_closed_event(&nodes[1], 1, reason, &[node_a_id], 100000);
38553867
}
38563868

3869+
test_scope!("Reload");
3870+
38573871
// Now reload node B
38583872
let manager_b = nodes[1].node.encode();
38593873
reload_node!(nodes[1], &manager_b, &[&mon_ab, &mon_bc], persister, chain_mon, node_b_reload);
@@ -3871,6 +3885,8 @@ fn do_test_durable_preimages_on_closed_channel(
38713885
}
38723886
}
38733887

3888+
test_scope!("Force close A<->B channel from A");
3889+
38743890
let err_msg = "Channel force-closed".to_owned();
38753891
let reason = ClosureReason::HolderForceClosed {
38763892
broadcasted_latest_txn: Some(true),
@@ -3889,6 +3905,8 @@ fn do_test_durable_preimages_on_closed_channel(
38893905

38903906
// After a timer tick a payment preimage ChannelMonitorUpdate is applied to the A<->B
38913907
// ChannelMonitor (possible twice), even though the channel has since been closed.
3908+
test_scope!("Timer tick to apply preimage monitor update");
3909+
38923910
check_added_monitors(&nodes[1], 0);
38933911
let mons_added = if close_chans_before_reload {
38943912
if !close_only_a {
@@ -3913,6 +3931,8 @@ fn do_test_durable_preimages_on_closed_channel(
39133931
check_added_monitors(&nodes[1], mons_added);
39143932

39153933
// Finally, check that B created a payment preimage transaction and close out the payment.
3934+
test_scope!("Check preimage txn and complete payment");
3935+
39163936
let bs_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
39173937
assert_eq!(bs_txn.len(), if close_chans_before_reload && !close_only_a { 2 } else { 1 });
39183938
let bs_preimage_tx = bs_txn
@@ -3926,6 +3946,7 @@ fn do_test_durable_preimages_on_closed_channel(
39263946
expect_payment_sent(&nodes[0], payment_preimage, None, true, true);
39273947

39283948
if !close_chans_before_reload || close_only_a {
3949+
test_scope!("Reconnect nodes B and C");
39293950
// Make sure the B<->C channel is still alive and well by sending a payment over it.
39303951
let mut reconnect_args = ReconnectArgs::new(&nodes[1], &nodes[2]);
39313952
reconnect_args.pending_responding_commitment_signed.1 = true;
@@ -3940,6 +3961,7 @@ fn do_test_durable_preimages_on_closed_channel(
39403961

39413962
// Once the blocked `ChannelMonitorUpdate` *finally* completes, the pending
39423963
// `PaymentForwarded` event will finally be released.
3964+
test_scope!("Complete blocked ChannelMonitorUpdate");
39433965
let (_, ab_update_id) = get_latest_mon_update_id(&nodes[1], chan_id_ab);
39443966
nodes[1].chain_monitor.chain_monitor.force_channel_monitor_updated(chan_id_ab, ab_update_id);
39453967

@@ -3957,6 +3979,8 @@ fn do_test_durable_preimages_on_closed_channel(
39573979
if !close_chans_before_reload || close_only_a {
39583980
// Once we call `process_pending_events` the final `ChannelMonitor` for the B<->C channel
39593981
// will fly, removing the payment preimage from it.
3982+
test_scope!("Process pending events to complete B<->C monitor update");
3983+
39603984
check_added_monitors(&nodes[1], 1);
39613985
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
39623986
send_payment(&nodes[1], &[&nodes[2]], 100_000);

0 commit comments

Comments
 (0)