Skip to content

Commit 4d7c172

Browse files
committed
ln/refactor: add helper function for manual acceptance tests
1 parent 568334c commit 4d7c172

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
@@ -16092,7 +16092,9 @@ mod tests {
1609216092

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

1609816100
#[test]
@@ -16109,7 +16111,10 @@ mod tests {
1610916111
update_overrides: None,
1611016112
};
1611116113

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

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

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

1613016132
let chanmon_cfgs = create_chanmon_cfgs(3);
1613116133
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
1613216134
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs,
16133-
&[Some(anchors_cfg.clone()), Some(anchors_cfg.clone()), Some(anchors_manual_accept_cfg.clone())]);
16135+
&[Some(start_cfg.clone()), Some(start_cfg.clone()), Some(mannual_accept_cfg.clone())]);
1613416136
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
1613516137

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

0 commit comments

Comments
 (0)