@@ -1394,22 +1394,11 @@ impl SendEvent {
1394
1394
}
1395
1395
1396
1396
#[ macro_export]
1397
+ /// Don't use this, use the identically-named function instead.
1397
1398
macro_rules! expect_pending_htlcs_forwardable_conditions {
1398
- ( $node: expr, $expected_failures: expr) => { {
1399
- let expected_failures = $expected_failures;
1400
- let events = $node. node. get_and_clear_pending_events( ) ;
1401
- match events[ 0 ] {
1402
- $crate:: util:: events:: Event :: PendingHTLCsForwardable { .. } => { } ,
1403
- _ => panic!( "Unexpected event {:?}" , events) ,
1404
- } ;
1405
-
1406
- let count = expected_failures. len( ) + 1 ;
1407
- assert_eq!( events. len( ) , count) ;
1408
-
1409
- if expected_failures. len( ) > 0 {
1410
- expect_htlc_handling_failed_destinations!( events, expected_failures)
1411
- }
1412
- } }
1399
+ ( $node: expr, $expected_failures: expr) => {
1400
+ $crate:: ln:: functional_test_utils:: expect_pending_htlcs_forwardable_conditions( $node. node. get_and_clear_pending_events( ) , & $expected_failures) ;
1401
+ }
1413
1402
}
1414
1403
1415
1404
#[ macro_export]
@@ -1427,27 +1416,49 @@ macro_rules! expect_htlc_handling_failed_destinations {
1427
1416
} }
1428
1417
}
1429
1418
1419
+ /// Checks that an [`Event::PendingHTLCsForwardable`] is available in the given events and, if
1420
+ /// there are any [`Event::HTLCHandlingFailed`] events their [`HTLCDestination`] is included in the
1421
+ /// `expected_failures` set.
1422
+ pub fn expect_pending_htlcs_forwardable_conditions ( events : Vec < Event > , expected_failures : & [ HTLCDestination ] ) {
1423
+ match events[ 0 ] {
1424
+ Event :: PendingHTLCsForwardable { .. } => { } ,
1425
+ _ => panic ! ( "Unexpected event {:?}" , events) ,
1426
+ } ;
1427
+
1428
+ let count = expected_failures. len ( ) + 1 ;
1429
+ assert_eq ! ( events. len( ) , count) ;
1430
+
1431
+ if expected_failures. len ( ) > 0 {
1432
+ expect_htlc_handling_failed_destinations ! ( events, expected_failures)
1433
+ }
1434
+ }
1435
+
1430
1436
#[ macro_export]
1431
1437
/// Clears (and ignores) a PendingHTLCsForwardable event
1438
+ ///
1439
+ /// Don't use this, call [`expect_pending_htlcs_forwardable_conditions()`] with an empty failure
1440
+ /// set instead.
1432
1441
macro_rules! expect_pending_htlcs_forwardable_ignore {
1433
- ( $node: expr) => { {
1434
- expect_pending_htlcs_forwardable_conditions! ( $node, vec! [ ] ) ;
1435
- } } ;
1442
+ ( $node: expr) => {
1443
+ $crate :: ln :: functional_test_utils :: expect_pending_htlcs_forwardable_conditions( $node. node . get_and_clear_pending_events ( ) , & [ ] ) ;
1444
+ }
1436
1445
}
1437
1446
1438
1447
#[ macro_export]
1439
1448
/// Clears (and ignores) PendingHTLCsForwardable and HTLCHandlingFailed events
1449
+ ///
1450
+ /// Don't use this, call [`expect_pending_htlcs_forwardable_conditions()`] instead.
1440
1451
macro_rules! expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore {
1441
- ( $node: expr, $expected_failures: expr) => { {
1442
- expect_pending_htlcs_forwardable_conditions! ( $node, $expected_failures) ;
1443
- } } ;
1452
+ ( $node: expr, $expected_failures: expr) => {
1453
+ $crate :: ln :: functional_test_utils :: expect_pending_htlcs_forwardable_conditions( $node. node . get_and_clear_pending_events ( ) , & $expected_failures) ;
1454
+ }
1444
1455
}
1445
1456
1446
1457
#[ macro_export]
1447
1458
/// Handles a PendingHTLCsForwardable event
1448
1459
macro_rules! expect_pending_htlcs_forwardable {
1449
1460
( $node: expr) => { {
1450
- expect_pending_htlcs_forwardable_ignore! ( $node) ;
1461
+ $crate :: ln :: functional_test_utils :: expect_pending_htlcs_forwardable_conditions ( $node. node . get_and_clear_pending_events ( ) , & [ ] ) ;
1451
1462
$node. node. process_pending_htlc_forwards( ) ;
1452
1463
1453
1464
// Ensure process_pending_htlc_forwards is idempotent.
@@ -1459,7 +1470,7 @@ macro_rules! expect_pending_htlcs_forwardable {
1459
1470
/// Handles a PendingHTLCsForwardable and HTLCHandlingFailed event
1460
1471
macro_rules! expect_pending_htlcs_forwardable_and_htlc_handling_failed {
1461
1472
( $node: expr, $expected_failures: expr) => { {
1462
- expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore! ( $node, $expected_failures) ;
1473
+ $crate :: ln :: functional_test_utils :: expect_pending_htlcs_forwardable_conditions ( $node. node . get_and_clear_pending_events ( ) , & $expected_failures) ;
1463
1474
$node. node. process_pending_htlc_forwards( ) ;
1464
1475
1465
1476
// Ensure process_pending_htlc_forwards is idempotent.
0 commit comments