Skip to content

Commit 8bc5dbc

Browse files
committed
itest: assert payment status after sending
1 parent b7b351f commit 8bc5dbc

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.
@@ -645,7 +647,7 @@ func runMultiHopReceiverPreimageClaim(ht *lntest.HarnessTest,
645647
TimeoutSeconds: 60,
646648
FeeLimitMsat: noFeeLimitMsat,
647649
}
648-
alice.RPC.SendPayment(req)
650+
ht.SendPaymentAssertInflight(alice, req)
649651

650652
// At this point, all 3 nodes should now have an active channel with
651653
// the created HTLC pending on all of them.
@@ -1006,7 +1008,7 @@ func runLocalForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest,
10061008
FeeLimitMsat: noFeeLimitMsat,
10071009
RouteHints: routeHints,
10081010
}
1009-
alice.RPC.SendPayment(req)
1011+
ht.SendPaymentAssertInflight(alice, req)
10101012

10111013
// Once the HTLC has cleared, all channels in our mini network should
10121014
// have the it locked in.
@@ -1335,7 +1337,7 @@ func runRemoteForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest,
13351337
TimeoutSeconds: 60,
13361338
FeeLimitMsat: noFeeLimitMsat,
13371339
}
1338-
alice.RPC.SendPayment(req)
1340+
ht.SendPaymentAssertInflight(alice, req)
13391341

13401342
// Once the HTLC has cleared, all the nodes in our mini network should
13411343
// show that the HTLC has been locked in.
@@ -1594,7 +1596,7 @@ func runLocalClaimIncomingHTLC(ht *lntest.HarnessTest,
15941596
TimeoutSeconds: 60,
15951597
FeeLimitMsat: noFeeLimitMsat,
15961598
}
1597-
alice.RPC.SendPayment(req)
1599+
ht.SendPaymentAssertInflight(alice, req)
15981600

15991601
// At this point, all 3 nodes should now have an active channel with
16001602
// the created HTLC pending on all of them.
@@ -1897,7 +1899,7 @@ func runLocalClaimIncomingHTLCLeased(ht *lntest.HarnessTest,
18971899
TimeoutSeconds: 60,
18981900
FeeLimitMsat: noFeeLimitMsat,
18991901
}
1900-
alice.RPC.SendPayment(req)
1902+
ht.SendPaymentAssertInflight(alice, req)
19011903

19021904
// At this point, all 3 nodes should now have an active channel with
19031905
// the created HTLC pending on all of them.
@@ -2252,7 +2254,7 @@ func runLocalPreimageClaim(ht *lntest.HarnessTest,
22522254
TimeoutSeconds: 60,
22532255
FeeLimitMsat: noFeeLimitMsat,
22542256
}
2255-
alice.RPC.SendPayment(req)
2257+
ht.SendPaymentAssertInflight(alice, req)
22562258

22572259
// At this point, all 3 nodes should now have an active channel with
22582260
// the created HTLC pending on all of them.
@@ -2535,7 +2537,7 @@ func runLocalPreimageClaimLeased(ht *lntest.HarnessTest,
25352537
TimeoutSeconds: 60,
25362538
FeeLimitMsat: noFeeLimitMsat,
25372539
}
2538-
alice.RPC.SendPayment(req)
2540+
ht.SendPaymentAssertInflight(alice, req)
25392541

25402542
// At this point, all 3 nodes should now have an active channel with
25412543
// the created HTLC pending on all of them.
@@ -2982,7 +2984,7 @@ func runHtlcAggregation(ht *lntest.HarnessTest,
29822984
TimeoutSeconds: 60,
29832985
FeeLimitMsat: noFeeLimitMsat,
29842986
}
2985-
alice.RPC.SendPayment(req)
2987+
ht.SendPaymentAssertInflight(alice, req)
29862988
}
29872989

29882990
// And Carol will pay Alice's.
@@ -2992,7 +2994,7 @@ func runHtlcAggregation(ht *lntest.HarnessTest,
29922994
TimeoutSeconds: 60,
29932995
FeeLimitMsat: noFeeLimitMsat,
29942996
}
2995-
carol.RPC.SendPayment(req)
2997+
ht.SendPaymentAssertInflight(carol, req)
29962998
}
29972999

29983000
// 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)