Skip to content

Commit fe3e82b

Browse files
Prepare tests for deprecating RAA-blockers
And tweak a few test utils to have clearer error messages. Splitting up tests with may variants makes it easier to debug tests. Tests marked "legacy" have test coverage replicated in the next commit, that does not rely on RAA blocking actions.
1 parent c5ea569 commit fe3e82b

4 files changed

Lines changed: 42 additions & 17 deletions

File tree

lightning/src/chain/channelmonitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fn push_monitor_event(
193193
}
194194

195195
/// An event to be processed by the ChannelManager.
196-
#[derive(Clone, PartialEq, Eq)]
196+
#[derive(Clone, PartialEq, Eq, Debug)]
197197
pub enum MonitorEvent {
198198
/// A monitor event containing an HTLCUpdate.
199199
HTLCEvent(HTLCUpdate),
@@ -255,7 +255,7 @@ impl_writeable_tlv_based_enum_upgradable_legacy!(MonitorEvent,
255255
/// Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on
256256
/// chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the
257257
/// preimage claim backward will lead to loss of funds.
258-
#[derive(Clone, PartialEq, Eq)]
258+
#[derive(Clone, PartialEq, Eq, Debug)]
259259
pub struct HTLCUpdate {
260260
pub(crate) payment_hash: PaymentHash,
261261
pub(crate) payment_preimage: Option<PaymentPreimage>,

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3774,7 +3774,7 @@ fn test_inverted_mon_completion_order() {
37743774
do_test_inverted_mon_completion_order(false, false);
37753775
}
37763776

3777-
fn do_test_durable_preimages_on_closed_channel(
3777+
fn do_test_durable_preimages_on_closed_channel_legacy(
37783778
close_chans_before_reload: bool, close_only_a: bool, hold_post_reload_mon_update: bool,
37793779
) {
37803780
// Test that we can apply a `ChannelMonitorUpdate` with a payment preimage even if the channel
@@ -4014,16 +4014,31 @@ fn do_test_durable_preimages_on_closed_channel(
40144014
}
40154015

40164016
#[test]
4017-
fn test_durable_preimages_on_closed_channel() {
4018-
do_test_durable_preimages_on_closed_channel(true, true, true);
4019-
do_test_durable_preimages_on_closed_channel(true, true, false);
4020-
do_test_durable_preimages_on_closed_channel(true, false, true);
4021-
do_test_durable_preimages_on_closed_channel(true, false, false);
4022-
do_test_durable_preimages_on_closed_channel(false, false, true);
4023-
do_test_durable_preimages_on_closed_channel(false, false, false);
4017+
fn test_durable_preimages_on_closed_channel_legacy_a() {
4018+
do_test_durable_preimages_on_closed_channel_legacy(true, true, true);
4019+
}
4020+
#[test]
4021+
fn test_durable_preimages_on_closed_channel_legacy_b() {
4022+
do_test_durable_preimages_on_closed_channel_legacy(true, true, false);
4023+
}
4024+
#[test]
4025+
fn test_durable_preimages_on_closed_channel_legacy_c() {
4026+
do_test_durable_preimages_on_closed_channel_legacy(true, false, true);
4027+
}
4028+
#[test]
4029+
fn test_durable_preimages_on_closed_channel_legacy_d() {
4030+
do_test_durable_preimages_on_closed_channel_legacy(true, false, false);
4031+
}
4032+
#[test]
4033+
fn test_durable_preimages_on_closed_channel_legacy_e() {
4034+
do_test_durable_preimages_on_closed_channel_legacy(false, false, true);
4035+
}
4036+
#[test]
4037+
fn test_durable_preimages_on_closed_channel_legacy_f() {
4038+
do_test_durable_preimages_on_closed_channel_legacy(false, false, false);
40244039
}
40254040

4026-
fn do_test_reload_mon_update_completion_actions(close_during_reload: bool) {
4041+
fn do_test_reload_mon_update_completion_actions_legacy(close_during_reload: bool) {
40274042
// Test that if a `ChannelMonitorUpdate` completes but a `ChannelManager` isn't serialized
40284043
// before restart we run the monitor update completion action on startup.
40294044
let chanmon_cfgs = create_chanmon_cfgs(3);
@@ -4139,9 +4154,9 @@ fn do_test_reload_mon_update_completion_actions(close_during_reload: bool) {
41394154
}
41404155

41414156
#[test]
4142-
fn test_reload_mon_update_completion_actions() {
4143-
do_test_reload_mon_update_completion_actions(true);
4144-
do_test_reload_mon_update_completion_actions(false);
4157+
fn test_reload_mon_update_completion_actions_legacy() {
4158+
do_test_reload_mon_update_completion_actions_legacy(true);
4159+
do_test_reload_mon_update_completion_actions_legacy(false);
41454160
}
41464161

41474162
fn do_test_glacial_peer_cant_hang(hold_chan_a: bool) {

lightning/src/ln/functional_test_utils.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,7 +2620,7 @@ macro_rules! expect_htlc_handling_failed_destinations {
26202620
assert!($expected_failures.contains(&failure_type));
26212621
num_expected_failures -= 1;
26222622
},
2623-
_ => panic!("Unexpected destination"),
2623+
e => panic!("Expected HTLCHandlingFailed, got {e:?}"),
26242624
}
26252625
}
26262626
assert_eq!(num_expected_failures, 0);
@@ -2644,7 +2644,8 @@ pub fn expect_and_process_pending_htlcs_and_htlc_handling_failed(
26442644
let events = node.node.get_and_clear_pending_events();
26452645
expect_htlc_failure_conditions(events, expected_failures);
26462646
expect_and_process_pending_htlcs(node, false);
2647-
assert!(node.node.get_and_clear_pending_events().is_empty());
2647+
let events = node.node.get_and_clear_pending_events();
2648+
assert!(events.is_empty(), "Unexpected events: {events:?}");
26482649
}
26492650

26502651
pub fn expect_and_process_pending_htlcs(node: &Node<'_, '_, '_>, process_twice: bool) {

lightning/src/ln/functional_tests.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7964,10 +7964,19 @@ fn do_test_onchain_htlc_settlement_after_close(
79647964
}
79657965

79667966
#[xtest(feature = "_externalize_tests")]
7967-
pub fn test_onchain_htlc_settlement_after_close() {
7967+
pub fn test_onchain_htlc_settlement_after_close_a() {
79687968
do_test_onchain_htlc_settlement_after_close(true, true);
7969+
}
7970+
#[xtest(feature = "_externalize_tests")]
7971+
pub fn test_onchain_htlc_settlement_after_close_b() {
79697972
do_test_onchain_htlc_settlement_after_close(false, true); // Technically redundant, but may as well
7973+
}
7974+
#[xtest(feature = "_externalize_tests")]
7975+
pub fn test_onchain_htlc_settlement_after_close_c() {
79707976
do_test_onchain_htlc_settlement_after_close(true, false);
7977+
}
7978+
#[xtest(feature = "_externalize_tests")]
7979+
pub fn test_onchain_htlc_settlement_after_close_d() {
79717980
do_test_onchain_htlc_settlement_after_close(false, false);
79727981
}
79737982

0 commit comments

Comments
 (0)