@@ -19,11 +19,13 @@ use ln::functional_test_utils::*;
19
19
#[ test]
20
20
fn test_simple_monitor_permanent_update_fail ( ) {
21
21
// 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) ;
23
25
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
24
26
25
27
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 ] ) ;
27
29
28
30
* nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Err ( ChannelMonitorUpdateErr :: PermanentFailure ) ;
29
31
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() {
49
51
fn do_test_simple_monitor_temporary_update_fail ( disconnect : bool ) {
50
52
// Test that we can recover from a simple temporary monitor update failure optionally with
51
53
// 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) ;
53
57
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
54
58
55
59
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 ] ) ;
57
61
58
62
* nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ;
59
63
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) {
95
99
claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1, 1_000_000 ) ;
96
100
97
101
// 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 ] ) ;
99
103
* nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ;
100
104
if let Err ( APIError :: MonitorUpdateFailed ) = nodes[ 0 ] . node . send_payment ( route, payment_hash_2) { } else { panic ! ( ) ; }
101
105
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
@@ -148,7 +152,9 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
148
152
// * We then walk through more message exchanges to get the original update_add_htlc
149
153
// through, swapping message ordering based on disconnect_count & 8 and optionally
150
154
// 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) ;
152
158
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
153
159
154
160
let ( payment_preimage_1, _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
@@ -474,7 +480,9 @@ fn test_monitor_temporary_update_fail_c() {
474
480
#[ test]
475
481
fn test_monitor_update_fail_cs ( ) {
476
482
// 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) ;
478
486
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
479
487
480
488
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() {
553
561
// Tests handling of a monitor update failure when no message rebroadcasting on
554
562
// test_restore_channel_monitor() is required. Backported from
555
563
// 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) ;
557
567
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
558
568
559
569
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() {
595
605
fn test_monitor_update_raa_while_paused ( ) {
596
606
// Tests handling of an RAA while monitor updating has already been marked failed.
597
607
// 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) ;
599
611
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
600
612
601
613
send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 5000000 , 5_000_000 ) ;
@@ -662,7 +674,9 @@ fn test_monitor_update_raa_while_paused() {
662
674
663
675
fn do_test_monitor_update_fail_raa ( test_ignore_second_cs : bool ) {
664
676
// 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) ;
666
680
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
667
681
let chan_2 = create_announced_chan_between_nodes ( & nodes, 1 , 2 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
668
682
@@ -915,7 +929,9 @@ fn test_monitor_update_fail_reestablish() {
915
929
// Simple test for message retransmission after monitor update failure on
916
930
// channel_reestablish generating a monitor update (which comes from freeing holding cell
917
931
// 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) ;
919
935
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
920
936
create_announced_chan_between_nodes ( & nodes, 1 , 2 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
921
937
@@ -993,7 +1009,9 @@ fn raa_no_response_awaiting_raa_state() {
993
1009
// due to a previous monitor update failure, we still set AwaitingRemoteRevoke on the channel
994
1010
// in question (assuming it intends to respond with a CS after monitor updating is restored).
995
1011
// 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) ;
997
1015
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
998
1016
999
1017
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() {
1106
1124
// Backported from chanmon_fail_consistency fuzz tests as an unmerged version of the handling
1107
1125
// code introduced a regression in this test (specifically, this caught a removal of the
1108
1126
// 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) ;
1110
1130
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
1111
1131
1112
1132
// Forward a payment for B to claim
@@ -1221,7 +1241,9 @@ fn monitor_failed_no_reestablish_response() {
1221
1241
// response to a commitment_signed.
1222
1242
// Backported from chanmon_fail_consistency fuzz tests as it caught a long-standing
1223
1243
// 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) ;
1225
1247
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
1226
1248
1227
1249
// Route the payment and deliver the initial commitment_signed (with a monitor update failure
@@ -1287,7 +1309,9 @@ fn first_message_on_recv_ordering() {
1287
1309
// have no pending response but will want to send a RAA/CS (with the updates for the second
1288
1310
// payment applied).
1289
1311
// 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) ;
1291
1315
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
1292
1316
1293
1317
// 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() {
1372
1396
// update to claim the payment. We then send a payment C->B->A, making the forward of this
1373
1397
// payment from B to A fail due to the paused channel. Finally, we restore the channel monitor
1374
1398
// 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) ;
1376
1402
let chan_1 = create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
1377
1403
create_announced_chan_between_nodes ( & nodes, 1 , 2 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
1378
1404
@@ -1445,7 +1471,9 @@ fn test_monitor_update_on_pending_forwards() {
1445
1471
// We do this with a simple 3-node network, sending a payment from A to C and one from C to A.
1446
1472
// The payment from A to C will be failed by C and pending a back-fail to A, while the payment
1447
1473
// 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) ;
1449
1477
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
1450
1478
create_announced_chan_between_nodes ( & nodes, 1 , 2 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
1451
1479
@@ -1510,7 +1538,9 @@ fn monitor_update_claim_fail_no_response() {
1510
1538
// to channel being AwaitingRAA).
1511
1539
// Backported from chanmon_fail_consistency fuzz tests as an unmerged version of the handling
1512
1540
// 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) ;
1514
1544
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
1515
1545
1516
1546
// Forward a payment for B to claim
@@ -1569,7 +1599,9 @@ fn monitor_update_claim_fail_no_response() {
1569
1599
fn 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 ) {
1570
1600
// Test that if the monitor update generated by funding_transaction_generated fails we continue
1571
1601
// 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) ;
1573
1605
1574
1606
nodes[ 0 ] . node . create_channel ( nodes[ 1 ] . node . get_our_node_id ( ) , 100000 , 10001 , 43 ) . unwrap ( ) ;
1575
1607
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