diff --git a/lntest/itest/lnd_multi-hop-error-propagation_test.go b/lntest/itest/lnd_multi-hop-error-propagation_test.go index 6fc629218..65ce48a65 100644 --- a/lntest/itest/lnd_multi-hop-error-propagation_test.go +++ b/lntest/itest/lnd_multi-hop-error-propagation_test.go @@ -296,8 +296,10 @@ out: if err != nil { t.Fatalf("unable to generate carol invoice: %v", err) } + + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) sendAndAssertSuccess( - t, net.Bob, + ctxt, t, net.Bob, &routerrpc.SendPaymentRequest{ PaymentRequest: carolInvoice2.PaymentRequest, TimeoutSeconds: 60, diff --git a/lntest/itest/lnd_send_multi_path_payment_test.go b/lntest/itest/lnd_send_multi_path_payment_test.go index 4065cd0d4..3d21285d0 100644 --- a/lntest/itest/lnd_send_multi_path_payment_test.go +++ b/lntest/itest/lnd_send_multi_path_payment_test.go @@ -68,8 +68,9 @@ func testSendMultiPathPayment(net *lntest.NetworkHarness, t *harnessTest) { rHash := rHashes[0] payReq := payReqs[0] + ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) payment := sendAndAssertSuccess( - t, net.Alice, + ctxt, t, net.Alice, &routerrpc.SendPaymentRequest{ PaymentRequest: payReq, MaxParts: 10, @@ -105,7 +106,7 @@ func testSendMultiPathPayment(net *lntest.NetworkHarness, t *harnessTest) { // Make sure Bob show the invoice as settled for the full // amount. - ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) inv, err := ctx.bob.LookupInvoice( ctxt, &lnrpc.PaymentHash{ RHash: rHash, diff --git a/lntest/itest/lnd_single_hop_invoice_test.go b/lntest/itest/lnd_single_hop_invoice_test.go index 0020b6dcc..e93f93622 100644 --- a/lntest/itest/lnd_single_hop_invoice_test.go +++ b/lntest/itest/lnd_single_hop_invoice_test.go @@ -63,8 +63,9 @@ func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) { // With the invoice for Bob added, send a payment towards Alice paying // to the above generated invoice. + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) resp := sendAndAssertSuccess( - t, net.Alice, + ctxt, t, net.Alice, &routerrpc.SendPaymentRequest{ PaymentRequest: invoiceResp.PaymentRequest, TimeoutSeconds: 60, @@ -115,8 +116,9 @@ func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) { // Next send another payment, but this time using a zpay32 encoded // invoice rather than manually specifying the payment details. + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) sendAndAssertSuccess( - t, net.Alice, + ctxt, t, net.Alice, &routerrpc.SendPaymentRequest{ PaymentRequest: invoiceResp.PaymentRequest, TimeoutSeconds: 60, @@ -138,8 +140,9 @@ func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) { keySendPreimage := lntypes.Preimage{3, 4, 5, 11} keySendHash := keySendPreimage.Hash() + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) sendAndAssertSuccess( - t, net.Alice, + ctxt, t, net.Alice, &routerrpc.SendPaymentRequest{ Dest: net.Bob.PubKey[:], Amt: paymentAmt, diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index bacc4bea3..5e7dd9213 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -1300,11 +1300,14 @@ func testPaymentFollowingChannelOpen(net *lntest.NetworkHarness, t *harnessTest) // Send payment to Bob so that a channel update to disk will be // executed. - sendAndAssertSuccess(t, net.Alice, &routerrpc.SendPaymentRequest{ - PaymentRequest: bobPayReqs[0], - TimeoutSeconds: 60, - FeeLimitSat: 1000000, - }) + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + sendAndAssertSuccess( + ctxt, t, net.Alice, &routerrpc.SendPaymentRequest{ + PaymentRequest: bobPayReqs[0], + TimeoutSeconds: 60, + FeeLimitSat: 1000000, + }, + ) // At this point we want to make sure the channel is opened and not // pending. @@ -5216,8 +5219,9 @@ func testListPayments(net *lntest.NetworkHarness, t *harnessTest) { // With the invoice for Bob added, send a payment towards Alice paying // to the above generated invoice. + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) sendAndAssertSuccess( - t, net.Alice, + ctxt, t, net.Alice, &routerrpc.SendPaymentRequest{ PaymentRequest: invoiceResp.PaymentRequest, TimeoutSeconds: 60, @@ -13095,7 +13099,8 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) { sendReq.FeeLimitMsat = 1000 * paymentAmt * limit.Percent / 100 } - result := sendAndAssertSuccess(t, net.Alice, sendReq) + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + result := sendAndAssertSuccess(ctxt, t, net.Alice, sendReq) checkRoute(result.Htlcs[0].Route) } @@ -13884,12 +13889,9 @@ func deriveFundingShim(net *lntest.NetworkHarness, t *harnessTest, // sendAndAssertSuccess sends the given payment requests and asserts that the // payment completes successfully. -func sendAndAssertSuccess(t *harnessTest, node *lntest.HarnessNode, +func sendAndAssertSuccess(ctx context.Context, t *harnessTest, node *lntest.HarnessNode, req *routerrpc.SendPaymentRequest) *lnrpc.Payment { - ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout) - defer cancel() - var result *lnrpc.Payment err := wait.NoError(func() error { stream, err := node.RouterClient.SendPaymentV2(ctx, req)