Skip to content

Commit 6a71d9e

Browse files
committed
ln/refactor: add helper function for manual acceptance tests
1 parent 2063b74 commit 6a71d9e

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16288,7 +16288,9 @@ mod tests {
1628816288

1628916289
#[test]
1629016290
fn test_inbound_anchors_manual_acceptance() {
16291-
test_inbound_anchors_manual_acceptance_with_override(None);
16291+
let mut anchors_cfg = test_default_channel_config();
16292+
anchors_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
16293+
do_test_manual_inbound_accept_with_override(anchors_cfg, None);
1629216294
}
1629316295

1629416296
#[test]
@@ -16305,7 +16307,11 @@ mod tests {
1630516307
update_overrides: None,
1630616308
};
1630716309

16308-
let accept_message = test_inbound_anchors_manual_acceptance_with_override(Some(overrides));
16310+
let mut anchors_cfg = test_default_channel_config();
16311+
anchors_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
16312+
16313+
let accept_message =
16314+
do_test_manual_inbound_accept_with_override(anchors_cfg, Some(overrides));
1630916315
assert_eq!(accept_message.common_fields.max_htlc_value_in_flight_msat, 5_000_000);
1631016316
assert_eq!(accept_message.common_fields.htlc_minimum_msat, 1_000);
1631116317
assert_eq!(accept_message.common_fields.minimum_depth, 2);
@@ -16315,19 +16321,16 @@ mod tests {
1631516321
}
1631616322

1631716323
#[rustfmt::skip]
16318-
fn test_inbound_anchors_manual_acceptance_with_override(config_overrides: Option<ChannelConfigOverrides>) -> AcceptChannel {
16319-
// Tests that we properly limit inbound channels when we have the manual-channel-acceptance
16320-
// flag set and (sometimes) accept channels as 0conf.
16321-
let mut anchors_cfg = test_default_channel_config();
16322-
anchors_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
16324+
fn do_test_manual_inbound_accept_with_override(start_cfg: UserConfig,
16325+
config_overrides: Option<ChannelConfigOverrides>) -> AcceptChannel {
1632316326

16324-
let mut anchors_manual_accept_cfg = anchors_cfg.clone();
16325-
anchors_manual_accept_cfg.manually_accept_inbound_channels = true;
16327+
let mut mannual_accept_cfg = start_cfg.clone();
16328+
mannual_accept_cfg.manually_accept_inbound_channels = true;
1632616329

1632716330
let chanmon_cfgs = create_chanmon_cfgs(3);
1632816331
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
1632916332
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs,
16330-
&[Some(anchors_cfg.clone()), Some(anchors_cfg.clone()), Some(anchors_manual_accept_cfg.clone())]);
16333+
&[Some(start_cfg.clone()), Some(start_cfg.clone()), Some(mannual_accept_cfg.clone())]);
1633116334
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
1633216335

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

0 commit comments

Comments
 (0)