Skip to content

Commit 306eea7

Browse files
committed
Rename test default channel config
Now that anchor channels are the default, rename `test_default_anchors_channel_config` to `test_default_channel_config` and the previous default to legacy.
1 parent aebcd1f commit 306eea7

18 files changed

+329
-146
lines changed

lightning-persister/src/test_utils.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ pub(crate) fn do_test_store<K: KVStoreSync + Sync>(store_0: &K, store_1: &K) {
132132
);
133133
node_cfgs[0].chain_monitor = chain_mon_0;
134134
node_cfgs[1].chain_monitor = chain_mon_1;
135-
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
135+
let legacy_cfg = test_legacy_channel_config();
136+
let node_chanmgrs =
137+
create_node_chanmgrs(2, &node_cfgs, &[Some(legacy_cfg.clone()), Some(legacy_cfg)]);
136138
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
137139

138140
let node_b_id = nodes[1].node.get_our_node_id();

lightning/src/chain/chainmonitor.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,12 @@ mod tests {
16871687
fn test_chainsync_triggers_distributed_monitor_persistence() {
16881688
let chanmon_cfgs = create_chanmon_cfgs(3);
16891689
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
1690-
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
1690+
let legacy_cfg = test_legacy_channel_config();
1691+
let node_chanmgrs = create_node_chanmgrs(
1692+
3,
1693+
&node_cfgs,
1694+
&[Some(legacy_cfg.clone()), Some(legacy_cfg.clone()), Some(legacy_cfg)],
1695+
);
16911696
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
16921697

16931698
let node_a_id = nodes[0].node.get_our_node_id();

lightning/src/chain/channelmonitor.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6808,7 +6808,8 @@ mod tests {
68086808
// updates is handled correctly in such conditions.
68096809
let chanmon_cfgs = create_chanmon_cfgs(3);
68106810
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
6811-
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
6811+
let legacy_cfg = test_legacy_channel_config();
6812+
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[Some(legacy_cfg.clone()), Some(legacy_cfg.clone()), Some(legacy_cfg)]);
68126813
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
68136814
let channel = create_announced_chan_between_nodes(&nodes, 0, 1);
68146815
create_announced_chan_between_nodes(&nodes, 1, 2);

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3779,7 +3779,12 @@ fn do_test_durable_preimages_on_closed_channel(
37793779
let chain_mon;
37803780
let node_b_reload;
37813781

3782-
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
3782+
let legacy_cfg = test_legacy_channel_config();
3783+
let node_chanmgrs = create_node_chanmgrs(
3784+
3,
3785+
&node_cfgs,
3786+
&[Some(legacy_cfg.clone()), Some(legacy_cfg.clone()), None],
3787+
);
37833788
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
37843789

37853790
let node_a_id = nodes[0].node.get_our_node_id();
@@ -3974,7 +3979,8 @@ fn do_test_reload_mon_update_completion_actions(close_during_reload: bool) {
39743979
let chain_mon;
39753980
let node_b_reload;
39763981

3977-
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
3982+
let legacy_cfg = test_legacy_channel_config();
3983+
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[Some(legacy_cfg), None, None]);
39783984
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
39793985

39803986
let node_b_id = nodes[1].node.get_our_node_id();
@@ -4462,7 +4468,9 @@ fn test_claim_to_closed_channel_blocks_forwarded_preimage_removal() {
44624468
// This tests that behavior.
44634469
let chanmon_cfgs = create_chanmon_cfgs(3);
44644470
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
4465-
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
4471+
let legacy_cfg = test_legacy_channel_config();
4472+
let node_chanmgrs =
4473+
create_node_chanmgrs(3, &node_cfgs, &[Some(legacy_cfg.clone()), Some(legacy_cfg), None]);
44664474
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
44674475

44684476
let node_a_id = nodes[0].node.get_our_node_id();
@@ -4543,7 +4551,8 @@ fn test_claim_to_closed_channel_blocks_claimed_event() {
45434551
// This tests that behavior.
45444552
let chanmon_cfgs = create_chanmon_cfgs(2);
45454553
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
4546-
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
4554+
let legacy_cfg = test_legacy_channel_config();
4555+
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(legacy_cfg), None]);
45474556
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
45484557

45494558
let node_a_id = nodes[0].node.get_our_node_id();

lightning/src/ln/channel_open_tests.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ fn test_0conf_limiting() {
172172

173173
#[test]
174174
fn test_inbound_anchors_manual_acceptance() {
175-
let anchors_cfg = test_default_anchors_channel_config();
175+
let anchors_cfg = test_default_channel_config();
176176
do_test_manual_inbound_accept_with_override(anchors_cfg, None);
177177
}
178178

@@ -190,7 +190,7 @@ fn test_inbound_anchors_config_overridden() {
190190
update_overrides: None,
191191
};
192192

193-
let mut anchors_cfg = test_default_anchors_channel_config();
193+
let mut anchors_cfg = test_default_channel_config();
194194
let accept_message = do_test_manual_inbound_accept_with_override(anchors_cfg, Some(overrides));
195195
assert_eq!(accept_message.common_fields.max_htlc_value_in_flight_msat, 5_000_000);
196196
assert_eq!(accept_message.common_fields.htlc_minimum_msat, 1_000);
@@ -306,9 +306,8 @@ fn test_zero_fee_commitments_downgrade_to_static_remote() {
306306
// are supported (but not accepted), but not legacy anchors.
307307
let mut initiator_cfg = test_default_channel_config();
308308
initiator_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
309-
initiator_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
310309

311-
let mut receiver_cfg = test_default_channel_config();
310+
let mut receiver_cfg = test_legacy_channel_config();
312311
receiver_cfg.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
313312

314313
let start_type = ChannelTypeFeatures::anchors_zero_fee_commitments();
@@ -367,9 +366,8 @@ fn do_test_channel_type_downgrade(
367366
fn test_no_channel_downgrade() {
368367
// Tests that the local node will not retry when a `option_static_remote` channel is
369368
// rejected by a peer that advertises support for the feature.
370-
let initiator_cfg = test_default_channel_config();
369+
let initiator_cfg = test_legacy_channel_config();
371370
let mut receiver_cfg = test_default_channel_config();
372-
receiver_cfg.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
373371

374372
let chanmon_cfgs = create_chanmon_cfgs(2);
375373
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -459,11 +457,11 @@ fn test_channel_resumption_fail_post_funding() {
459457
pub fn test_insane_channel_opens() {
460458
// Stand up a network of 2 nodes
461459
use crate::ln::channel::TOTAL_BITCOIN_SUPPLY_SATOSHIS;
462-
let mut cfg = UserConfig::default();
463-
cfg.channel_handshake_limits.max_funding_satoshis = TOTAL_BITCOIN_SUPPLY_SATOSHIS + 1;
460+
let mut legacy_cfg = test_legacy_channel_config();
461+
legacy_cfg.channel_handshake_limits.max_funding_satoshis = TOTAL_BITCOIN_SUPPLY_SATOSHIS + 1;
464462
let chanmon_cfgs = create_chanmon_cfgs(2);
465463
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
466-
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(cfg.clone())]);
464+
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(legacy_cfg.clone())]);
467465
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
468466

469467
let node_a_id = nodes[0].node.get_our_node_id();
@@ -473,7 +471,7 @@ pub fn test_insane_channel_opens() {
473471
// funding satoshis
474472
let channel_value_sat = 31337; // same as funding satoshis
475473
let channel_reserve_satoshis =
476-
get_holder_selected_channel_reserve_satoshis(channel_value_sat, &cfg);
474+
get_holder_selected_channel_reserve_satoshis(channel_value_sat, &legacy_cfg);
477475
let push_msat = (channel_value_sat - channel_reserve_satoshis) * 1000;
478476

479477
// Have node0 initiate a channel to node1 with aforementioned parameters

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20398,7 +20398,7 @@ mod tests {
2039820398
fn test_trigger_lnd_force_close() {
2039920399
let chanmon_cfg = create_chanmon_cfgs(2);
2040020400
let node_cfg = create_node_cfgs(2, &chanmon_cfg);
20401-
let user_config = test_default_channel_config();
20401+
let user_config = test_legacy_channel_config();
2040220402
let node_chanmgr = create_node_chanmgrs(2, &node_cfg, &[Some(user_config.clone()), Some(user_config)]);
2040320403
let nodes = create_network(2, &node_cfg, &node_chanmgr);
2040420404
let message = "Channel force-closed".to_owned();

lightning/src/ln/functional_test_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4532,7 +4532,7 @@ pub fn create_node_cfgs_with_node_id_message_router<'a>(
45324532
)
45334533
}
45344534

4535-
pub fn test_default_channel_config() -> UserConfig {
4535+
pub fn test_legacy_channel_config() -> UserConfig {
45364536
let mut default_config = UserConfig::default();
45374537
default_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = false;
45384538
// Set cltv_expiry_delta slightly lower to keep the final CLTV values inside one byte in our
@@ -4552,8 +4552,8 @@ pub fn test_default_channel_config() -> UserConfig {
45524552
default_config
45534553
}
45544554

4555-
pub fn test_default_anchors_channel_config() -> UserConfig {
4556-
let mut config = test_default_channel_config();
4555+
pub fn test_default_channel_config() -> UserConfig {
4556+
let mut config = test_legacy_channel_config();
45574557
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
45584558
config
45594559
}

0 commit comments

Comments
 (0)