itest: make sendAndAssertSuccess take context
This commit is contained in:
parent
c4fc72d573
commit
a2a61a104f
@ -296,8 +296,10 @@ out:
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to generate carol invoice: %v", err)
|
t.Fatalf("unable to generate carol invoice: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||||
sendAndAssertSuccess(
|
sendAndAssertSuccess(
|
||||||
t, net.Bob,
|
ctxt, t, net.Bob,
|
||||||
&routerrpc.SendPaymentRequest{
|
&routerrpc.SendPaymentRequest{
|
||||||
PaymentRequest: carolInvoice2.PaymentRequest,
|
PaymentRequest: carolInvoice2.PaymentRequest,
|
||||||
TimeoutSeconds: 60,
|
TimeoutSeconds: 60,
|
||||||
|
@ -68,8 +68,9 @@ func testSendMultiPathPayment(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
rHash := rHashes[0]
|
rHash := rHashes[0]
|
||||||
payReq := payReqs[0]
|
payReq := payReqs[0]
|
||||||
|
|
||||||
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
payment := sendAndAssertSuccess(
|
payment := sendAndAssertSuccess(
|
||||||
t, net.Alice,
|
ctxt, t, net.Alice,
|
||||||
&routerrpc.SendPaymentRequest{
|
&routerrpc.SendPaymentRequest{
|
||||||
PaymentRequest: payReq,
|
PaymentRequest: payReq,
|
||||||
MaxParts: 10,
|
MaxParts: 10,
|
||||||
@ -105,7 +106,7 @@ func testSendMultiPathPayment(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Make sure Bob show the invoice as settled for the full
|
// Make sure Bob show the invoice as settled for the full
|
||||||
// amount.
|
// amount.
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||||
inv, err := ctx.bob.LookupInvoice(
|
inv, err := ctx.bob.LookupInvoice(
|
||||||
ctxt, &lnrpc.PaymentHash{
|
ctxt, &lnrpc.PaymentHash{
|
||||||
RHash: rHash,
|
RHash: rHash,
|
||||||
|
@ -63,8 +63,9 @@ func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// With the invoice for Bob added, send a payment towards Alice paying
|
// With the invoice for Bob added, send a payment towards Alice paying
|
||||||
// to the above generated invoice.
|
// to the above generated invoice.
|
||||||
|
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||||
resp := sendAndAssertSuccess(
|
resp := sendAndAssertSuccess(
|
||||||
t, net.Alice,
|
ctxt, t, net.Alice,
|
||||||
&routerrpc.SendPaymentRequest{
|
&routerrpc.SendPaymentRequest{
|
||||||
PaymentRequest: invoiceResp.PaymentRequest,
|
PaymentRequest: invoiceResp.PaymentRequest,
|
||||||
TimeoutSeconds: 60,
|
TimeoutSeconds: 60,
|
||||||
@ -115,8 +116,9 @@ func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Next send another payment, but this time using a zpay32 encoded
|
// Next send another payment, but this time using a zpay32 encoded
|
||||||
// invoice rather than manually specifying the payment details.
|
// invoice rather than manually specifying the payment details.
|
||||||
|
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||||
sendAndAssertSuccess(
|
sendAndAssertSuccess(
|
||||||
t, net.Alice,
|
ctxt, t, net.Alice,
|
||||||
&routerrpc.SendPaymentRequest{
|
&routerrpc.SendPaymentRequest{
|
||||||
PaymentRequest: invoiceResp.PaymentRequest,
|
PaymentRequest: invoiceResp.PaymentRequest,
|
||||||
TimeoutSeconds: 60,
|
TimeoutSeconds: 60,
|
||||||
@ -138,8 +140,9 @@ func testSingleHopInvoice(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
keySendPreimage := lntypes.Preimage{3, 4, 5, 11}
|
keySendPreimage := lntypes.Preimage{3, 4, 5, 11}
|
||||||
keySendHash := keySendPreimage.Hash()
|
keySendHash := keySendPreimage.Hash()
|
||||||
|
|
||||||
|
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||||
sendAndAssertSuccess(
|
sendAndAssertSuccess(
|
||||||
t, net.Alice,
|
ctxt, t, net.Alice,
|
||||||
&routerrpc.SendPaymentRequest{
|
&routerrpc.SendPaymentRequest{
|
||||||
Dest: net.Bob.PubKey[:],
|
Dest: net.Bob.PubKey[:],
|
||||||
Amt: paymentAmt,
|
Amt: paymentAmt,
|
||||||
|
@ -1300,11 +1300,14 @@ func testPaymentFollowingChannelOpen(net *lntest.NetworkHarness, t *harnessTest)
|
|||||||
|
|
||||||
// Send payment to Bob so that a channel update to disk will be
|
// Send payment to Bob so that a channel update to disk will be
|
||||||
// executed.
|
// executed.
|
||||||
sendAndAssertSuccess(t, net.Alice, &routerrpc.SendPaymentRequest{
|
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||||
PaymentRequest: bobPayReqs[0],
|
sendAndAssertSuccess(
|
||||||
TimeoutSeconds: 60,
|
ctxt, t, net.Alice, &routerrpc.SendPaymentRequest{
|
||||||
FeeLimitSat: 1000000,
|
PaymentRequest: bobPayReqs[0],
|
||||||
})
|
TimeoutSeconds: 60,
|
||||||
|
FeeLimitSat: 1000000,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
// At this point we want to make sure the channel is opened and not
|
// At this point we want to make sure the channel is opened and not
|
||||||
// pending.
|
// pending.
|
||||||
@ -5216,8 +5219,9 @@ func testListPayments(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// With the invoice for Bob added, send a payment towards Alice paying
|
// With the invoice for Bob added, send a payment towards Alice paying
|
||||||
// to the above generated invoice.
|
// to the above generated invoice.
|
||||||
|
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||||
sendAndAssertSuccess(
|
sendAndAssertSuccess(
|
||||||
t, net.Alice,
|
ctxt, t, net.Alice,
|
||||||
&routerrpc.SendPaymentRequest{
|
&routerrpc.SendPaymentRequest{
|
||||||
PaymentRequest: invoiceResp.PaymentRequest,
|
PaymentRequest: invoiceResp.PaymentRequest,
|
||||||
TimeoutSeconds: 60,
|
TimeoutSeconds: 60,
|
||||||
@ -13095,7 +13099,8 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
sendReq.FeeLimitMsat = 1000 * paymentAmt * limit.Percent / 100
|
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)
|
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
|
// sendAndAssertSuccess sends the given payment requests and asserts that the
|
||||||
// payment completes successfully.
|
// 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 {
|
req *routerrpc.SendPaymentRequest) *lnrpc.Payment {
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
var result *lnrpc.Payment
|
var result *lnrpc.Payment
|
||||||
err := wait.NoError(func() error {
|
err := wait.NoError(func() error {
|
||||||
stream, err := node.RouterClient.SendPaymentV2(ctx, req)
|
stream, err := node.RouterClient.SendPaymentV2(ctx, req)
|
||||||
|
Loading…
Reference in New Issue
Block a user