@@ -1590,7 +1590,6 @@ fn test_monitor_update_fail_claim() {
1590
1590
1591
1591
chanmon_cfgs[ 1 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: InProgress ) ;
1592
1592
nodes[ 1 ] . node . claim_funds ( payment_preimage_1) ;
1593
- expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
1594
1593
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1595
1594
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1596
1595
@@ -1616,6 +1615,7 @@ fn test_monitor_update_fail_claim() {
1616
1615
let events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
1617
1616
assert_eq ! ( events. len( ) , 0 ) ;
1618
1617
commitment_signed_dance ! ( nodes[ 1 ] , nodes[ 2 ] , payment_event. commitment_msg, false , true ) ;
1618
+ expect_pending_htlcs_forwardable_ignore ! ( nodes[ 1 ] ) ;
1619
1619
1620
1620
let ( _, payment_hash_3, payment_secret_3) = get_payment_preimage_hash ! ( nodes[ 0 ] ) ;
1621
1621
nodes[ 2 ] . node . send_payment ( & route, payment_hash_3, & Some ( payment_secret_3) , PaymentId ( payment_hash_3. 0 ) ) . unwrap ( ) ;
@@ -1633,6 +1633,7 @@ fn test_monitor_update_fail_claim() {
1633
1633
let channel_id = chan_1. 2 ;
1634
1634
let ( outpoint, latest_update, _) = nodes[ 1 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
1635
1635
nodes[ 1 ] . chain_monitor . chain_monitor . force_channel_monitor_updated ( outpoint, latest_update) ;
1636
+ expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
1636
1637
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
1637
1638
1638
1639
let bs_fulfill_update = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
@@ -1641,7 +1642,7 @@ fn test_monitor_update_fail_claim() {
1641
1642
expect_payment_sent ! ( nodes[ 0 ] , payment_preimage_1) ;
1642
1643
1643
1644
// Get the payment forwards, note that they were batched into one commitment update.
1644
- expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
1645
+ nodes[ 1 ] . node . process_pending_htlc_forwards ( ) ;
1645
1646
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1646
1647
let bs_forward_update = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
1647
1648
nodes[ 0 ] . node . handle_update_add_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_forward_update. update_add_htlcs [ 0 ] ) ;
@@ -1784,14 +1785,14 @@ fn monitor_update_claim_fail_no_response() {
1784
1785
1785
1786
chanmon_cfgs[ 1 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: InProgress ) ;
1786
1787
nodes[ 1 ] . node . claim_funds ( payment_preimage_1) ;
1787
- expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
1788
1788
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1789
1789
1790
1790
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1791
1791
1792
1792
chanmon_cfgs[ 1 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: Completed ) ;
1793
1793
let ( outpoint, latest_update, _) = nodes[ 1 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
1794
1794
nodes[ 1 ] . chain_monitor . chain_monitor . force_channel_monitor_updated ( outpoint, latest_update) ;
1795
+ expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
1795
1796
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
1796
1797
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1797
1798
@@ -2270,7 +2271,6 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
2270
2271
chanmon_cfgs[ 0 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: InProgress ) ;
2271
2272
nodes[ 0 ] . node . claim_funds ( payment_preimage_0) ;
2272
2273
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
2273
- expect_payment_claimed ! ( nodes[ 0 ] , payment_hash_0, 100_000 ) ;
2274
2274
2275
2275
nodes[ 1 ] . node . handle_update_add_htlc ( & nodes[ 0 ] . node . get_our_node_id ( ) , & send. msgs [ 0 ] ) ;
2276
2276
nodes[ 1 ] . node . handle_commitment_signed ( & nodes[ 0 ] . node . get_our_node_id ( ) , & send. commitment_msg ) ;
@@ -2333,6 +2333,7 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
2333
2333
chanmon_cfgs[ 0 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: Completed ) ;
2334
2334
let ( funding_txo, mon_id, _) = nodes[ 0 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & chan_id) . unwrap ( ) . clone ( ) ;
2335
2335
nodes[ 0 ] . chain_monitor . chain_monitor . force_channel_monitor_updated ( funding_txo, mon_id) ;
2336
+ expect_payment_claimed ! ( nodes[ 0 ] , payment_hash_0, 100_000 ) ;
2336
2337
2337
2338
// New outbound messages should be generated immediately upon a call to
2338
2339
// get_and_clear_pending_msg_events (but not before).
@@ -2631,15 +2632,13 @@ fn double_temp_error() {
2631
2632
// `claim_funds` results in a ChannelMonitorUpdate.
2632
2633
nodes[ 1 ] . node . claim_funds ( payment_preimage_1) ;
2633
2634
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
2634
- expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_1, 1_000_000 ) ;
2635
2635
let ( funding_tx, latest_update_1, _) = nodes[ 1 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
2636
2636
2637
2637
chanmon_cfgs[ 1 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: InProgress ) ;
2638
2638
// Previously, this would've panicked due to a double-call to `Channel::monitor_update_failed`,
2639
2639
// which had some asserts that prevented it from being called twice.
2640
2640
nodes[ 1 ] . node . claim_funds ( payment_preimage_2) ;
2641
2641
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
2642
- expect_payment_claimed ! ( nodes[ 1 ] , payment_hash_2, 1_000_000 ) ;
2643
2642
chanmon_cfgs[ 1 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: Completed ) ;
2644
2643
2645
2644
let ( _, latest_update_2, _) = nodes[ 1 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
@@ -2648,11 +2647,24 @@ fn double_temp_error() {
2648
2647
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
2649
2648
nodes[ 1 ] . chain_monitor . chain_monitor . force_channel_monitor_updated ( funding_tx, latest_update_2) ;
2650
2649
2651
- // Complete the first HTLC.
2652
- let events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
2653
- assert_eq ! ( events. len( ) , 1 ) ;
2650
+ // Complete the first HTLC. Note that as a side-effect we handle the monitor update completions
2651
+ // and get both PaymentClaimed events at once.
2652
+ let msg_events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
2653
+
2654
+ let events = nodes[ 1 ] . node . get_and_clear_pending_events ( ) ;
2655
+ assert_eq ! ( events. len( ) , 2 ) ;
2656
+ match events[ 0 ] {
2657
+ Event :: PaymentClaimed { amount_msat : 1_000_000 , payment_hash, .. } => assert_eq ! ( payment_hash, payment_hash_1) ,
2658
+ _ => panic ! ( "Unexpected Event: {:?}" , events[ 0 ] ) ,
2659
+ }
2660
+ match events[ 1 ] {
2661
+ Event :: PaymentClaimed { amount_msat : 1_000_000 , payment_hash, .. } => assert_eq ! ( payment_hash, payment_hash_2) ,
2662
+ _ => panic ! ( "Unexpected Event: {:?}" , events[ 1 ] ) ,
2663
+ }
2664
+
2665
+ assert_eq ! ( msg_events. len( ) , 1 ) ;
2654
2666
let ( update_fulfill_1, commitment_signed_b1, node_id) = {
2655
- match & events [ 0 ] {
2667
+ match & msg_events [ 0 ] {
2656
2668
& 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 } } => {
2657
2669
assert ! ( update_add_htlcs. is_empty( ) ) ;
2658
2670
assert_eq ! ( update_fulfill_htlcs. len( ) , 1 ) ;
0 commit comments