Skip to content

Commit dc84315

Browse files
committed
itest: assert payment status after sending
1 parent 96a9524 commit dc84315

8 files changed

+32
-35
lines changed

itest/lnd_channel_balance_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func testChannelUnsettledBalance(ht *lntest.HarnessTest) {
156156
TimeoutSeconds: 60,
157157
FeeLimitMsat: noFeeLimitMsat,
158158
}
159-
alice.RPC.SendPayment(req)
159+
ht.SendPaymentAssertInflight(alice, req)
160160
}()
161161
}
162162

itest/lnd_channel_force_close_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func runChannelForceClosureTest(ht *lntest.HarnessTest,
114114
TimeoutSeconds: 60,
115115
FeeLimitMsat: noFeeLimitMsat,
116116
}
117-
alice.RPC.SendPayment(req)
117+
ht.SendPaymentAssertInflight(alice, req)
118118
}
119119

120120
// Once the HTLC has cleared, all the nodes n our mini network should

itest/lnd_forward_interceptor_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,7 @@ func testForwardInterceptorWireRecords(ht *lntest.HarnessTest) {
508508
FeeLimitMsat: noFeeLimitMsat,
509509
FirstHopCustomRecords: customRecords,
510510
}
511-
512-
_ = alice.RPC.SendPayment(sendReq)
511+
ht.SendPaymentAssertInflight(alice, sendReq)
513512

514513
// We start the htlc interceptor with a simple implementation that saves
515514
// all intercepted packets. These packets are held to simulate a
@@ -635,8 +634,7 @@ func testForwardInterceptorRestart(ht *lntest.HarnessTest) {
635634
FeeLimitMsat: noFeeLimitMsat,
636635
FirstHopCustomRecords: customRecords,
637636
}
638-
639-
_ = alice.RPC.SendPayment(sendReq)
637+
ht.SendPaymentAssertInflight(alice, sendReq)
640638

641639
// We start the htlc interceptor with a simple implementation that saves
642640
// all intercepted packets. These packets are held to simulate a

itest/lnd_hold_invoice_force_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func testHoldInvoiceForceClose(ht *lntest.HarnessTest) {
4444
TimeoutSeconds: 60,
4545
FeeLimitMsat: noFeeLimitMsat,
4646
}
47-
alice.RPC.SendPayment(req)
47+
ht.SendPaymentAssertInflight(alice, req)
4848

4949
ht.AssertInvoiceState(stream, lnrpc.Invoice_ACCEPTED)
5050

itest/lnd_htlc_timeout_resolver_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func testHtlcTimeoutResolverExtractPreimageRemote(ht *lntest.HarnessTest) {
131131
TimeoutSeconds: 60,
132132
FeeLimitMsat: noFeeLimitMsat,
133133
}
134-
alice.RPC.SendPayment(req)
134+
ht.SendPaymentAssertInflight(alice, req)
135135

136136
// Once the payment sent, Alice should have one outgoing HTLC active.
137137
ht.AssertOutgoingHTLCActive(alice, aliceChanPoint, payHash[:])
@@ -270,7 +270,7 @@ func testHtlcTimeoutResolverExtractPreimageLocal(ht *lntest.HarnessTest) {
270270
TimeoutSeconds: 60,
271271
FeeLimitMsat: noFeeLimitMsat,
272272
}
273-
alice.RPC.SendPayment(req)
273+
ht.SendPaymentAssertInflight(alice, req)
274274

275275
// Once the payment sent, Alice should have one outgoing HTLC active.
276276
ht.AssertOutgoingHTLCActive(alice, aliceChanPoint, payHash[:])

itest/lnd_misc_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,10 @@ func testRejectHTLC(ht *lntest.HarnessTest) {
632632
TimeoutSeconds: 60,
633633
FeeLimitMsat: noFeeLimitMsat,
634634
}
635-
payStream := alice.RPC.SendPayment(paymentReq)
636-
ht.AssertPaymentStatusFromStream(payStream, lnrpc.Payment_FAILED)
635+
ht.SendPaymentAssertFail(
636+
alice, paymentReq,
637+
lnrpc.PaymentFailureReason_FAILURE_REASON_NO_ROUTE,
638+
)
637639

638640
ht.AssertLastHTLCError(alice, lnrpc.Failure_CHANNEL_DISABLED)
639641

itest/lnd_multi-hop_force_close_test.go

+15-13
Original file line numberDiff line numberDiff line change
@@ -298,25 +298,27 @@ func runLocalClaimOutgoingHTLC(ht *lntest.HarnessTest,
298298
routeHints = makeRouteHints(bob, carol, params.ZeroConf)
299299
}
300300

301-
alice.RPC.SendPayment(&routerrpc.SendPaymentRequest{
301+
req := &routerrpc.SendPaymentRequest{
302302
Dest: carolPubKey,
303303
Amt: int64(dustHtlcAmt),
304304
PaymentHash: dustPayHash,
305305
FinalCltvDelta: finalCltvDelta,
306306
TimeoutSeconds: 60,
307307
FeeLimitMsat: noFeeLimitMsat,
308308
RouteHints: routeHints,
309-
})
309+
}
310+
ht.SendPaymentAssertInflight(alice, req)
310311

311-
alice.RPC.SendPayment(&routerrpc.SendPaymentRequest{
312+
req = &routerrpc.SendPaymentRequest{
312313
Dest: carolPubKey,
313314
Amt: int64(htlcAmt),
314315
PaymentHash: payHash,
315316
FinalCltvDelta: finalCltvDelta,
316317
TimeoutSeconds: 60,
317318
FeeLimitMsat: noFeeLimitMsat,
318319
RouteHints: routeHints,
319-
})
320+
}
321+
ht.SendPaymentAssertInflight(alice, req)
320322

321323
// Verify that all nodes in the path now have two HTLC's with the
322324
// proper parameters.
@@ -642,7 +644,7 @@ func runMultiHopReceiverPreimageClaim(ht *lntest.HarnessTest,
642644
TimeoutSeconds: 60,
643645
FeeLimitMsat: noFeeLimitMsat,
644646
}
645-
alice.RPC.SendPayment(req)
647+
ht.SendPaymentAssertInflight(alice, req)
646648

647649
// At this point, all 3 nodes should now have an active channel with
648650
// the created HTLC pending on all of them.
@@ -985,7 +987,7 @@ func runLocalForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest,
985987
FeeLimitMsat: noFeeLimitMsat,
986988
RouteHints: routeHints,
987989
}
988-
alice.RPC.SendPayment(req)
990+
ht.SendPaymentAssertInflight(alice, req)
989991

990992
// Once the HTLC has cleared, all channels in our mini network should
991993
// have the it locked in.
@@ -1314,7 +1316,7 @@ func runRemoteForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest,
13141316
TimeoutSeconds: 60,
13151317
FeeLimitMsat: noFeeLimitMsat,
13161318
}
1317-
alice.RPC.SendPayment(req)
1319+
ht.SendPaymentAssertInflight(alice, req)
13181320

13191321
// Once the HTLC has cleared, all the nodes in our mini network should
13201322
// show that the HTLC has been locked in.
@@ -1580,7 +1582,7 @@ func runLocalClaimIncomingHTLC(ht *lntest.HarnessTest,
15801582
TimeoutSeconds: 60,
15811583
FeeLimitMsat: noFeeLimitMsat,
15821584
}
1583-
alice.RPC.SendPayment(req)
1585+
ht.SendPaymentAssertInflight(alice, req)
15841586

15851587
// At this point, all 3 nodes should now have an active channel with
15861588
// the created HTLC pending on all of them.
@@ -1867,7 +1869,7 @@ func runLocalClaimIncomingHTLCLeased(ht *lntest.HarnessTest,
18671869
TimeoutSeconds: 60,
18681870
FeeLimitMsat: noFeeLimitMsat,
18691871
}
1870-
alice.RPC.SendPayment(req)
1872+
ht.SendPaymentAssertInflight(alice, req)
18711873

18721874
// At this point, all 3 nodes should now have an active channel with
18731875
// the created HTLC pending on all of them.
@@ -2214,7 +2216,7 @@ func runLocalPreimageClaim(ht *lntest.HarnessTest,
22142216
TimeoutSeconds: 60,
22152217
FeeLimitMsat: noFeeLimitMsat,
22162218
}
2217-
alice.RPC.SendPayment(req)
2219+
ht.SendPaymentAssertInflight(alice, req)
22182220

22192221
// At this point, all 3 nodes should now have an active channel with
22202222
// the created HTLC pending on all of them.
@@ -2465,7 +2467,7 @@ func runLocalPreimageClaimLeased(ht *lntest.HarnessTest,
24652467
TimeoutSeconds: 60,
24662468
FeeLimitMsat: noFeeLimitMsat,
24672469
}
2468-
alice.RPC.SendPayment(req)
2470+
ht.SendPaymentAssertInflight(alice, req)
24692471

24702472
// At this point, all 3 nodes should now have an active channel with
24712473
// the created HTLC pending on all of them.
@@ -2904,7 +2906,7 @@ func runHtlcAggregation(ht *lntest.HarnessTest,
29042906
TimeoutSeconds: 60,
29052907
FeeLimitMsat: noFeeLimitMsat,
29062908
}
2907-
alice.RPC.SendPayment(req)
2909+
ht.SendPaymentAssertInflight(alice, req)
29082910
}
29092911

29102912
// And Carol will pay Alice's.
@@ -2914,7 +2916,7 @@ func runHtlcAggregation(ht *lntest.HarnessTest,
29142916
TimeoutSeconds: 60,
29152917
FeeLimitMsat: noFeeLimitMsat,
29162918
}
2917-
carol.RPC.SendPayment(req)
2919+
ht.SendPaymentAssertInflight(carol, req)
29182920
}
29192921

29202922
// At this point, all 3 nodes should now the HTLCs active on their

itest/lnd_watchtower_test.go

+6-11
Original file line numberDiff line numberDiff line change
@@ -655,17 +655,12 @@ func generateBackups(ht *lntest.HarnessTest, srcNode,
655655
)
656656

657657
send := func(node *node.HarnessNode, payReq string) {
658-
stream := node.RPC.SendPayment(
659-
&routerrpc.SendPaymentRequest{
660-
PaymentRequest: payReq,
661-
TimeoutSeconds: 60,
662-
FeeLimitMsat: noFeeLimitMsat,
663-
},
664-
)
665-
666-
ht.AssertPaymentStatusFromStream(
667-
stream, lnrpc.Payment_SUCCEEDED,
668-
)
658+
req := &routerrpc.SendPaymentRequest{
659+
PaymentRequest: payReq,
660+
TimeoutSeconds: 60,
661+
FeeLimitMsat: noFeeLimitMsat,
662+
}
663+
ht.SendPaymentAssertSettled(node, req)
669664
}
670665

671666
// Pay each invoice.

0 commit comments

Comments
 (0)