@@ -21,25 +21,10 @@ import (
21
21
)
22
22
23
23
var 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
- },
38
24
{
39
25
Name : "single hop with v2" ,
40
26
TestFunc : func (ht * lntest.HarnessTest ) {
41
- // useStream: false, routerrpc: true.
42
- testSingleHopSendToRouteCase (ht , false , true )
27
+ testSingleHopSendToRouteCase (ht )
43
28
},
44
29
},
45
30
}
@@ -50,12 +35,11 @@ var sendToRouteTestCases = []*lntest.TestCase{
50
35
//
51
36
// Carol --100k--> Dave
52
37
//
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 ) {
59
43
60
44
const chanAmt = btcutil .Amount (100000 )
61
45
const paymentAmtSat = 1000
@@ -119,44 +103,7 @@ func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
119
103
}
120
104
}
121
105
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.
160
107
sendToRouteRouterRPC := func () {
161
108
for i , rHash := range rHashes {
162
109
setMPPFields (i )
@@ -172,19 +119,8 @@ func testSingleHopSendToRouteCase(ht *lntest.HarnessTest,
172
119
}
173
120
174
121
// 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 ()
188
124
189
125
// Verify that the payment's from Carol's PoV have the correct payment
190
126
// hash and amount.
@@ -352,6 +288,7 @@ func runMultiHopSendToRoute(ht *lntest.HarnessTest, useGraphCache bool) {
352
288
),
353
289
}
354
290
291
+ // Using Alice as the source, pay to the invoice from Bob.
355
292
sendReq := & routerrpc.SendToRouteRequest {
356
293
PaymentHash : rHash ,
357
294
Route : route ,
@@ -432,21 +369,16 @@ func testSendToRouteErrorPropagation(ht *lntest.HarnessTest) {
432
369
rHash := resp .RHash
433
370
434
371
// 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 {
438
373
PaymentHash : rHash ,
439
374
Route : fakeRoute .Routes [0 ],
440
375
}
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 )
443
378
444
379
// 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" )
450
382
}
451
383
452
384
// testPrivateChannels tests that a private channel can be used for
0 commit comments