diff --git a/itest/lnd_route_blinding.go b/itest/lnd_route_blinding.go index a1d197683c..54a5c93a3f 100644 --- a/itest/lnd_route_blinding.go +++ b/itest/lnd_route_blinding.go @@ -321,6 +321,8 @@ type blindedForwardTest struct { dave *node.HarnessNode channels []*lnrpc.ChannelPoint + preimage [33]byte + // ctx is a context to be used by the test. ctx context.Context //nolint:containedctx @@ -332,9 +334,10 @@ func newBlindedForwardTest(ht *lntest.HarnessTest) *blindedForwardTest { ctx, cancel := context.WithCancel(context.Background()) return &blindedForwardTest{ - ht: ht, - ctx: ctx, - cancel: cancel, + ht: ht, + ctx: ctx, + cancel: cancel, + preimage: [33]byte{1, 2, 3}, } } @@ -434,6 +437,29 @@ func (b *blindedForwardTest) createRouteToBlinded(paymentAmt int64, return resp.Routes[0] } +// sendBlindedPayment dispatches a payment to the route provided. The streaming +// client for the send is returned with a cancel function that can be used to +// terminate the stream. +func (b *blindedForwardTest) sendBlindedPayment(route *lnrpc.Route) ( + lnrpc.Lightning_SendToRouteClient, func()) { + + hash := sha256.Sum256(b.preimage[:]) + + ctxt, cancel := context.WithCancel(b.ctx) + sendReq := &lnrpc.SendToRouteRequest{ + PaymentHash: hash[:], + Route: route, + } + + sendClient, err := b.ht.Alice.RPC.LN.SendToRoute(ctxt) + require.NoError(b.ht, err, "send to route client") + + err = sendClient.SendMsg(sendReq) + require.NoError(b.ht, err, "send to route request") + + return sendClient, cancel +} + // setupFourHopNetwork creates a network with the following topology and // liquidity: // Alice (100k)----- Bob (100k) ----- Carol (100k) ----- Dave @@ -625,5 +651,11 @@ func testForwardBlindedRoute(ht *lntest.HarnessTest) { defer testCase.cleanup() route := testCase.setup() - testCase.createRouteToBlinded(100_000, route) + blindedRoute := testCase.createRouteToBlinded(100_000, route) + + testCase.sendBlindedPayment(blindedRoute) + + // Wait for the HTLC to be active on Alice's channel. + hash := sha256.Sum256(testCase.preimage[:]) + ht.AssertHLTCNotActive(ht.Alice, testCase.channels[0], hash) }