@@ -89,7 +89,7 @@ fn test_monitor_and_persister_update_fail() {
89
89
send_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , 10_000_000 ) ;
90
90
91
91
// Route an HTLC from node 0 to node 1 (but don't settle)
92
- let preimage = route_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ .. ] , 9_000_000 ) . 0 ;
92
+ let ( preimage, payment_hash , _ ) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 9_000_000 ) ;
93
93
94
94
// Make a copy of the ChainMonitor so we can capture the error it returns on a
95
95
// bogus update. Note that if instead we updated the nodes[0]'s ChainMonitor
@@ -123,8 +123,10 @@ fn test_monitor_and_persister_update_fail() {
123
123
persister. set_update_ret ( Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ) ;
124
124
125
125
// Try to update ChannelMonitor
126
- assert ! ( nodes[ 1 ] . node. claim_funds( preimage) ) ;
126
+ nodes[ 1 ] . node . claim_funds ( preimage) ;
127
+ expect_payment_claimed ! ( nodes[ 1 ] , payment_hash, 9_000_000 ) ;
127
128
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
129
+
128
130
let updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
129
131
assert_eq ! ( updates. update_fulfill_htlcs. len( ) , 1 ) ;
130
132
nodes[ 0 ] . node . handle_update_fulfill_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fulfill_htlcs [ 0 ] ) ;
@@ -267,7 +269,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
267
269
let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
268
270
let channel_id = create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) . 2 ;
269
271
270
- let ( payment_preimage_1, payment_hash_1, _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
272
+ let ( payment_preimage_1, payment_hash_1, _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1_000_000 ) ;
271
273
272
274
// Now try to send a second payment which will fail to send
273
275
let ( route, payment_hash_2, payment_preimage_2, payment_secret_2) = get_route_and_payment_hash ! ( nodes[ 0 ] , nodes[ 1 ] , 1000000 ) ;
@@ -283,8 +285,10 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
283
285
284
286
// Claim the previous payment, which will result in a update_fulfill_htlc/CS from nodes[1]
285
287
// but nodes[0] won't respond since it is frozen.
286
- assert ! ( nodes[ 1 ] . node. claim_funds( payment_preimage_1) ) ;
288
+ nodes[ 1 ] . node . claim_funds ( payment_preimage_1) ;
287
289
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
290
+ expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
291
+
288
292
let events_2 = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
289
293
assert_eq ! ( events_2. len( ) , 1 ) ;
290
294
let ( bs_initial_fulfill, bs_initial_commitment_signed) = match events_2[ 0 ] {
@@ -1088,13 +1092,15 @@ fn test_monitor_update_fail_reestablish() {
1088
1092
let chan_1 = create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) ;
1089
1093
create_announced_chan_between_nodes ( & nodes, 1 , 2 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) ;
1090
1094
1091
- let ( payment_preimage, _ , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , 1000000 ) ;
1095
+ let ( payment_preimage, payment_hash , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , 1_000_000 ) ;
1092
1096
1093
1097
nodes[ 1 ] . node . peer_disconnected ( & nodes[ 0 ] . node . get_our_node_id ( ) , false ) ;
1094
1098
nodes[ 0 ] . node . peer_disconnected ( & nodes[ 1 ] . node . get_our_node_id ( ) , false ) ;
1095
1099
1096
- assert ! ( nodes[ 2 ] . node. claim_funds( payment_preimage) ) ;
1100
+ nodes[ 2 ] . node . claim_funds ( payment_preimage) ;
1097
1101
check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
1102
+ expect_payment_claimed ! ( nodes[ 2 ] , payment_hash, 1_000_000 ) ;
1103
+
1098
1104
let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
1099
1105
assert ! ( updates. update_add_htlcs. is_empty( ) ) ;
1100
1106
assert ! ( updates. update_fail_htlcs. is_empty( ) ) ;
@@ -1292,13 +1298,14 @@ fn claim_while_disconnected_monitor_update_fail() {
1292
1298
let channel_id = create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) . 2 ;
1293
1299
1294
1300
// Forward a payment for B to claim
1295
- let ( payment_preimage_1, _ , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
1301
+ let ( payment_preimage_1, payment_hash_1 , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1_000_000 ) ;
1296
1302
1297
1303
nodes[ 0 ] . node . peer_disconnected ( & nodes[ 1 ] . node . get_our_node_id ( ) , false ) ;
1298
1304
nodes[ 1 ] . node . peer_disconnected ( & nodes[ 0 ] . node . get_our_node_id ( ) , false ) ;
1299
1305
1300
- assert ! ( nodes[ 1 ] . node. claim_funds( payment_preimage_1) ) ;
1306
+ nodes[ 1 ] . node . claim_funds ( payment_preimage_1) ;
1301
1307
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1308
+ expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
1302
1309
1303
1310
nodes[ 0 ] . node . peer_connected ( & nodes[ 1 ] . node . get_our_node_id ( ) , & msgs:: Init { features : InitFeatures :: empty ( ) , remote_network_address : None } ) ;
1304
1311
nodes[ 1 ] . node . peer_connected ( & nodes[ 0 ] . node . get_our_node_id ( ) , & msgs:: Init { features : InitFeatures :: empty ( ) , remote_network_address : None } ) ;
@@ -1578,10 +1585,11 @@ fn test_monitor_update_fail_claim() {
1578
1585
// Rebalance a bit so that we can send backwards from 3 to 2.
1579
1586
send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , 5000000 ) ;
1580
1587
1581
- let ( payment_preimage_1, _ , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
1588
+ let ( payment_preimage_1, payment_hash_1 , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1_000_000 ) ;
1582
1589
1583
1590
chanmon_cfgs[ 1 ] . persister . set_update_ret ( Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ) ;
1584
- assert ! ( nodes[ 1 ] . node. claim_funds( payment_preimage_1) ) ;
1591
+ nodes[ 1 ] . node . claim_funds ( payment_preimage_1) ;
1592
+ expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
1585
1593
nodes[ 1 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Temporary failure claiming HTLC, treating as success: Failed to update ChannelMonitor" . to_string ( ) , 1 ) ;
1586
1594
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1587
1595
@@ -1754,7 +1762,7 @@ fn monitor_update_claim_fail_no_response() {
1754
1762
let channel_id = create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) . 2 ;
1755
1763
1756
1764
// Forward a payment for B to claim
1757
- let ( payment_preimage_1, _ , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
1765
+ let ( payment_preimage_1, payment_hash_1 , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1_000_000 ) ;
1758
1766
1759
1767
// Now start forwarding a second payment, skipping the last RAA so B is in AwaitingRAA
1760
1768
let ( route, payment_hash_2, payment_preimage_2, payment_secret_2) = get_route_and_payment_hash ! ( nodes[ 0 ] , nodes[ 1 ] , 1000000 ) ;
@@ -1770,8 +1778,10 @@ fn monitor_update_claim_fail_no_response() {
1770
1778
let as_raa = commitment_signed_dance ! ( nodes[ 1 ] , nodes[ 0 ] , payment_event. commitment_msg, false , true , false , true ) ;
1771
1779
1772
1780
chanmon_cfgs[ 1 ] . persister . set_update_ret ( Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ) ;
1773
- assert ! ( nodes[ 1 ] . node. claim_funds( payment_preimage_1) ) ;
1781
+ nodes[ 1 ] . node . claim_funds ( payment_preimage_1) ;
1782
+ expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
1774
1783
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1784
+
1775
1785
let events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
1776
1786
assert_eq ! ( events. len( ) , 0 ) ;
1777
1787
nodes[ 1 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Temporary failure claiming HTLC, treating as success: Failed to update ChannelMonitor" . to_string ( ) , 1 ) ;
@@ -2076,13 +2086,15 @@ fn test_fail_htlc_on_broadcast_after_claim() {
2076
2086
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) ;
2077
2087
let chan_id_2 = create_announced_chan_between_nodes ( & nodes, 1 , 2 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) . 2 ;
2078
2088
2079
- let payment_preimage = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , 2000 ) . 0 ;
2089
+ let ( payment_preimage, payment_hash , _ ) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , 2000 ) ;
2080
2090
2081
2091
let bs_txn = get_local_commitment_txn ! ( nodes[ 2 ] , chan_id_2) ;
2082
2092
assert_eq ! ( bs_txn. len( ) , 1 ) ;
2083
2093
2084
2094
nodes[ 2 ] . node . claim_funds ( payment_preimage) ;
2085
2095
check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
2096
+ expect_payment_claimed ! ( nodes[ 2 ] , payment_hash, 2000 ) ;
2097
+
2086
2098
let cs_updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
2087
2099
nodes[ 1 ] . node . handle_update_fulfill_htlc ( & nodes[ 2 ] . node . get_our_node_id ( ) , & cs_updates. update_fulfill_htlcs [ 0 ] ) ;
2088
2100
let bs_updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
@@ -2235,7 +2247,7 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
2235
2247
//
2236
2248
// Note that because, at the end, MonitorUpdateFailed is still set, the HTLC generated in (c)
2237
2249
// will not be freed from the holding cell.
2238
- let ( payment_preimage_0, _ , _) = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 100000 ) ;
2250
+ let ( payment_preimage_0, payment_hash_0 , _) = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 100_000 ) ;
2239
2251
2240
2252
nodes[ 0 ] . node . send_payment ( & route, payment_hash_1, & Some ( payment_secret_1) ) . unwrap ( ) ;
2241
2253
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
@@ -2246,8 +2258,9 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
2246
2258
check_added_monitors ! ( nodes[ 0 ] , 0 ) ;
2247
2259
2248
2260
chanmon_cfgs[ 0 ] . persister . set_update_ret ( Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ) ;
2249
- assert ! ( nodes[ 0 ] . node. claim_funds( payment_preimage_0) ) ;
2261
+ nodes[ 0 ] . node . claim_funds ( payment_preimage_0) ;
2250
2262
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
2263
+ expect_payment_claimed ! ( nodes[ 0 ] , payment_hash_0, 100_000 ) ;
2251
2264
2252
2265
nodes[ 1 ] . node . handle_update_add_htlc ( & nodes[ 0 ] . node . get_our_node_id ( ) , & send. msgs [ 0 ] ) ;
2253
2266
nodes[ 1 ] . node . handle_commitment_signed ( & nodes[ 0 ] . node . get_our_node_id ( ) , & send. commitment_msg ) ;
@@ -2460,8 +2473,10 @@ fn do_test_reconnect_dup_htlc_claims(htlc_status: HTLCStatusAtDupClaim, second_f
2460
2473
check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
2461
2474
get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
2462
2475
} else {
2463
- assert ! ( nodes[ 2 ] . node. claim_funds( payment_preimage) ) ;
2476
+ nodes[ 2 ] . node . claim_funds ( payment_preimage) ;
2464
2477
check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
2478
+ expect_payment_claimed ! ( nodes[ 2 ] , payment_hash, 100_000 ) ;
2479
+
2465
2480
let cs_updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
2466
2481
assert_eq ! ( cs_updates. update_fulfill_htlcs. len( ) , 1 ) ;
2467
2482
// Check that the message we're about to deliver matches the one generated:
@@ -2630,20 +2645,22 @@ fn double_temp_error() {
2630
2645
2631
2646
let ( _, _, channel_id, _) = create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) ;
2632
2647
2633
- let ( payment_preimage_1, _ , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
2634
- let ( payment_preimage_2, _ , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
2648
+ let ( payment_preimage_1, payment_hash_1 , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1_000_000 ) ;
2649
+ let ( payment_preimage_2, payment_hash_2 , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1_000_000 ) ;
2635
2650
2636
2651
chanmon_cfgs[ 1 ] . persister . set_update_ret ( Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ) ;
2637
2652
// `claim_funds` results in a ChannelMonitorUpdate.
2638
- assert ! ( nodes[ 1 ] . node. claim_funds( payment_preimage_1) ) ;
2653
+ nodes[ 1 ] . node . claim_funds ( payment_preimage_1) ;
2639
2654
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
2655
+ expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
2640
2656
let ( funding_tx, latest_update_1, _) = nodes[ 1 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
2641
2657
2642
2658
chanmon_cfgs[ 1 ] . persister . set_update_ret ( Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ) ;
2643
2659
// Previously, this would've panicked due to a double-call to `Channel::monitor_update_failed`,
2644
2660
// which had some asserts that prevented it from being called twice.
2645
- assert ! ( nodes[ 1 ] . node. claim_funds( payment_preimage_2) ) ;
2661
+ nodes[ 1 ] . node . claim_funds ( payment_preimage_2) ;
2646
2662
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
2663
+ expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_2, 1_000_000 ) ;
2647
2664
chanmon_cfgs[ 1 ] . persister . set_update_ret ( Ok ( ( ) ) ) ;
2648
2665
2649
2666
let ( _, latest_update_2, _) = nodes[ 1 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
0 commit comments