@@ -1555,22 +1555,20 @@ macro_rules! commitment_signed_dance {
1555
1555
bs_revoke_and_ack
1556
1556
}
1557
1557
} ;
1558
- ( $node_a: expr, $node_b: expr, ( ) , $fail_backwards: expr, true /* skip last step */ , true /* return extra message */ ) => {
1559
- {
1560
- let ( extra_msg_option, bs_revoke_and_ack) = $crate:: ln:: functional_test_utils:: do_main_commitment_signed_dance( & $node_a, & $node_b, $fail_backwards) ;
1561
- $node_a. node. handle_revoke_and_ack( & $node_b. node. get_our_node_id( ) , & bs_revoke_and_ack) ;
1562
- $crate:: ln:: functional_test_utils:: check_added_monitors( & $node_a, 1 ) ;
1563
- extra_msg_option
1564
- }
1565
- } ;
1566
1558
( $node_a: expr, $node_b: expr, ( ) , $fail_backwards: expr, true /* skip last step */ , false /* no extra message */ ) => {
1567
- assert!( commitment_signed_dance! ( $node_a, $node_b, ( ) , $fail_backwards, true , true ) . is_none( ) ) ;
1559
+ assert!( $crate :: ln :: functional_test_utils :: commitment_signed_dance_through_cp_raa ( & $node_a, & $node_b, $fail_backwards) . is_none( ) ) ;
1568
1560
} ;
1569
1561
( $node_a: expr, $node_b: expr, $commitment_signed: expr, $fail_backwards: expr) => {
1570
1562
$crate:: ln:: functional_test_utils:: do_commitment_signed_dance( & $node_a, & $node_b, & $commitment_signed, $fail_backwards, false ) ;
1571
1563
}
1572
1564
}
1573
1565
1566
+ pub fn commitment_signed_dance_through_cp_raa ( node_a : & Node < ' _ , ' _ , ' _ > , node_b : & Node < ' _ , ' _ , ' _ > , fail_backwards : bool ) -> Option < MessageSendEvent > {
1567
+ let ( extra_msg_option, bs_revoke_and_ack) = do_main_commitment_signed_dance ( node_a, node_b, fail_backwards) ;
1568
+ node_a. node . handle_revoke_and_ack ( & node_b. node . get_our_node_id ( ) , & bs_revoke_and_ack) ;
1569
+ check_added_monitors ( node_a, 1 ) ;
1570
+ extra_msg_option
1571
+ }
1574
1572
1575
1573
pub fn do_main_commitment_signed_dance ( node_a : & Node < ' _ , ' _ , ' _ > , node_b : & Node < ' _ , ' _ , ' _ > , fail_backwards : bool ) -> ( Option < MessageSendEvent > , msgs:: RevokeAndACK ) {
1576
1574
let ( as_revoke_and_ack, as_commitment_signed) = get_revoke_commit_msgs ! ( node_a, node_b. node. get_our_node_id( ) ) ;
@@ -1741,6 +1739,44 @@ macro_rules! expect_payment_claimed {
1741
1739
}
1742
1740
}
1743
1741
1742
+ pub fn expect_payment_sent < CM : AChannelManager , H : NodeHolder < CM =CM > > ( node : & H ,
1743
+ expected_payment_preimage : PaymentPreimage , expected_fee_msat_opt : Option < Option < u64 > > ,
1744
+ expect_per_path_claims : bool ,
1745
+ ) {
1746
+ let events = node. node ( ) . get_and_clear_pending_events ( ) ;
1747
+ let expected_payment_hash = PaymentHash (
1748
+ bitcoin:: hashes:: sha256:: Hash :: hash ( & expected_payment_preimage. 0 ) . into_inner ( ) ) ;
1749
+ if expect_per_path_claims {
1750
+ assert ! ( events. len( ) > 1 ) ;
1751
+ } else {
1752
+ assert_eq ! ( events. len( ) , 1 ) ;
1753
+ }
1754
+ let expected_payment_id = match events[ 0 ] {
1755
+ Event :: PaymentSent { ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat } => {
1756
+ assert_eq ! ( expected_payment_preimage, * payment_preimage) ;
1757
+ assert_eq ! ( expected_payment_hash, * payment_hash) ;
1758
+ if let Some ( expected_fee_msat) = expected_fee_msat_opt {
1759
+ assert_eq ! ( * fee_paid_msat, expected_fee_msat) ;
1760
+ } else {
1761
+ assert ! ( fee_paid_msat. is_some( ) ) ;
1762
+ }
1763
+ payment_id. unwrap ( )
1764
+ } ,
1765
+ _ => panic ! ( "Unexpected event" ) ,
1766
+ } ;
1767
+ if expect_per_path_claims {
1768
+ for i in 1 ..events. len ( ) {
1769
+ match events[ i] {
1770
+ Event :: PaymentPathSuccessful { payment_id, payment_hash, .. } => {
1771
+ assert_eq ! ( payment_id, expected_payment_id) ;
1772
+ assert_eq ! ( payment_hash, Some ( expected_payment_hash) ) ;
1773
+ } ,
1774
+ _ => panic ! ( "Unexpected event" ) ,
1775
+ }
1776
+ }
1777
+ }
1778
+ }
1779
+
1744
1780
#[ cfg( test) ]
1745
1781
#[ macro_export]
1746
1782
macro_rules! expect_payment_sent_without_paths {
@@ -1760,40 +1796,10 @@ macro_rules! expect_payment_sent {
1760
1796
( $node: expr, $expected_payment_preimage: expr, $expected_fee_msat_opt: expr) => {
1761
1797
$crate:: expect_payment_sent!( $node, $expected_payment_preimage, $expected_fee_msat_opt, true ) ;
1762
1798
} ;
1763
- ( $node: expr, $expected_payment_preimage: expr, $expected_fee_msat_opt: expr, $expect_paths: expr) => { {
1764
- use bitcoin:: hashes:: Hash as _;
1765
- let events = $node. node. get_and_clear_pending_events( ) ;
1766
- let expected_payment_hash = $crate:: ln:: PaymentHash (
1767
- bitcoin:: hashes:: sha256:: Hash :: hash( & $expected_payment_preimage. 0 ) . into_inner( ) ) ;
1768
- if $expect_paths {
1769
- assert!( events. len( ) > 1 ) ;
1770
- } else {
1771
- assert_eq!( events. len( ) , 1 ) ;
1772
- }
1773
- let expected_payment_id = match events[ 0 ] {
1774
- $crate:: events:: Event :: PaymentSent { ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat } => {
1775
- assert_eq!( $expected_payment_preimage, * payment_preimage) ;
1776
- assert_eq!( expected_payment_hash, * payment_hash) ;
1777
- assert!( fee_paid_msat. is_some( ) ) ;
1778
- if $expected_fee_msat_opt. is_some( ) {
1779
- assert_eq!( * fee_paid_msat, $expected_fee_msat_opt) ;
1780
- }
1781
- payment_id. unwrap( )
1782
- } ,
1783
- _ => panic!( "Unexpected event" ) ,
1784
- } ;
1785
- if $expect_paths {
1786
- for i in 1 ..events. len( ) {
1787
- match events[ i] {
1788
- $crate:: events:: Event :: PaymentPathSuccessful { payment_id, payment_hash, .. } => {
1789
- assert_eq!( payment_id, expected_payment_id) ;
1790
- assert_eq!( payment_hash, Some ( expected_payment_hash) ) ;
1791
- } ,
1792
- _ => panic!( "Unexpected event" ) ,
1793
- }
1794
- }
1795
- }
1796
- } }
1799
+ ( $node: expr, $expected_payment_preimage: expr, $expected_fee_msat_opt: expr, $expect_paths: expr) => {
1800
+ $crate:: ln:: functional_test_utils:: expect_payment_sent( & $node, $expected_payment_preimage,
1801
+ $expected_fee_msat_opt. map( |o| Some ( o) ) , $expect_paths) ;
1802
+ }
1797
1803
}
1798
1804
1799
1805
#[ cfg( test) ]
0 commit comments