Skip to content

Commit a0e25b6

Browse files
committed
fixup: cleanup awkward if else
1 parent 77e28f7 commit a0e25b6

File tree

3 files changed

+35
-77
lines changed

3 files changed

+35
-77
lines changed

lightning/src/ln/async_signer_tests.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -973,13 +973,9 @@ fn do_test_async_holder_signatures(keyed_anchors: bool, p2a_anchor: bool, remote
973973
// asynchronously by allowing their retrieval to fail and retrying via
974974
// `ChannelMonitor::signer_unblocked`.
975975
let mut config = test_default_channel_config();
976-
if keyed_anchors {
977-
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
978-
config.manually_accept_inbound_channels = true;
979-
} else if p2a_anchor {
980-
config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
981-
config.manually_accept_inbound_channels = true;
982-
}
976+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
977+
config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
978+
config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
983979

984980
let chanmon_cfgs = create_chanmon_cfgs(2);
985981
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);

lightning/src/ln/monitor_tests.rs

Lines changed: 29 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,11 @@ fn do_chanmon_claim_value_coop_close(keyed_anchors: bool, p2a_anchor: bool) {
317317
let chanmon_cfgs = create_chanmon_cfgs(2);
318318
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
319319
let mut user_config = test_default_channel_config();
320-
if keyed_anchors {
321-
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
322-
user_config.manually_accept_inbound_channels = true;
323-
} else if p2a_anchor {
324-
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
325-
user_config.manually_accept_inbound_channels = true;
326-
}
320+
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
321+
user_config.manually_accept_inbound_channels = true;
322+
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
323+
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
324+
user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
327325
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
328326
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
329327

@@ -472,13 +470,9 @@ fn do_test_claim_value_force_close(keyed_anchors: bool, p2a_anchor: bool, prev_c
472470
}
473471
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
474472
let mut user_config = test_default_channel_config();
475-
if keyed_anchors {
476-
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
477-
user_config.manually_accept_inbound_channels = true;
478-
} else if p2a_anchor {
479-
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
480-
user_config.manually_accept_inbound_channels = true;
481-
}
473+
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
474+
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
475+
user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
482476
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
483477
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
484478

@@ -875,13 +869,9 @@ fn do_test_balances_on_local_commitment_htlcs(keyed_anchors: bool, p2a_anchor: b
875869
let chanmon_cfgs = create_chanmon_cfgs(2);
876870
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
877871
let mut user_config = test_default_channel_config();
878-
if keyed_anchors {
879-
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
880-
user_config.manually_accept_inbound_channels = true;
881-
} else if p2a_anchor {
882-
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
883-
user_config.manually_accept_inbound_channels = true;
884-
}
872+
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
873+
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
874+
user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
885875
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
886876
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
887877

@@ -1390,13 +1380,9 @@ fn do_test_revoked_counterparty_commitment_balances(keyed_anchors: bool, p2a_anc
13901380
chanmon_cfgs[1].keys_manager.disable_revocation_policy_check = true;
13911381
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
13921382
let mut user_config = test_default_channel_config();
1393-
if keyed_anchors {
1394-
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
1395-
user_config.manually_accept_inbound_channels = true;
1396-
} else if p2a_anchor {
1397-
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
1398-
user_config.manually_accept_inbound_channels = true;
1399-
}
1383+
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
1384+
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
1385+
user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
14001386
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
14011387
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
14021388

@@ -1697,13 +1683,9 @@ fn do_test_revoked_counterparty_htlc_tx_balances(keyed_anchors: bool, p2a_anchor
16971683
chanmon_cfgs[1].keys_manager.disable_revocation_policy_check = true;
16981684
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
16991685
let mut user_config = test_default_channel_config();
1700-
if keyed_anchors {
1701-
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
1702-
user_config.manually_accept_inbound_channels = true;
1703-
} else if p2a_anchor {
1704-
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
1705-
user_config.manually_accept_inbound_channels = true;
1706-
}
1686+
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
1687+
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
1688+
user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
17071689
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
17081690
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
17091691

@@ -1991,13 +1973,9 @@ fn do_test_revoked_counterparty_aggregated_claims(keyed_anchors: bool, p2a_ancho
19911973
chanmon_cfgs[0].keys_manager.disable_revocation_policy_check = true;
19921974
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
19931975
let mut user_config = test_default_channel_config();
1994-
if keyed_anchors {
1995-
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
1996-
user_config.manually_accept_inbound_channels = true;
1997-
} else if p2a_anchor {
1998-
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
1999-
user_config.manually_accept_inbound_channels = true;
2000-
}
1976+
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
1977+
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
1978+
user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
20011979
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
20021980
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
20031981

@@ -2272,13 +2250,9 @@ fn do_test_claimable_balance_correct_while_payment_pending(outbound_payment: boo
22722250
let mut chanmon_cfgs = create_chanmon_cfgs(3);
22732251
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
22742252
let mut user_config = test_default_channel_config();
2275-
if keyed_anchors {
2276-
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
2277-
user_config.manually_accept_inbound_channels = true;
2278-
} else if p2a_anchor {
2279-
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
2280-
user_config.manually_accept_inbound_channels = true;
2281-
}
2253+
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
2254+
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
2255+
user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
22822256
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[Some(user_config.clone()), Some(user_config.clone()), Some(user_config)]);
22832257
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
22842258

@@ -2425,13 +2399,9 @@ fn do_test_monitor_rebroadcast_pending_claims(keyed_anchors: bool, p2a_anchor: b
24252399
let mut chanmon_cfgs = create_chanmon_cfgs(2);
24262400
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
24272401
let mut config = test_default_channel_config();
2428-
if keyed_anchors {
2429-
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
2430-
config.manually_accept_inbound_channels = true;
2431-
} else if p2a_anchor {
2432-
config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
2433-
config.manually_accept_inbound_channels = true;
2434-
}
2402+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
2403+
config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
2404+
config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
24352405
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(config.clone()), Some(config)]);
24362406
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
24372407

@@ -3156,13 +3126,9 @@ fn do_test_monitor_claims_with_random_signatures(keyed_anchors: bool, p2a_anchor
31563126
let chanmon_cfgs = create_chanmon_cfgs(2);
31573127
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
31583128
let mut user_config = test_default_channel_config();
3159-
if keyed_anchors {
3160-
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
3161-
user_config.manually_accept_inbound_channels = true;
3162-
} else if p2a_anchor {
3163-
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
3164-
user_config.manually_accept_inbound_channels = true;
3165-
}
3129+
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
3130+
user_config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
3131+
user_config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
31663132
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_config.clone()), Some(user_config)]);
31673133
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
31683134

lightning/src/ln/reorg_tests.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -824,13 +824,9 @@ fn do_test_retries_own_commitment_broadcast_after_reorg(keyed_anchors: bool, p2a
824824
}
825825
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
826826
let mut config = test_default_channel_config();
827-
if keyed_anchors {
828-
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
829-
config.manually_accept_inbound_channels = true;
830-
} else if p2a_anchor {
831-
config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = true;
832-
config.manually_accept_inbound_channels = true;
833-
}
827+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
828+
config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
829+
config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
834830
let persister;
835831
let new_chain_monitor;
836832
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(config.clone()), Some(config.clone())]);

0 commit comments

Comments
 (0)