@@ -448,21 +448,25 @@ func (b *blindedForwardTest) createRouteToBlinded(paymentAmt int64,
448448 return resp .Routes [0 ]
449449}
450450
451- // sendBlindedPayment dispatches a payment to the route provided.
451+ // sendBlindedPayment dispatches a payment to the route provided, returning a
452+ // cancel function for the payment. Timeout is set for very long to allow
453+ // time for on-chain resolution.
452454func (b * blindedForwardTest ) sendBlindedPayment (ctx context.Context ,
453- route * lnrpc.Route ) {
455+ route * lnrpc.Route ) func () {
454456
455457 hash := sha256 .Sum256 (b .preimage [:])
456458 sendReq := & routerrpc.SendToRouteRequest {
457459 PaymentHash : hash [:],
458460 Route : route ,
459461 }
460462
461- // Dispatch in a goroutine because this call is blocking - we assume
462- // that we'll have assertions that this payment is sent by the caller.
463+ ctx , cancel := context .WithTimeout (ctx , time .Hour )
463464 go func () {
464- b .ht .Alice .RPC .SendToRouteV2 (sendReq )
465+ _ , err := b .ht .Alice .RPC .Router .SendToRouteV2 (ctx , sendReq )
466+ require .NoError (b .ht , err )
465467 }()
468+
469+ return cancel
466470}
467471
468472// interceptFinalHop launches a goroutine to intercept Carol's htlcs and
@@ -805,7 +809,8 @@ func testForwardBlindedRoute(ht *lntest.HarnessTest) {
805809 resolveHTLC := testCase .interceptFinalHop ()
806810
807811 // Once our interceptor is set up, we can send the blinded payment.
808- testCase .sendBlindedPayment (ctx , blindedRoute )
812+ cancelPmt := testCase .sendBlindedPayment (ctx , blindedRoute )
813+ defer cancelPmt ()
809814
810815 // Wait for the HTLC to be active on Alice's channel.
811816 hash := sha256 .Sum256 (testCase .preimage [:])
@@ -886,7 +891,8 @@ func sendAndResumeBlindedPayment(ctx context.Context, ht *lntest.HarnessTest,
886891 // First, test sending the payment all the way through to Dave. We
887892 // expect this payment to fail, because he does not know how to
888893 // process payments to a blinded route (not yet supported).
889- testCase .sendBlindedPayment (ctx , blindedRoute )
894+ cancelPmt := testCase .sendBlindedPayment (ctx , blindedRoute )
895+ defer cancelPmt ()
890896
891897 // When Carol intercepts the HTLC, instruct her to resume the payment
892898 // so that it'll reach Dave and fail.
0 commit comments