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