Skip to content

Commit 58fa379

Browse files
committed
itest: demonstrate UpdateAddHTLC reloading bug
This commit adds a new route blinding itest that demonstrates that the reloading and re-forwarding of an UpdateAddHTLC message on restart currently is done incorrectly for a blinded path payment. This is due to the fact that the blinding point member is not currently set correctly. This is fixed in the next commit which will also change the test to assert that the behaviour is now correct.
1 parent 8d5f66b commit 58fa379

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

itest/list_on_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,10 @@ var allTestCases = []*lntest.TestCase{
578578
Name: "update pending open channels",
579579
TestFunc: testUpdateOnPendingOpenChannels,
580580
},
581+
{
582+
Name: "blinded payment htlc re-forward",
583+
TestFunc: testBlindedPaymentHTLCReForward,
584+
},
581585
{
582586
Name: "query blinded route",
583587
TestFunc: testQueryBlindedRoutes,

itest/lnd_route_blinding_test.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,3 +1424,75 @@ 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+
//
1436+
// NOTE: this first version of this test asserts that this fails. This is to
1437+
// demonstrate that a bug exists in the reloading and forwarding code. This will
1438+
// be fixed in a following commit.
1439+
func testBlindedPaymentHTLCReForward(ht *lntest.HarnessTest) {
1440+
// Setup a test case.
1441+
ctx, testCase := newBlindedForwardTest(ht)
1442+
defer testCase.cleanup()
1443+
1444+
// Set up network with carol interceptor.
1445+
testCase.setupNetwork(ctx, true)
1446+
1447+
// Let dave create invoice.
1448+
blindedPaymentPath := testCase.buildBlindedPath()
1449+
route := testCase.createRouteToBlinded(10_000_000, blindedPaymentPath)
1450+
1451+
// Once our interceptor is set up, we can send the blinded payment.
1452+
hash := sha256.Sum256(testCase.preimage[:])
1453+
sendReq := &routerrpc.SendToRouteRequest{
1454+
PaymentHash: hash[:],
1455+
Route: route,
1456+
}
1457+
1458+
// In a goroutine, we let Alice pay the invoice from dave.
1459+
//
1460+
// NOTE: for now, we assert that this attempt fails. Once the noted bug
1461+
// is fixed, this will be changed to a success assertion.
1462+
done := make(chan struct{})
1463+
go func() {
1464+
defer close(done)
1465+
1466+
htlcAttempt, err := testCase.ht.Alice.RPC.Router.SendToRouteV2(
1467+
ctx, sendReq,
1468+
)
1469+
require.NoError(testCase.ht, err)
1470+
require.Equal(
1471+
testCase.ht, lnrpc.HTLCAttempt_FAILED,
1472+
htlcAttempt.Status,
1473+
)
1474+
}()
1475+
1476+
// Wait for the HTLC to be active on Alice and Bob's channels.
1477+
ht.AssertOutgoingHTLCActive(ht.Alice, testCase.channels[0], hash[:])
1478+
ht.AssertOutgoingHTLCActive(ht.Bob, testCase.channels[1], hash[:])
1479+
1480+
// Intercept the forward on Carol's link. At this point, we know she
1481+
// has received the HTLC and so will persist this packet.
1482+
_, err := testCase.carolInterceptor.Recv()
1483+
require.NoError(ht, err)
1484+
1485+
// Now, restart Carol. This time, don't require an interceptor. This
1486+
// means that Carol should load up any previously persisted
1487+
// UpdateAddHTLC messages and continue the processing of them.
1488+
ht.RestartNodeWithExtraArgs(
1489+
testCase.carol, []string{"--bitcoin.timelockdelta=18"},
1490+
)
1491+
1492+
// Now, wait for the payment to complete.
1493+
select {
1494+
case <-done:
1495+
case <-time.After(defaultTimeout):
1496+
require.Fail(ht, "timeout waiting for sending payment")
1497+
}
1498+
}

0 commit comments

Comments
 (0)