itest: make sendAndAssertSuccess take context

This commit is contained in:
Johan T. Halseth 2021-03-31 13:26:56 +02:00
parent c4fc72d573
commit a2a61a104f
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
4 changed files with 25 additions and 17 deletions

@ -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,

@ -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,

@ -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,

@ -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)