@@ -1420,3 +1420,75 @@ func testMPPToMultipleBlindedPaths(ht *lntest.HarnessTest) {
14201420 ht .AssertNumWaitingClose (hn , 0 )
14211421 }
14221422}
1423+
1424+ // testBlindedPaymentHTLCReForward tests that an UpdateAddHTLC message is
1425+ // correctly persisted, reloaded and resent to the next peer on restart in the
1426+ // case where the sending peer does not get a chance to send the message before
1427+ // restarting. This test specifically tests that this is done correctly for
1428+ // a blinded path payment since this adds a new blinding point field to
1429+ // UpdateAddHTLC which we need to ensure gets included in the message on
1430+ // restart.
1431+ //
1432+ // NOTE: this first version of this test asserts that this fails. This is to
1433+ // demonstrate that a bug exists in the reloading and forwarding code. This will
1434+ // be fixed in a following commit.
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+ //
1456+ // NOTE: for now, we assert that this attempt fails. Once the noted bug
1457+ // is fixed, this will be changed to a success assertion.
1458+ done := make (chan struct {})
1459+ go func () {
1460+ defer close (done )
1461+
1462+ htlcAttempt , err := testCase .ht .Alice .RPC .Router .SendToRouteV2 (
1463+ ctx , sendReq ,
1464+ )
1465+ require .NoError (testCase .ht , err )
1466+ require .Equal (
1467+ testCase .ht , lnrpc .HTLCAttempt_FAILED ,
1468+ htlcAttempt .Status ,
1469+ )
1470+ }()
1471+
1472+ // Wait for the HTLC to be active on Alice and Bob's channels.
1473+ ht .AssertOutgoingHTLCActive (ht .Alice , testCase .channels [0 ], hash [:])
1474+ ht .AssertOutgoingHTLCActive (ht .Bob , testCase .channels [1 ], hash [:])
1475+
1476+ // Intercept the forward on Carol's link. At this point, we know she
1477+ // has received the HTLC and so will persist this packet.
1478+ _ , err := testCase .carolInterceptor .Recv ()
1479+ require .NoError (ht , err )
1480+
1481+ // Now, restart Carol. This time, don't require an interceptor. This
1482+ // means that Carol should load up any previously persisted
1483+ // UpdateAddHTLC messages and continue the processing of them.
1484+ ht .RestartNodeWithExtraArgs (
1485+ testCase .carol , []string {"--bitcoin.timelockdelta=18" },
1486+ )
1487+
1488+ // Now, wait for the payment to complete.
1489+ select {
1490+ case <- done :
1491+ case <- time .After (defaultTimeout ):
1492+ require .Fail (ht , "timeout waiting for sending payment" )
1493+ }
1494+ }
0 commit comments