@@ -1424,3 +1424,68 @@ func testMPPToMultipleBlindedPaths(ht *lntest.HarnessTest) {
14241424 ht .AssertNumWaitingClose (hn , 0 )
14251425 }
14261426}
1427+
1428+ // testBlindedPaymentHTLCReForward tests that an UpdateAddHTLC message is
1429+ // correctly persisted, reloaded and resent to the next peer on restart in the
1430+ // case where the sending peer does not get a chance to send the message before
1431+ // restarting. This test specifically tests that this is done correctly for
1432+ // a blinded path payment since this adds a new blinding point field to
1433+ // UpdateAddHTLC which we need to ensure gets included in the message on
1434+ // restart.
1435+ func testBlindedPaymentHTLCReForward (ht * lntest.HarnessTest ) {
1436+ // Setup a test case.
1437+ ctx , testCase := newBlindedForwardTest (ht )
1438+ defer testCase .cleanup ()
1439+
1440+ // Set up network with carol interceptor.
1441+ testCase .setupNetwork (ctx , true )
1442+
1443+ // Let dave create invoice.
1444+ blindedPaymentPath := testCase .buildBlindedPath ()
1445+ route := testCase .createRouteToBlinded (10_000_000 , blindedPaymentPath )
1446+
1447+ // Once our interceptor is set up, we can send the blinded payment.
1448+ hash := sha256 .Sum256 (testCase .preimage [:])
1449+ sendReq := & routerrpc.SendToRouteRequest {
1450+ PaymentHash : hash [:],
1451+ Route : route ,
1452+ }
1453+
1454+ // In a goroutine, we let Alice pay the invoice from dave.
1455+ done := make (chan struct {})
1456+ go func () {
1457+ defer close (done )
1458+
1459+ htlcAttempt , err := testCase .ht .Alice .RPC .Router .SendToRouteV2 (
1460+ ctx , sendReq ,
1461+ )
1462+ require .NoError (testCase .ht , err )
1463+ require .Equal (
1464+ testCase .ht , lnrpc .HTLCAttempt_SUCCEEDED ,
1465+ htlcAttempt .Status ,
1466+ )
1467+ }()
1468+
1469+ // Wait for the HTLC to be active on Alice and Bob's channels.
1470+ ht .AssertOutgoingHTLCActive (ht .Alice , testCase .channels [0 ], hash [:])
1471+ ht .AssertOutgoingHTLCActive (ht .Bob , testCase .channels [1 ], hash [:])
1472+
1473+ // Intercept the forward on Carol's link. At this point, we know she
1474+ // has received the HTLC and so will persist this packet.
1475+ _ , err := testCase .carolInterceptor .Recv ()
1476+ require .NoError (ht , err )
1477+
1478+ // Now, restart Carol. This time, don't require an interceptor. This
1479+ // means that Carol should load up any previously persisted
1480+ // UpdateAddHTLC messages and continue the processing of them.
1481+ ht .RestartNodeWithExtraArgs (
1482+ testCase .carol , []string {"--bitcoin.timelockdelta=18" },
1483+ )
1484+
1485+ // Now, wait for the payment to complete.
1486+ select {
1487+ case <- done :
1488+ case <- time .After (defaultTimeout ):
1489+ require .Fail (ht , "timeout waiting for sending payment" )
1490+ }
1491+ }
0 commit comments