Skip to content

Commit f1cae54

Browse files
committed
ln/refactor: add helper function for manual acceptance tests
1 parent 816f170 commit f1cae54

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16091,7 +16091,9 @@ mod tests {
1609116091

1609216092
#[test]
1609316093
fn test_inbound_anchors_manual_acceptance() {
16094-
test_inbound_anchors_manual_acceptance_with_override(None);
16094+
let mut anchors_cfg = test_default_channel_config();
16095+
anchors_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
16096+
do_test_manual_inbound_accept_with_override(anchors_cfg, None);
1609516097
}
1609616098

1609716099
#[test]
@@ -16108,7 +16110,10 @@ mod tests {
1610816110
update_overrides: None,
1610916111
};
1611016112

16111-
let accept_message = test_inbound_anchors_manual_acceptance_with_override(Some(overrides));
16113+
let mut anchors_cfg = test_default_channel_config();
16114+
anchors_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
16115+
16116+
let accept_message = do_test_manual_inbound_accept_with_override(anchors_cfg, Some(overrides));
1611216117
assert_eq!(accept_message.common_fields.max_htlc_value_in_flight_msat, 5_000_000);
1611316118
assert_eq!(accept_message.common_fields.htlc_minimum_msat, 1_000);
1611416119
assert_eq!(accept_message.common_fields.minimum_depth, 2);
@@ -16117,19 +16122,16 @@ mod tests {
1611716122
assert_eq!(accept_message.channel_reserve_satoshis, 2_000);
1611816123
}
1611916124

16120-
fn test_inbound_anchors_manual_acceptance_with_override(config_overrides: Option<ChannelConfigOverrides>) -> AcceptChannel {
16121-
// Tests that we properly limit inbound channels when we have the manual-channel-acceptance
16122-
// flag set and (sometimes) accept channels as 0conf.
16123-
let mut anchors_cfg = test_default_channel_config();
16124-
anchors_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
16125+
fn do_test_manual_inbound_accept_with_override(start_cfg: UserConfig,
16126+
config_overrides: Option<ChannelConfigOverrides>) -> AcceptChannel {
1612516127

16126-
let mut anchors_manual_accept_cfg = anchors_cfg.clone();
16127-
anchors_manual_accept_cfg.manually_accept_inbound_channels = true;
16128+
let mut mannual_accept_cfg = start_cfg.clone();
16129+
mannual_accept_cfg.manually_accept_inbound_channels = true;
1612816130

1612916131
let chanmon_cfgs = create_chanmon_cfgs(3);
1613016132
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
1613116133
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs,
16132-
&[Some(anchors_cfg.clone()), Some(anchors_cfg.clone()), Some(anchors_manual_accept_cfg.clone())]);
16134+
&[Some(start_cfg.clone()), Some(start_cfg.clone()), Some(mannual_accept_cfg.clone())]);
1613316135
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
1613416136

1613516137
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 0, 42, None, None).unwrap();

0 commit comments

Comments
 (0)