@@ -21,25 +21,10 @@ import (
2121)
2222
2323var sendToRouteTestCases = []* lntest.TestCase {
24- {
25- Name : "single hop with sync" ,
26- TestFunc : func (ht * lntest.HarnessTest ) {
27- // useStream: false, routerrpc: false.
28- testSingleHopSendToRouteCase (ht , false , false )
29- },
30- },
31- {
32- Name : "single hop with stream" ,
33- TestFunc : func (ht * lntest.HarnessTest ) {
34- // useStream: true, routerrpc: false.
35- testSingleHopSendToRouteCase (ht , true , false )
36- },
37- },
3824 {
3925 Name : "single hop with v2" ,
4026 TestFunc : func (ht * lntest.HarnessTest ) {
41- // useStream: false, routerrpc: true.
42- testSingleHopSendToRouteCase (ht , false , true )
27+ testSingleHopSendToRouteCase (ht )
4328 },
4429 },
4530}
@@ -50,12 +35,11 @@ var sendToRouteTestCases = []*lntest.TestCase{
5035//
5136// Carol --100k--> Dave
5237//
53- // We'll query the daemon for routes from Carol to Dave and then send payments
54- // by feeding the route back into the various SendToRoute RPC methods. Here we
55- // test all three SendToRoute endpoints, forcing each to perform both a regular
56- // payment and an MPP payment.
57- func testSingleHopSendToRouteCase (ht * lntest.HarnessTest ,
58- useStream , useRPC bool ) {
38+ // We'll query the daemon for a route from Carol to Dave and then send payments
39+ // using SendToRouteV2. This test ensures that payments are properly processed
40+ // through the provided route with a single hop, and tests both regular payments
41+ // and Multi-Path Payments (MPP) via the same method.
42+ func testSingleHopSendToRouteCase (ht * lntest.HarnessTest ) {
5943
6044 const chanAmt = btcutil .Amount (100000 )
6145 const paymentAmtSat = 1000
@@ -119,44 +103,7 @@ func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
119103 }
120104 }
121105
122- // Construct closures for each of the payment types covered:
123- // - main rpc server sync
124- // - main rpc server streaming
125- // - routerrpc server sync
126- sendToRouteSync := func () {
127- for i , rHash := range rHashes {
128- setMPPFields (i )
129-
130- sendReq := & lnrpc.SendToRouteRequest {
131- PaymentHash : rHash ,
132- Route : r ,
133- }
134- resp := carol .RPC .SendToRouteSync (sendReq )
135- require .Emptyf (ht , resp .PaymentError ,
136- "received payment error from %s: %v" ,
137- carol .Name (), resp .PaymentError )
138- }
139- }
140- sendToRouteStream := func () {
141- alicePayStream := carol .RPC .SendToRoute ()
142-
143- for i , rHash := range rHashes {
144- setMPPFields (i )
145-
146- sendReq := & lnrpc.SendToRouteRequest {
147- PaymentHash : rHash ,
148- Route : routes .Routes [0 ],
149- }
150- err := alicePayStream .Send (sendReq )
151- require .NoError (ht , err , "unable to send payment" )
152-
153- resp , err := ht .ReceiveSendToRouteUpdate (alicePayStream )
154- require .NoError (ht , err , "unable to receive stream" )
155- require .Emptyf (ht , resp .PaymentError ,
156- "received payment error from %s: %v" ,
157- carol .Name (), resp .PaymentError )
158- }
159- }
106+ // Closure to send payments via the routerrpc server.
160107 sendToRouteRouterRPC := func () {
161108 for i , rHash := range rHashes {
162109 setMPPFields (i )
@@ -172,19 +119,8 @@ func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
172119 }
173120
174121 // Using Carol as the node as the source, send the payments
175- // synchronously via the routerrpc's SendToRoute, or via the main RPC
176- // server's SendToRoute streaming or sync calls.
177- switch {
178- case ! useRPC && useStream :
179- sendToRouteStream ()
180- case ! useRPC && ! useStream :
181- sendToRouteSync ()
182- case useRPC && ! useStream :
183- sendToRouteRouterRPC ()
184- default :
185- require .Fail (ht , "routerrpc does not support " +
186- "streaming send_to_route" )
187- }
122+ // synchronously via the routerrpc's SendToRouteV2 method.
123+ sendToRouteRouterRPC ()
188124
189125 // Verify that the payment's from Carol's PoV have the correct payment
190126 // hash and amount.
@@ -352,6 +288,7 @@ func runMultiHopSendToRoute(ht *lntest.HarnessTest, useGraphCache bool) {
352288 ),
353289 }
354290
291+ // Using Alice as the source, pay to the invoice from Bob.
355292 sendReq := & routerrpc.SendToRouteRequest {
356293 PaymentHash : rHash ,
357294 Route : route ,
@@ -432,21 +369,16 @@ func testSendToRouteErrorPropagation(ht *lntest.HarnessTest) {
432369 rHash := resp .RHash
433370
434371 // Using Alice as the source, pay to the invoice from Bob.
435- alicePayStream := alice .RPC .SendToRoute ()
436-
437- sendReq := & lnrpc.SendToRouteRequest {
372+ sendReq := & routerrpc.SendToRouteRequest {
438373 PaymentHash : rHash ,
439374 Route : fakeRoute .Routes [0 ],
440375 }
441- err := alicePayStream . Send (sendReq )
442- require .NoError (ht , err , "unable to send payment" )
376+ sendResp := alice . RPC . SendToRouteV2 (sendReq )
377+ require .Equal (ht , sendResp . Status , lnrpc . HTLCAttempt_FAILED )
443378
444379 // At this place we should get an rpc error with notification
445- // that edge is not found on hop(0)
446- event , err := ht .ReceiveSendToRouteUpdate (alicePayStream )
447- require .NoError (ht , err , "payment stream has been closed but fake " +
448- "route has consumed" )
449- require .Contains (ht , event .PaymentError , "UnknownNextPeer" )
380+ // that edge is not found on hop(0).
381+ require .Contains (ht , sendResp .Failure .String (), "UNKNOWN_NEXT_PEER" )
450382}
451383
452384// testPrivateChannels tests that a private channel can be used for
0 commit comments