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