@@ -19,11 +19,13 @@ use ln::functional_test_utils::*;
1919#[ test]
2020fn test_simple_monitor_permanent_update_fail ( ) {
2121 // Test that we handle a simple permanent monitor update failure
22- let mut nodes = create_network ( 2 , & [ None , None ] ) ;
22+ let node_cfgs = create_node_cfgs ( 2 ) ;
23+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
24+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
2325 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
2426
2527 let route = nodes[ 0 ] . router . get_route ( & nodes[ 1 ] . node . get_our_node_id ( ) , None , & Vec :: new ( ) , 1000000 , TEST_FINAL_CLTV ) . unwrap ( ) ;
26- let ( _, payment_hash_1) = get_payment_preimage_hash ! ( nodes[ 0 ] ) ;
28+ let ( _, payment_hash_1) = get_payment_preimage_hash ! ( & nodes[ 0 ] ) ;
2729
2830 * nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Err ( ChannelMonitorUpdateErr :: PermanentFailure ) ;
2931 if let Err ( APIError :: ChannelUnavailable { ..} ) = nodes[ 0 ] . node . send_payment ( route, payment_hash_1) { } else { panic ! ( ) ; }
@@ -49,11 +51,13 @@ fn test_simple_monitor_permanent_update_fail() {
4951fn do_test_simple_monitor_temporary_update_fail ( disconnect : bool ) {
5052 // Test that we can recover from a simple temporary monitor update failure optionally with
5153 // a disconnect in between
52- let mut nodes = create_network ( 2 , & [ None , None ] ) ;
54+ let node_cfgs = create_node_cfgs ( 2 ) ;
55+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
56+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
5357 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
5458
5559 let route = nodes[ 0 ] . router . get_route ( & nodes[ 1 ] . node . get_our_node_id ( ) , None , & Vec :: new ( ) , 1000000 , TEST_FINAL_CLTV ) . unwrap ( ) ;
56- let ( payment_preimage_1, payment_hash_1) = get_payment_preimage_hash ! ( nodes[ 0 ] ) ;
60+ let ( payment_preimage_1, payment_hash_1) = get_payment_preimage_hash ! ( & nodes[ 0 ] ) ;
5761
5862 * nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ;
5963 if let Err ( APIError :: MonitorUpdateFailed ) = nodes[ 0 ] . node . send_payment ( route. clone ( ) , payment_hash_1) { } else { panic ! ( ) ; }
@@ -95,7 +99,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool) {
9599 claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1, 1_000_000 ) ;
96100
97101 // Now set it to failed again...
98- let ( _, payment_hash_2) = get_payment_preimage_hash ! ( nodes[ 0 ] ) ;
102+ let ( _, payment_hash_2) = get_payment_preimage_hash ! ( & nodes[ 0 ] ) ;
99103 * nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ;
100104 if let Err ( APIError :: MonitorUpdateFailed ) = nodes[ 0 ] . node . send_payment ( route, payment_hash_2) { } else { panic ! ( ) ; }
101105 check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
@@ -148,7 +152,9 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
148152 // * We then walk through more message exchanges to get the original update_add_htlc
149153 // through, swapping message ordering based on disconnect_count & 8 and optionally
150154 // disconnect/reconnecting based on disconnect_count.
151- let mut nodes = create_network ( 2 , & [ None , None ] ) ;
155+ let node_cfgs = create_node_cfgs ( 2 ) ;
156+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
157+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
152158 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
153159
154160 let ( payment_preimage_1, _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
@@ -474,7 +480,9 @@ fn test_monitor_temporary_update_fail_c() {
474480#[ test]
475481fn test_monitor_update_fail_cs ( ) {
476482 // Tests handling of a monitor update failure when processing an incoming commitment_signed
477- let mut nodes = create_network ( 2 , & [ None , None ] ) ;
483+ let node_cfgs = create_node_cfgs ( 2 ) ;
484+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
485+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
478486 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
479487
480488 let route = nodes[ 0 ] . router . get_route ( & nodes[ 1 ] . node . get_our_node_id ( ) , None , & Vec :: new ( ) , 1000000 , TEST_FINAL_CLTV ) . unwrap ( ) ;
@@ -553,7 +561,9 @@ fn test_monitor_update_fail_no_rebroadcast() {
553561 // Tests handling of a monitor update failure when no message rebroadcasting on
554562 // test_restore_channel_monitor() is required. Backported from
555563 // chanmon_fail_consistency fuzz tests.
556- let mut nodes = create_network ( 2 , & [ None , None ] ) ;
564+ let node_cfgs = create_node_cfgs ( 2 ) ;
565+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
566+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
557567 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
558568
559569 let route = nodes[ 0 ] . router . get_route ( & nodes[ 1 ] . node . get_our_node_id ( ) , None , & Vec :: new ( ) , 1000000 , TEST_FINAL_CLTV ) . unwrap ( ) ;
@@ -595,7 +605,9 @@ fn test_monitor_update_fail_no_rebroadcast() {
595605fn test_monitor_update_raa_while_paused ( ) {
596606 // Tests handling of an RAA while monitor updating has already been marked failed.
597607 // Backported from chanmon_fail_consistency fuzz tests as this used to be broken.
598- let mut nodes = create_network ( 2 , & [ None , None ] ) ;
608+ let node_cfgs = create_node_cfgs ( 2 ) ;
609+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
610+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
599611 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
600612
601613 send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 5000000 , 5_000_000 ) ;
@@ -662,7 +674,9 @@ fn test_monitor_update_raa_while_paused() {
662674
663675fn do_test_monitor_update_fail_raa ( test_ignore_second_cs : bool ) {
664676 // Tests handling of a monitor update failure when processing an incoming RAA
665- let mut nodes = create_network ( 3 , & [ None , None , None ] ) ;
677+ let node_cfgs = create_node_cfgs ( 3 ) ;
678+ let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
679+ let mut nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
666680 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
667681 let chan_2 = create_announced_chan_between_nodes ( & nodes, 1 , 2 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
668682
@@ -915,7 +929,9 @@ fn test_monitor_update_fail_reestablish() {
915929 // Simple test for message retransmission after monitor update failure on
916930 // channel_reestablish generating a monitor update (which comes from freeing holding cell
917931 // HTLCs).
918- let mut nodes = create_network ( 3 , & [ None , None , None ] ) ;
932+ let node_cfgs = create_node_cfgs ( 3 ) ;
933+ let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
934+ let mut nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
919935 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
920936 create_announced_chan_between_nodes ( & nodes, 1 , 2 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
921937
@@ -993,7 +1009,9 @@ fn raa_no_response_awaiting_raa_state() {
9931009 // due to a previous monitor update failure, we still set AwaitingRemoteRevoke on the channel
9941010 // in question (assuming it intends to respond with a CS after monitor updating is restored).
9951011 // Backported from chanmon_fail_consistency fuzz tests as this used to be broken.
996- let mut nodes = create_network ( 2 , & [ None , None ] ) ;
1012+ let node_cfgs = create_node_cfgs ( 2 ) ;
1013+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
1014+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
9971015 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
9981016
9991017 let route = nodes[ 0 ] . router . get_route ( & nodes[ 1 ] . node . get_our_node_id ( ) , None , & Vec :: new ( ) , 1000000 , TEST_FINAL_CLTV ) . unwrap ( ) ;
@@ -1106,7 +1124,9 @@ fn claim_while_disconnected_monitor_update_fail() {
11061124 // Backported from chanmon_fail_consistency fuzz tests as an unmerged version of the handling
11071125 // code introduced a regression in this test (specifically, this caught a removal of the
11081126 // channel_reestablish handling ensuring the order was sensical given the messages used).
1109- let mut nodes = create_network ( 2 , & [ None , None ] ) ;
1127+ let node_cfgs = create_node_cfgs ( 2 ) ;
1128+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
1129+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
11101130 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
11111131
11121132 // Forward a payment for B to claim
@@ -1221,7 +1241,9 @@ fn monitor_failed_no_reestablish_response() {
12211241 // response to a commitment_signed.
12221242 // Backported from chanmon_fail_consistency fuzz tests as it caught a long-standing
12231243 // debug_assert!() failure in channel_reestablish handling.
1224- let mut nodes = create_network ( 2 , & [ None , None ] ) ;
1244+ let node_cfgs = create_node_cfgs ( 2 ) ;
1245+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
1246+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
12251247 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
12261248
12271249 // Route the payment and deliver the initial commitment_signed (with a monitor update failure
@@ -1287,7 +1309,9 @@ fn first_message_on_recv_ordering() {
12871309 // have no pending response but will want to send a RAA/CS (with the updates for the second
12881310 // payment applied).
12891311 // Backported from chanmon_fail_consistency fuzz tests as it caught a bug here.
1290- let mut nodes = create_network ( 2 , & [ None , None ] ) ;
1312+ let node_cfgs = create_node_cfgs ( 2 ) ;
1313+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
1314+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
12911315 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
12921316
12931317 // Route the first payment outbound, holding the last RAA for B until we are set up so that we
@@ -1372,7 +1396,9 @@ fn test_monitor_update_fail_claim() {
13721396 // update to claim the payment. We then send a payment C->B->A, making the forward of this
13731397 // payment from B to A fail due to the paused channel. Finally, we restore the channel monitor
13741398 // updating and claim the payment on B.
1375- let mut nodes = create_network ( 3 , & [ None , None , None ] ) ;
1399+ let node_cfgs = create_node_cfgs ( 3 ) ;
1400+ let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
1401+ let mut nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
13761402 let chan_1 = create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
13771403 create_announced_chan_between_nodes ( & nodes, 1 , 2 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
13781404
@@ -1445,7 +1471,9 @@ fn test_monitor_update_on_pending_forwards() {
14451471 // We do this with a simple 3-node network, sending a payment from A to C and one from C to A.
14461472 // The payment from A to C will be failed by C and pending a back-fail to A, while the payment
14471473 // from C to A will be pending a forward to A.
1448- let mut nodes = create_network ( 3 , & [ None , None , None ] ) ;
1474+ let node_cfgs = create_node_cfgs ( 3 ) ;
1475+ let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
1476+ let mut nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
14491477 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
14501478 create_announced_chan_between_nodes ( & nodes, 1 , 2 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
14511479
@@ -1510,7 +1538,9 @@ fn monitor_update_claim_fail_no_response() {
15101538 // to channel being AwaitingRAA).
15111539 // Backported from chanmon_fail_consistency fuzz tests as an unmerged version of the handling
15121540 // code was broken.
1513- let mut nodes = create_network ( 2 , & [ None , None ] ) ;
1541+ let node_cfgs = create_node_cfgs ( 3 ) ;
1542+ let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
1543+ let mut nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
15141544 create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
15151545
15161546 // Forward a payment for B to claim
@@ -1569,7 +1599,9 @@ fn monitor_update_claim_fail_no_response() {
15691599fn do_during_funding_monitor_fail ( fail_on_generate : bool , restore_between_fails : bool , fail_on_signed : bool , confirm_a_first : bool , restore_b_before_conf : bool ) {
15701600 // Test that if the monitor update generated by funding_transaction_generated fails we continue
15711601 // the channel setup happily after the update is restored.
1572- let mut nodes = create_network ( 2 , & [ None , None ] ) ;
1602+ let node_cfgs = create_node_cfgs ( 2 ) ;
1603+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
1604+ let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
15731605
15741606 nodes[ 0 ] . node . create_channel ( nodes[ 1 ] . node . get_our_node_id ( ) , 100000 , 10001 , 43 ) . unwrap ( ) ;
15751607 nodes[ 1 ] . node . handle_open_channel ( & nodes[ 0 ] . node . get_our_node_id ( ) , InitFeatures :: supported ( ) , & get_event_msg ! ( nodes[ 0 ] , MessageSendEvent :: SendOpenChannel , nodes[ 1 ] . node. get_our_node_id( ) ) ) ;
0 commit comments