@@ -1516,22 +1516,20 @@ macro_rules! commitment_signed_dance {
1516
1516
bs_revoke_and_ack
1517
1517
}
1518
1518
} ;
1519
- ( $node_a: expr, $node_b: expr, ( ) , $fail_backwards: expr, true /* skip last step */ , true /* return extra message */ ) => {
1520
- {
1521
- let ( extra_msg_option, bs_revoke_and_ack) = $crate:: ln:: functional_test_utils:: do_main_commitment_signed_dance( & $node_a, & $node_b, $fail_backwards) ;
1522
- $node_a. node. handle_revoke_and_ack( & $node_b. node. get_our_node_id( ) , & bs_revoke_and_ack) ;
1523
- $crate:: ln:: functional_test_utils:: check_added_monitors( & $node_a, 1 ) ;
1524
- extra_msg_option
1525
- }
1526
- } ;
1527
1519
( $node_a: expr, $node_b: expr, ( ) , $fail_backwards: expr, true /* skip last step */ , false /* no extra message */ ) => {
1528
- assert!( commitment_signed_dance! ( $node_a, $node_b, ( ) , $fail_backwards, true , true ) . is_none( ) ) ;
1520
+ assert!( $crate :: ln :: functional_test_utils :: commitment_signed_dance_through_cp_raa ( & $node_a, & $node_b, $fail_backwards) . is_none( ) ) ;
1529
1521
} ;
1530
1522
( $node_a: expr, $node_b: expr, $commitment_signed: expr, $fail_backwards: expr) => {
1531
1523
$crate:: ln:: functional_test_utils:: do_commitment_signed_dance( & $node_a, & $node_b, & $commitment_signed, $fail_backwards, false ) ;
1532
1524
}
1533
1525
}
1534
1526
1527
+ pub fn commitment_signed_dance_through_cp_raa ( node_a : & Node < ' _ , ' _ , ' _ > , node_b : & Node < ' _ , ' _ , ' _ > , fail_backwards : bool ) -> Option < MessageSendEvent > {
1528
+ let ( extra_msg_option, bs_revoke_and_ack) = do_main_commitment_signed_dance ( node_a, node_b, fail_backwards) ;
1529
+ node_a. node . handle_revoke_and_ack ( & node_b. node . get_our_node_id ( ) , & bs_revoke_and_ack) ;
1530
+ check_added_monitors ( node_a, 1 ) ;
1531
+ extra_msg_option
1532
+ }
1535
1533
1536
1534
pub fn do_main_commitment_signed_dance ( node_a : & Node < ' _ , ' _ , ' _ > , node_b : & Node < ' _ , ' _ , ' _ > , fail_backwards : bool ) -> ( Option < MessageSendEvent > , msgs:: RevokeAndACK ) {
1537
1535
let ( as_revoke_and_ack, as_commitment_signed) = get_revoke_commit_msgs ! ( node_a, node_b. node. get_our_node_id( ) ) ;
@@ -1702,6 +1700,43 @@ macro_rules! expect_payment_claimed {
1702
1700
}
1703
1701
}
1704
1702
1703
+ pub fn expect_payment_sent ( node : & Node < ' _ , ' _ , ' _ > , expected_payment_preimage : PaymentPreimage ,
1704
+ expected_fee_msat_opt : Option < Option < u64 > > , expect_per_path_claims : bool ,
1705
+ ) {
1706
+ let events = node. node . get_and_clear_pending_events ( ) ;
1707
+ let expected_payment_hash = PaymentHash (
1708
+ bitcoin:: hashes:: sha256:: Hash :: hash ( & expected_payment_preimage. 0 ) . into_inner ( ) ) ;
1709
+ if expect_per_path_claims {
1710
+ assert ! ( events. len( ) > 1 ) ;
1711
+ } else {
1712
+ assert_eq ! ( events. len( ) , 1 ) ;
1713
+ }
1714
+ let expected_payment_id = match events[ 0 ] {
1715
+ Event :: PaymentSent { ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat } => {
1716
+ assert_eq ! ( expected_payment_preimage, * payment_preimage) ;
1717
+ assert_eq ! ( expected_payment_hash, * payment_hash) ;
1718
+ if let Some ( expected_fee_msat) = expected_fee_msat_opt {
1719
+ assert_eq ! ( * fee_paid_msat, expected_fee_msat) ;
1720
+ } else {
1721
+ assert ! ( fee_paid_msat. is_some( ) ) ;
1722
+ }
1723
+ payment_id. unwrap ( )
1724
+ } ,
1725
+ _ => panic ! ( "Unexpected event" ) ,
1726
+ } ;
1727
+ if expect_per_path_claims {
1728
+ for i in 1 ..events. len ( ) {
1729
+ match events[ i] {
1730
+ Event :: PaymentPathSuccessful { payment_id, payment_hash, .. } => {
1731
+ assert_eq ! ( payment_id, expected_payment_id) ;
1732
+ assert_eq ! ( payment_hash, Some ( expected_payment_hash) ) ;
1733
+ } ,
1734
+ _ => panic ! ( "Unexpected event" ) ,
1735
+ }
1736
+ }
1737
+ }
1738
+ }
1739
+
1705
1740
#[ cfg( test) ]
1706
1741
#[ macro_export]
1707
1742
macro_rules! expect_payment_sent_without_paths {
@@ -1721,40 +1756,10 @@ macro_rules! expect_payment_sent {
1721
1756
( $node: expr, $expected_payment_preimage: expr, $expected_fee_msat_opt: expr) => {
1722
1757
$crate:: expect_payment_sent!( $node, $expected_payment_preimage, $expected_fee_msat_opt, true ) ;
1723
1758
} ;
1724
- ( $node: expr, $expected_payment_preimage: expr, $expected_fee_msat_opt: expr, $expect_paths: expr) => { {
1725
- use bitcoin:: hashes:: Hash as _;
1726
- let events = $node. node. get_and_clear_pending_events( ) ;
1727
- let expected_payment_hash = $crate:: ln:: PaymentHash (
1728
- bitcoin:: hashes:: sha256:: Hash :: hash( & $expected_payment_preimage. 0 ) . into_inner( ) ) ;
1729
- if $expect_paths {
1730
- assert!( events. len( ) > 1 ) ;
1731
- } else {
1732
- assert_eq!( events. len( ) , 1 ) ;
1733
- }
1734
- let expected_payment_id = match events[ 0 ] {
1735
- $crate:: util:: events:: Event :: PaymentSent { ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat } => {
1736
- assert_eq!( $expected_payment_preimage, * payment_preimage) ;
1737
- assert_eq!( expected_payment_hash, * payment_hash) ;
1738
- assert!( fee_paid_msat. is_some( ) ) ;
1739
- if $expected_fee_msat_opt. is_some( ) {
1740
- assert_eq!( * fee_paid_msat, $expected_fee_msat_opt) ;
1741
- }
1742
- payment_id. unwrap( )
1743
- } ,
1744
- _ => panic!( "Unexpected event" ) ,
1745
- } ;
1746
- if $expect_paths {
1747
- for i in 1 ..events. len( ) {
1748
- match events[ i] {
1749
- $crate:: util:: events:: Event :: PaymentPathSuccessful { payment_id, payment_hash, .. } => {
1750
- assert_eq!( payment_id, expected_payment_id) ;
1751
- assert_eq!( payment_hash, Some ( expected_payment_hash) ) ;
1752
- } ,
1753
- _ => panic!( "Unexpected event" ) ,
1754
- }
1755
- }
1756
- }
1757
- } }
1759
+ ( $node: expr, $expected_payment_preimage: expr, $expected_fee_msat_opt: expr, $expect_paths: expr) => {
1760
+ $crate:: ln:: functional_test_utils:: expect_payment_sent( & $node, $expected_payment_preimage,
1761
+ $expected_fee_msat_opt. map( |o| Some ( o) ) , $expect_paths) ;
1762
+ }
1758
1763
}
1759
1764
1760
1765
#[ cfg( test) ]
0 commit comments