@@ -1602,7 +1602,6 @@ fn test_monitor_update_fail_claim() {
1602
1602
1603
1603
chanmon_cfgs[ 1 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: InProgress ) ;
1604
1604
nodes[ 1 ] . node . claim_funds ( payment_preimage_1) ;
1605
- expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
1606
1605
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1607
1606
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1608
1607
@@ -1628,6 +1627,7 @@ fn test_monitor_update_fail_claim() {
1628
1627
let events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
1629
1628
assert_eq ! ( events. len( ) , 0 ) ;
1630
1629
commitment_signed_dance ! ( nodes[ 1 ] , nodes[ 2 ] , payment_event. commitment_msg, false , true ) ;
1630
+ expect_pending_htlcs_forwardable_ignore ! ( nodes[ 1 ] ) ;
1631
1631
1632
1632
let ( _, payment_hash_3, payment_secret_3) = get_payment_preimage_hash ! ( nodes[ 0 ] ) ;
1633
1633
nodes[ 2 ] . node . send_payment ( & route, payment_hash_3, & Some ( payment_secret_3) , PaymentId ( payment_hash_3. 0 ) ) . unwrap ( ) ;
@@ -1645,6 +1645,7 @@ fn test_monitor_update_fail_claim() {
1645
1645
let channel_id = chan_1. 2 ;
1646
1646
let ( outpoint, latest_update, _) = nodes[ 1 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
1647
1647
nodes[ 1 ] . chain_monitor . chain_monitor . force_channel_monitor_updated ( outpoint, latest_update) ;
1648
+ expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
1648
1649
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
1649
1650
1650
1651
let bs_fulfill_update = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
@@ -1653,7 +1654,7 @@ fn test_monitor_update_fail_claim() {
1653
1654
expect_payment_sent ! ( nodes[ 0 ] , payment_preimage_1) ;
1654
1655
1655
1656
// Get the payment forwards, note that they were batched into one commitment update.
1656
- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
1657
+ nodes[ 1 ] . node . process_pending_htlc_forwards ( ) ;
1657
1658
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1658
1659
let bs_forward_update = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
1659
1660
nodes[ 0 ] . node . handle_update_add_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_forward_update. update_add_htlcs [ 0 ] ) ;
@@ -1796,14 +1797,14 @@ fn monitor_update_claim_fail_no_response() {
1796
1797
1797
1798
chanmon_cfgs[ 1 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: InProgress ) ;
1798
1799
nodes[ 1 ] . node . claim_funds ( payment_preimage_1) ;
1799
- expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
1800
1800
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1801
1801
1802
1802
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1803
1803
1804
1804
chanmon_cfgs[ 1 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: Completed ) ;
1805
1805
let ( outpoint, latest_update, _) = nodes[ 1 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
1806
1806
nodes[ 1 ] . chain_monitor . chain_monitor . force_channel_monitor_updated ( outpoint, latest_update) ;
1807
+ expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
1807
1808
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
1808
1809
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1809
1810
@@ -2283,7 +2284,6 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
2283
2284
chanmon_cfgs[ 0 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: InProgress ) ;
2284
2285
nodes[ 0 ] . node . claim_funds ( payment_preimage_0) ;
2285
2286
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
2286
- expect_payment_claimed ! ( nodes[ 0 ] , payment_hash_0, 100_000 ) ;
2287
2287
2288
2288
nodes[ 1 ] . node . handle_update_add_htlc ( & nodes[ 0 ] . node . get_our_node_id ( ) , & send. msgs [ 0 ] ) ;
2289
2289
nodes[ 1 ] . node . handle_commitment_signed ( & nodes[ 0 ] . node . get_our_node_id ( ) , & send. commitment_msg ) ;
@@ -2346,6 +2346,7 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
2346
2346
chanmon_cfgs[ 0 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: Completed ) ;
2347
2347
let ( funding_txo, mon_id, _) = nodes[ 0 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & chan_id) . unwrap ( ) . clone ( ) ;
2348
2348
nodes[ 0 ] . chain_monitor . chain_monitor . force_channel_monitor_updated ( funding_txo, mon_id) ;
2349
+ expect_payment_claimed ! ( nodes[ 0 ] , payment_hash_0, 100_000 ) ;
2349
2350
2350
2351
// New outbound messages should be generated immediately upon a call to
2351
2352
// get_and_clear_pending_msg_events (but not before).
@@ -2644,15 +2645,13 @@ fn double_temp_error() {
2644
2645
// `claim_funds` results in a ChannelMonitorUpdate.
2645
2646
nodes[ 1 ] . node . claim_funds ( payment_preimage_1) ;
2646
2647
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
2647
- expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
2648
2648
let ( funding_tx, latest_update_1, _) = nodes[ 1 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
2649
2649
2650
2650
chanmon_cfgs[ 1 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: InProgress ) ;
2651
2651
// Previously, this would've panicked due to a double-call to `Channel::monitor_update_failed`,
2652
2652
// which had some asserts that prevented it from being called twice.
2653
2653
nodes[ 1 ] . node . claim_funds ( payment_preimage_2) ;
2654
2654
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
2655
- expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_2, 1_000_000 ) ;
2656
2655
chanmon_cfgs[ 1 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: Completed ) ;
2657
2656
2658
2657
let ( _, latest_update_2, _) = nodes[ 1 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
@@ -2661,11 +2660,24 @@ fn double_temp_error() {
2661
2660
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
2662
2661
nodes[ 1 ] . chain_monitor . chain_monitor . force_channel_monitor_updated ( funding_tx, latest_update_2) ;
2663
2662
2664
- // Complete the first HTLC.
2665
- let events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
2666
- assert_eq ! ( events. len( ) , 1 ) ;
2663
+ // Complete the first HTLC. Note that as a side-effect we handle the monitor update completions
2664
+ // and get both PaymentClaimed events at once.
2665
+ let msg_events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
2666
+
2667
+ let events = nodes[ 1 ] . node . get_and_clear_pending_events ( ) ;
2668
+ assert_eq ! ( events. len( ) , 2 ) ;
2669
+ match events[ 0 ] {
2670
+ Event :: PaymentClaimed { amount_msat : 1_000_000 , payment_hash, .. } => assert_eq ! ( payment_hash, payment_hash_1) ,
2671
+ _ => panic ! ( "Unexpected Event: {:?}" , events[ 0 ] ) ,
2672
+ }
2673
+ match events[ 1 ] {
2674
+ Event :: PaymentClaimed { amount_msat : 1_000_000 , payment_hash, .. } => assert_eq ! ( payment_hash, payment_hash_2) ,
2675
+ _ => panic ! ( "Unexpected Event: {:?}" , events[ 1 ] ) ,
2676
+ }
2677
+
2678
+ assert_eq ! ( msg_events. len( ) , 1 ) ;
2667
2679
let ( update_fulfill_1, commitment_signed_b1, node_id) = {
2668
- match & events [ 0 ] {
2680
+ match & msg_events [ 0 ] {
2669
2681
& MessageSendEvent :: UpdateHTLCs { ref node_id, updates : msgs:: CommitmentUpdate { ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs, ref update_fail_malformed_htlcs, ref update_fee, ref commitment_signed } } => {
2670
2682
assert ! ( update_add_htlcs. is_empty( ) ) ;
2671
2683
assert_eq ! ( update_fulfill_htlcs. len( ) , 1 ) ;
0 commit comments