Skip to content

Commit a4620af

Browse files
author
Antoine Riard
committed
Pass UserConfig to node creation test utilities
We way want more granularity on the set of user opt-in features at a given time, specially with new 1.1 spec features
1 parent d2647e0 commit a4620af

File tree

3 files changed

+92
-92
lines changed

3 files changed

+92
-92
lines changed

src/ln/chanmon_update_fail_tests.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use ln::functional_test_utils::*;
1818
#[test]
1919
fn test_simple_monitor_permanent_update_fail() {
2020
// Test that we handle a simple permanent monitor update failure
21-
let mut nodes = create_network(2);
21+
let mut nodes = create_network(2, &[None, None]);
2222
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
2323

2424
let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
@@ -48,7 +48,7 @@ fn test_simple_monitor_permanent_update_fail() {
4848
fn do_test_simple_monitor_temporary_update_fail(disconnect: bool) {
4949
// Test that we can recover from a simple temporary monitor update failure optionally with
5050
// a disconnect in between
51-
let mut nodes = create_network(2);
51+
let mut nodes = create_network(2, &[None, None]);
5252
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
5353

5454
let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
@@ -147,7 +147,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
147147
// * We then walk through more message exchanges to get the original update_add_htlc
148148
// through, swapping message ordering based on disconnect_count & 8 and optionally
149149
// disconnect/reconnecting based on disconnect_count.
150-
let mut nodes = create_network(2);
150+
let mut nodes = create_network(2, &[None, None]);
151151
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
152152

153153
let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
@@ -473,7 +473,7 @@ fn test_monitor_temporary_update_fail_c() {
473473
#[test]
474474
fn test_monitor_update_fail_cs() {
475475
// Tests handling of a monitor update failure when processing an incoming commitment_signed
476-
let mut nodes = create_network(2);
476+
let mut nodes = create_network(2, &[None, None]);
477477
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
478478

479479
let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
@@ -552,7 +552,7 @@ fn test_monitor_update_fail_no_rebroadcast() {
552552
// Tests handling of a monitor update failure when no message rebroadcasting on
553553
// test_restore_channel_monitor() is required. Backported from
554554
// chanmon_fail_consistency fuzz tests.
555-
let mut nodes = create_network(2);
555+
let mut nodes = create_network(2, &[None, None]);
556556
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
557557

558558
let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
@@ -594,7 +594,7 @@ fn test_monitor_update_fail_no_rebroadcast() {
594594
fn test_monitor_update_raa_while_paused() {
595595
// Tests handling of an RAA while monitor updating has already been marked failed.
596596
// Backported from chanmon_fail_consistency fuzz tests as this used to be broken.
597-
let mut nodes = create_network(2);
597+
let mut nodes = create_network(2, &[None, None]);
598598
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
599599

600600
send_payment(&nodes[0], &[&nodes[1]], 5000000);
@@ -661,7 +661,7 @@ fn test_monitor_update_raa_while_paused() {
661661

662662
fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
663663
// Tests handling of a monitor update failure when processing an incoming RAA
664-
let mut nodes = create_network(3);
664+
let mut nodes = create_network(3, &[None, None, None]);
665665
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
666666
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
667667

@@ -914,7 +914,7 @@ fn test_monitor_update_fail_reestablish() {
914914
// Simple test for message retransmission after monitor update failure on
915915
// channel_reestablish generating a monitor update (which comes from freeing holding cell
916916
// HTLCs).
917-
let mut nodes = create_network(3);
917+
let mut nodes = create_network(3, &[None, None, None]);
918918
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
919919
create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
920920

@@ -992,7 +992,7 @@ fn raa_no_response_awaiting_raa_state() {
992992
// due to a previous monitor update failure, we still set AwaitingRemoteRevoke on the channel
993993
// in question (assuming it intends to respond with a CS after monitor updating is restored).
994994
// Backported from chanmon_fail_consistency fuzz tests as this used to be broken.
995-
let mut nodes = create_network(2);
995+
let mut nodes = create_network(2, &[None, None]);
996996
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
997997

998998
let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
@@ -1105,7 +1105,7 @@ fn claim_while_disconnected_monitor_update_fail() {
11051105
// Backported from chanmon_fail_consistency fuzz tests as an unmerged version of the handling
11061106
// code introduced a regression in this test (specifically, this caught a removal of the
11071107
// channel_reestablish handling ensuring the order was sensical given the messages used).
1108-
let mut nodes = create_network(2);
1108+
let mut nodes = create_network(2, &[None, None]);
11091109
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
11101110

11111111
// Forward a payment for B to claim
@@ -1220,7 +1220,7 @@ fn monitor_failed_no_reestablish_response() {
12201220
// response to a commitment_signed.
12211221
// Backported from chanmon_fail_consistency fuzz tests as it caught a long-standing
12221222
// debug_assert!() failure in channel_reestablish handling.
1223-
let mut nodes = create_network(2);
1223+
let mut nodes = create_network(2, &[None, None]);
12241224
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
12251225

12261226
// Route the payment and deliver the initial commitment_signed (with a monitor update failure
@@ -1286,7 +1286,7 @@ fn first_message_on_recv_ordering() {
12861286
// have no pending response but will want to send a RAA/CS (with the updates for the second
12871287
// payment applied).
12881288
// Backported from chanmon_fail_consistency fuzz tests as it caught a bug here.
1289-
let mut nodes = create_network(2);
1289+
let mut nodes = create_network(2, &[None, None]);
12901290
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
12911291

12921292
// Route the first payment outbound, holding the last RAA for B until we are set up so that we
@@ -1371,7 +1371,7 @@ fn test_monitor_update_fail_claim() {
13711371
// update to claim the payment. We then send a payment C->B->A, making the forward of this
13721372
// payment from B to A fail due to the paused channel. Finally, we restore the channel monitor
13731373
// updating and claim the payment on B.
1374-
let mut nodes = create_network(3);
1374+
let mut nodes = create_network(3, &[None, None, None]);
13751375
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
13761376
create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
13771377

@@ -1441,7 +1441,7 @@ fn test_monitor_update_on_pending_forwards() {
14411441
// We do this with a simple 3-node network, sending a payment from A to C and one from C to A.
14421442
// The payment from A to C will be failed by C and pending a back-fail to A, while the payment
14431443
// from C to A will be pending a forward to A.
1444-
let mut nodes = create_network(3);
1444+
let mut nodes = create_network(3, &[None, None, None]);
14451445
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
14461446
create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
14471447

@@ -1505,7 +1505,7 @@ fn monitor_update_claim_fail_no_response() {
15051505
// to channel being AwaitingRAA).
15061506
// Backported from chanmon_fail_consistency fuzz tests as an unmerged version of the handling
15071507
// code was broken.
1508-
let mut nodes = create_network(2);
1508+
let mut nodes = create_network(2, &[None, None]);
15091509
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
15101510

15111511
// Forward a payment for B to claim

src/ln/functional_test_utils.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ pub fn fail_payment(origin_node: &Node, expected_route: &[&Node], our_payment_ha
827827
fail_payment_along_route(origin_node, expected_route, false, our_payment_hash);
828828
}
829829

830-
pub fn create_network(node_count: usize) -> Vec<Node> {
830+
pub fn create_network(node_count: usize, node_config: &[Option<UserConfig>]) -> Vec<Node> {
831831
let mut nodes = Vec::new();
832832
let mut rng = thread_rng();
833833
let secp_ctx = Secp256k1::new();
@@ -844,10 +844,10 @@ pub fn create_network(node_count: usize) -> Vec<Node> {
844844
rng.fill_bytes(&mut seed);
845845
let keys_manager = Arc::new(test_utils::TestKeysInterface::new(&seed, Network::Testnet, Arc::clone(&logger)));
846846
let chan_monitor = Arc::new(test_utils::TestChannelMonitor::new(chain_monitor.clone(), tx_broadcaster.clone(), logger.clone(), feeest.clone()));
847-
let mut config = UserConfig::new();
848-
config.channel_options.announced_channel = true;
849-
config.peer_channel_config_limits.force_announced_channel_preference = false;
850-
let node = ChannelManager::new(Network::Testnet, feeest.clone(), chan_monitor.clone(), chain_monitor.clone(), tx_broadcaster.clone(), Arc::clone(&logger), keys_manager.clone(), config).unwrap();
847+
let mut default_config = UserConfig::new();
848+
default_config.channel_options.announced_channel = true;
849+
default_config.peer_channel_config_limits.force_announced_channel_preference = false;
850+
let node = ChannelManager::new(Network::Testnet, feeest.clone(), chan_monitor.clone(), chain_monitor.clone(), tx_broadcaster.clone(), Arc::clone(&logger), keys_manager.clone(), if node_config[i].is_some() { node_config[i].clone().unwrap() } else { default_config }).unwrap();
851851
let router = Router::new(PublicKey::from_secret_key(&secp_ctx, &keys_manager.get_node_secret()), chain_monitor.clone(), Arc::clone(&logger));
852852
nodes.push(Node { chain_monitor, tx_broadcaster, chan_monitor, node, router, keys_manager, node_seed: seed,
853853
network_payment_count: payment_count.clone(),

0 commit comments

Comments
 (0)