@@ -905,8 +905,8 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
905
905
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
906
906
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
907
907
908
- // Attempt to forward a third payment but fail due to the second channel being unavailable
909
- // for forwarding .
908
+ // Forward a third payment which will also be added to the holding cell, despite the channel
909
+ // being paused waiting a monitor update .
910
910
let ( _, payment_hash_3, payment_secret_3) = get_payment_preimage_hash ! ( nodes[ 2 ] ) ;
911
911
{
912
912
let net_graph_msg_handler = & nodes[ 0 ] . net_graph_msg_handler ;
@@ -921,39 +921,11 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
921
921
commitment_signed_dance ! ( nodes[ 1 ] , nodes[ 0 ] , send_event. commitment_msg, false , true ) ;
922
922
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
923
923
924
- let mut events_2 = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
925
- assert_eq ! ( events_2. len( ) , 1 ) ;
926
- match events_2. remove ( 0 ) {
927
- MessageSendEvent :: UpdateHTLCs { node_id, updates } => {
928
- assert_eq ! ( node_id, nodes[ 0 ] . node. get_our_node_id( ) ) ;
929
- assert ! ( updates. update_fulfill_htlcs. is_empty( ) ) ;
930
- assert_eq ! ( updates. update_fail_htlcs. len( ) , 1 ) ;
931
- assert ! ( updates. update_fail_malformed_htlcs. is_empty( ) ) ;
932
- assert ! ( updates. update_add_htlcs. is_empty( ) ) ;
933
- assert ! ( updates. update_fee. is_none( ) ) ;
934
-
935
- nodes[ 0 ] . node . handle_update_fail_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
936
- commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , updates. commitment_signed, false , true ) ;
937
-
938
- let msg_events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
939
- assert_eq ! ( msg_events. len( ) , 1 ) ;
940
- match msg_events[ 0 ] {
941
- MessageSendEvent :: PaymentFailureNetworkUpdate { update : msgs:: HTLCFailChannelUpdate :: ChannelUpdateMessage { ref msg } } => {
942
- assert_eq ! ( msg. contents. short_channel_id, chan_2. 0 . contents. short_channel_id) ;
943
- assert_eq ! ( msg. contents. flags & 2 , 2 ) ; // temp disabled
944
- } ,
945
- _ => panic ! ( "Unexpected event" ) ,
946
- }
947
-
948
- let events = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
949
- assert_eq ! ( events. len( ) , 1 ) ;
950
- if let Event :: PaymentFailed { payment_hash, rejected_by_dest, .. } = events[ 0 ] {
951
- assert_eq ! ( payment_hash, payment_hash_3) ;
952
- assert ! ( !rejected_by_dest) ;
953
- } else { panic ! ( "Unexpected event!" ) ; }
954
- } ,
955
- _ => panic ! ( "Unexpected event type!" ) ,
956
- } ;
924
+ // Call forward_pending_htlcs and check that the new HTLC was simply added to the holding cell
925
+ // and not forwarded.
926
+ expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
927
+ check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
928
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
957
929
958
930
let ( payment_preimage_4, payment_hash_4) = if test_ignore_second_cs {
959
931
// Try to route another payment backwards from 2 to make sure 1 holds off on responding
@@ -970,7 +942,6 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
970
942
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
971
943
nodes[ 1 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Previous monitor update failure prevented generation of RAA" . to_string ( ) , 1 ) ;
972
944
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
973
- assert ! ( nodes[ 1 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
974
945
( Some ( payment_preimage_4) , Some ( payment_hash_4) )
975
946
} else { ( None , None ) } ;
976
947
@@ -1020,14 +991,10 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
1020
991
1021
992
nodes[ 0 ] . node . handle_update_fail_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & messages_a. 0 ) ;
1022
993
commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , messages_a. 1 , false ) ;
1023
- let events_4 = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
1024
- assert_eq ! ( events_4. len( ) , 1 ) ;
1025
- if let Event :: PaymentFailed { payment_hash, rejected_by_dest, .. } = events_4[ 0 ] {
1026
- assert_eq ! ( payment_hash, payment_hash_1) ;
1027
- assert ! ( rejected_by_dest) ;
1028
- } else { panic ! ( "Unexpected event!" ) ; }
994
+ expect_payment_failed ! ( nodes[ 0 ] , payment_hash_1, true ) ;
1029
995
1030
996
nodes[ 2 ] . node . handle_update_add_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & send_event_b. msgs [ 0 ] ) ;
997
+ let as_cs;
1031
998
if test_ignore_second_cs {
1032
999
nodes[ 2 ] . node . handle_commitment_signed ( & nodes[ 1 ] . node . get_our_node_id ( ) , & send_event_b. commitment_msg ) ;
1033
1000
check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
@@ -1043,40 +1010,83 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
1043
1010
1044
1011
nodes[ 1 ] . node . handle_revoke_and_ack ( & nodes[ 2 ] . node . get_our_node_id ( ) , & bs_revoke_and_ack) ;
1045
1012
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1046
- let as_cs = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 2 ] . node. get_our_node_id( ) ) ;
1047
- assert ! ( as_cs. update_add_htlcs. is_empty( ) ) ;
1048
- assert ! ( as_cs. update_fail_htlcs. is_empty( ) ) ;
1049
- assert ! ( as_cs. update_fail_malformed_htlcs. is_empty( ) ) ;
1050
- assert ! ( as_cs. update_fulfill_htlcs. is_empty( ) ) ;
1051
- assert ! ( as_cs. update_fee. is_none( ) ) ;
1013
+ as_cs = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 2 ] . node. get_our_node_id( ) ) ;
1052
1014
1053
1015
nodes[ 1 ] . node . handle_commitment_signed ( & nodes[ 2 ] . node . get_our_node_id ( ) , & bs_cs. commitment_signed ) ;
1054
1016
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1055
- let as_raa = get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendRevokeAndACK , nodes[ 2 ] . node. get_our_node_id( ) ) ;
1056
-
1057
- nodes[ 2 ] . node . handle_commitment_signed ( & nodes[ 1 ] . node . get_our_node_id ( ) , & as_cs. commitment_signed ) ;
1017
+ } else {
1018
+ nodes[ 2 ] . node . handle_commitment_signed ( & nodes[ 1 ] . node . get_our_node_id ( ) , & send_event_b. commitment_msg ) ;
1058
1019
check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
1059
- let bs_second_raa = get_event_msg ! ( nodes[ 2 ] , MessageSendEvent :: SendRevokeAndACK , nodes[ 1 ] . node. get_our_node_id( ) ) ;
1060
1020
1061
- nodes[ 2 ] . node . handle_revoke_and_ack ( & nodes[ 1 ] . node . get_our_node_id ( ) , & as_raa) ;
1062
- check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
1063
- assert ! ( nodes[ 2 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1021
+ let bs_revoke_and_commit = nodes[ 2 ] . node . get_and_clear_pending_msg_events ( ) ;
1022
+ assert_eq ! ( bs_revoke_and_commit. len( ) , 2 ) ;
1023
+ match bs_revoke_and_commit[ 0 ] {
1024
+ MessageSendEvent :: SendRevokeAndACK { ref node_id, ref msg } => {
1025
+ assert_eq ! ( * node_id, nodes[ 1 ] . node. get_our_node_id( ) ) ;
1026
+ nodes[ 1 ] . node . handle_revoke_and_ack ( & nodes[ 2 ] . node . get_our_node_id ( ) , & msg) ;
1027
+ check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1028
+ } ,
1029
+ _ => panic ! ( "Unexpected event" ) ,
1030
+ }
1064
1031
1065
- nodes[ 1 ] . node . handle_revoke_and_ack ( & nodes[ 2 ] . node . get_our_node_id ( ) , & bs_second_raa) ;
1066
- check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1067
- assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1068
- } else {
1069
- commitment_signed_dance ! ( nodes[ 2 ] , nodes[ 1 ] , send_event_b. commitment_msg, false ) ;
1032
+ as_cs = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 2 ] . node. get_our_node_id( ) ) ;
1033
+
1034
+ match bs_revoke_and_commit[ 1 ] {
1035
+ MessageSendEvent :: UpdateHTLCs { ref node_id, ref updates } => {
1036
+ assert_eq ! ( * node_id, nodes[ 1 ] . node. get_our_node_id( ) ) ;
1037
+ assert ! ( updates. update_add_htlcs. is_empty( ) ) ;
1038
+ assert ! ( updates. update_fail_htlcs. is_empty( ) ) ;
1039
+ assert ! ( updates. update_fail_malformed_htlcs. is_empty( ) ) ;
1040
+ assert ! ( updates. update_fulfill_htlcs. is_empty( ) ) ;
1041
+ assert ! ( updates. update_fee. is_none( ) ) ;
1042
+ nodes[ 1 ] . node . handle_commitment_signed ( & nodes[ 2 ] . node . get_our_node_id ( ) , & updates. commitment_signed ) ;
1043
+ check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1044
+ } ,
1045
+ _ => panic ! ( "Unexpected event" ) ,
1046
+ }
1070
1047
}
1071
1048
1049
+ assert_eq ! ( as_cs. update_add_htlcs. len( ) , 1 ) ;
1050
+ assert ! ( as_cs. update_fail_htlcs. is_empty( ) ) ;
1051
+ assert ! ( as_cs. update_fail_malformed_htlcs. is_empty( ) ) ;
1052
+ assert ! ( as_cs. update_fulfill_htlcs. is_empty( ) ) ;
1053
+ assert ! ( as_cs. update_fee. is_none( ) ) ;
1054
+ let as_raa = get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendRevokeAndACK , nodes[ 2 ] . node. get_our_node_id( ) ) ;
1055
+
1056
+
1057
+ nodes[ 2 ] . node . handle_update_add_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & as_cs. update_add_htlcs [ 0 ] ) ;
1058
+ nodes[ 2 ] . node . handle_commitment_signed ( & nodes[ 1 ] . node . get_our_node_id ( ) , & as_cs. commitment_signed ) ;
1059
+ check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
1060
+ let bs_second_raa = get_event_msg ! ( nodes[ 2 ] , MessageSendEvent :: SendRevokeAndACK , nodes[ 1 ] . node. get_our_node_id( ) ) ;
1061
+
1062
+ nodes[ 2 ] . node . handle_revoke_and_ack ( & nodes[ 1 ] . node . get_our_node_id ( ) , & as_raa) ;
1063
+ check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
1064
+ let bs_second_cs = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
1065
+
1066
+ nodes[ 1 ] . node . handle_revoke_and_ack ( & nodes[ 2 ] . node . get_our_node_id ( ) , & bs_second_raa) ;
1067
+ check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1068
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1069
+
1070
+ nodes[ 1 ] . node . handle_commitment_signed ( & nodes[ 2 ] . node . get_our_node_id ( ) , & bs_second_cs. commitment_signed ) ;
1071
+ check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1072
+ let as_second_raa = get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendRevokeAndACK , nodes[ 2 ] . node. get_our_node_id( ) ) ;
1073
+
1074
+ nodes[ 2 ] . node . handle_revoke_and_ack ( & nodes[ 1 ] . node . get_our_node_id ( ) , & as_second_raa) ;
1075
+ check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
1076
+ assert ! ( nodes[ 2 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1077
+
1072
1078
expect_pending_htlcs_forwardable ! ( nodes[ 2 ] ) ;
1073
1079
1074
1080
let events_6 = nodes[ 2 ] . node . get_and_clear_pending_events ( ) ;
1075
- assert_eq ! ( events_6. len( ) , 1 ) ;
1081
+ assert_eq ! ( events_6. len( ) , 2 ) ;
1076
1082
match events_6[ 0 ] {
1077
1083
Event :: PaymentReceived { payment_hash, .. } => { assert_eq ! ( payment_hash, payment_hash_2) ; } ,
1078
1084
_ => panic ! ( "Unexpected event" ) ,
1079
1085
} ;
1086
+ match events_6[ 1 ] {
1087
+ Event :: PaymentReceived { payment_hash, .. } => { assert_eq ! ( payment_hash, payment_hash_3) ; } ,
1088
+ _ => panic ! ( "Unexpected event" ) ,
1089
+ } ;
1080
1090
1081
1091
if test_ignore_second_cs {
1082
1092
expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
@@ -1611,9 +1621,9 @@ fn first_message_on_recv_ordering() {
1611
1621
fn test_monitor_update_fail_claim ( ) {
1612
1622
// Basic test for monitor update failures when processing claim_funds calls.
1613
1623
// We set up a simple 3-node network, sending a payment from A to B and failing B's monitor
1614
- // update to claim the payment. We then send a payment C->B->A, making the forward of this
1615
- // payment from B to A fail due to the paused channel. Finally, we restore the channel monitor
1616
- // updating and claim the payment on B .
1624
+ // update to claim the payment. We then send two payments C->B->A, which are held at B.
1625
+ // Finally, we restore the channel monitor updating and claim the payment on B, forwarding
1626
+ // the payments from C onwards to A .
1617
1627
let chanmon_cfgs = create_chanmon_cfgs ( 3 ) ;
1618
1628
let node_cfgs = create_node_cfgs ( 3 , & chanmon_cfgs) ;
1619
1629
let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
@@ -1629,12 +1639,19 @@ fn test_monitor_update_fail_claim() {
1629
1639
1630
1640
* nodes[ 1 ] . chain_monitor . update_ret . lock ( ) . unwrap ( ) = Some ( Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ) ;
1631
1641
assert ! ( nodes[ 1 ] . node. claim_funds( payment_preimage_1) ) ;
1642
+ nodes[ 1 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Temporary failure claiming HTLC, treating as success: Failed to update ChannelMonitor" . to_string ( ) , 1 ) ;
1632
1643
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1633
1644
1645
+ // Note that at this point there is a pending commitment transaction update for A being held by
1646
+ // B. Even when we go to send the payment from C through B to A, B will not update this
1647
+ // already-signed commitment transaction and will instead wait for it to resolve before
1648
+ // forwarding the payment onwards.
1649
+
1634
1650
let ( _, payment_hash_2, payment_secret_2) = get_payment_preimage_hash ! ( nodes[ 0 ] ) ;
1651
+ let route;
1635
1652
{
1636
1653
let net_graph_msg_handler = & nodes[ 2 ] . net_graph_msg_handler ;
1637
- let route = get_route ( & nodes[ 2 ] . node . get_our_node_id ( ) , & net_graph_msg_handler. network_graph . read ( ) . unwrap ( ) , & nodes[ 0 ] . node . get_our_node_id ( ) , Some ( InvoiceFeatures :: known ( ) ) , None , & Vec :: new ( ) , 1000000 , TEST_FINAL_CLTV , & logger) . unwrap ( ) ;
1654
+ route = get_route ( & nodes[ 2 ] . node . get_our_node_id ( ) , & net_graph_msg_handler. network_graph . read ( ) . unwrap ( ) , & nodes[ 0 ] . node . get_our_node_id ( ) , Some ( InvoiceFeatures :: known ( ) ) , None , & Vec :: new ( ) , 1_000_000 , TEST_FINAL_CLTV , & logger) . unwrap ( ) ;
1638
1655
nodes[ 2 ] . node . send_payment ( & route, payment_hash_2, & Some ( payment_secret_2) ) . unwrap ( ) ;
1639
1656
check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
1640
1657
}
@@ -1649,29 +1666,19 @@ fn test_monitor_update_fail_claim() {
1649
1666
nodes[ 1 ] . node . handle_update_add_htlc ( & nodes[ 2 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
1650
1667
let events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
1651
1668
assert_eq ! ( events. len( ) , 0 ) ;
1652
- nodes[ 1 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Temporary failure claiming HTLC, treating as success: Failed to update ChannelMonitor" . to_string ( ) , 1 ) ;
1653
1669
commitment_signed_dance ! ( nodes[ 1 ] , nodes[ 2 ] , payment_event. commitment_msg, false , true ) ;
1654
1670
1655
- let bs_fail_update = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 2 ] . node. get_our_node_id( ) ) ;
1656
- nodes[ 2 ] . node . handle_update_fail_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_fail_update. update_fail_htlcs [ 0 ] ) ;
1657
- commitment_signed_dance ! ( nodes[ 2 ] , nodes[ 1 ] , bs_fail_update. commitment_signed, false , true ) ;
1658
-
1659
- let msg_events = nodes[ 2 ] . node . get_and_clear_pending_msg_events ( ) ;
1660
- assert_eq ! ( msg_events. len( ) , 1 ) ;
1661
- match msg_events[ 0 ] {
1662
- MessageSendEvent :: PaymentFailureNetworkUpdate { update : msgs:: HTLCFailChannelUpdate :: ChannelUpdateMessage { ref msg } } => {
1663
- assert_eq ! ( msg. contents. short_channel_id, chan_1. 0 . contents. short_channel_id) ;
1664
- assert_eq ! ( msg. contents. flags & 2 , 2 ) ; // temp disabled
1665
- } ,
1666
- _ => panic ! ( "Unexpected event" ) ,
1667
- }
1671
+ let ( _, payment_hash_3, payment_secret_3) = get_payment_preimage_hash ! ( nodes[ 0 ] ) ;
1672
+ nodes[ 2 ] . node . send_payment ( & route, payment_hash_3, & Some ( payment_secret_3) ) . unwrap ( ) ;
1673
+ check_added_monitors ! ( nodes[ 2 ] , 1 ) ;
1668
1674
1669
- let events = nodes[ 2 ] . node . get_and_clear_pending_events ( ) ;
1675
+ let mut events = nodes[ 2 ] . node . get_and_clear_pending_msg_events ( ) ;
1670
1676
assert_eq ! ( events. len( ) , 1 ) ;
1671
- if let Event :: PaymentFailed { payment_hash, rejected_by_dest, .. } = events[ 0 ] {
1672
- assert_eq ! ( payment_hash, payment_hash_2) ;
1673
- assert ! ( !rejected_by_dest) ;
1674
- } else { panic ! ( "Unexpected event!" ) ; }
1677
+ let payment_event = SendEvent :: from_event ( events. pop ( ) . unwrap ( ) ) ;
1678
+ nodes[ 1 ] . node . handle_update_add_htlc ( & nodes[ 2 ] . node . get_our_node_id ( ) , & payment_event. msgs [ 0 ] ) ;
1679
+ let events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
1680
+ assert_eq ! ( events. len( ) , 0 ) ;
1681
+ commitment_signed_dance ! ( nodes[ 1 ] , nodes[ 2 ] , payment_event. commitment_msg, false , true ) ;
1675
1682
1676
1683
// Now restore monitor updating on the 0<->1 channel and claim the funds on B.
1677
1684
let ( outpoint, latest_update) = nodes[ 1 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & chan_1. 2 ) . unwrap ( ) . clone ( ) ;
@@ -1681,12 +1688,37 @@ fn test_monitor_update_fail_claim() {
1681
1688
let bs_fulfill_update = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
1682
1689
nodes[ 0 ] . node . handle_update_fulfill_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_fulfill_update. update_fulfill_htlcs [ 0 ] ) ;
1683
1690
commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , bs_fulfill_update. commitment_signed, false ) ;
1691
+ expect_payment_sent ! ( nodes[ 0 ] , payment_preimage_1) ;
1692
+
1693
+ // Get the payment forwards, note that they were batched into one commitment update.
1694
+ expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
1695
+ check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1696
+ let bs_forward_update = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
1697
+ nodes[ 0 ] . node . handle_update_add_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_forward_update. update_add_htlcs [ 0 ] ) ;
1698
+ nodes[ 0 ] . node . handle_update_add_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_forward_update. update_add_htlcs [ 1 ] ) ;
1699
+ commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , bs_forward_update. commitment_signed, false ) ;
1700
+ expect_pending_htlcs_forwardable ! ( nodes[ 0 ] ) ;
1684
1701
1685
1702
let events = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
1686
- assert_eq ! ( events. len( ) , 1 ) ;
1687
- if let Event :: PaymentSent { payment_preimage, .. } = events[ 0 ] {
1688
- assert_eq ! ( payment_preimage, payment_preimage_1) ;
1689
- } else { panic ! ( "Unexpected event!" ) ; }
1703
+ assert_eq ! ( events. len( ) , 2 ) ;
1704
+ match events[ 0 ] {
1705
+ Event :: PaymentReceived { ref payment_hash, ref payment_preimage, ref payment_secret, amt, user_payment_id : _ } => {
1706
+ assert_eq ! ( payment_hash_2, * payment_hash) ;
1707
+ assert ! ( payment_preimage. is_none( ) ) ;
1708
+ assert_eq ! ( payment_secret_2, * payment_secret) ;
1709
+ assert_eq ! ( 1_000_000 , amt) ;
1710
+ } ,
1711
+ _ => panic ! ( "Unexpected event" ) ,
1712
+ }
1713
+ match events[ 1 ] {
1714
+ Event :: PaymentReceived { ref payment_hash, ref payment_preimage, ref payment_secret, amt, user_payment_id : _ } => {
1715
+ assert_eq ! ( payment_hash_3, * payment_hash) ;
1716
+ assert ! ( payment_preimage. is_none( ) ) ;
1717
+ assert_eq ! ( payment_secret_3, * payment_secret) ;
1718
+ assert_eq ! ( 1_000_000 , amt) ;
1719
+ } ,
1720
+ _ => panic ! ( "Unexpected event" ) ,
1721
+ }
1690
1722
}
1691
1723
1692
1724
#[ test]
0 commit comments