@@ -76,7 +76,7 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
76
76
override implicit val mat : Materializer = materializer
77
77
}
78
78
79
- def mockApi (eclair: Eclair = mock[Eclair ]): MockService = {
79
+ def mockApi (eclair : Eclair = mock[Eclair ]): MockService = {
80
80
new MockService (eclair)
81
81
}
82
82
@@ -122,7 +122,7 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
122
122
test(" API returns invalid channelId on invalid channelId form data" ) {
123
123
Post (" /channel" , FormData (Map (" channelId" -> " hey" )).toEntity) ~>
124
124
addCredentials(BasicHttpCredentials (" " , mockApi().password)) ~>
125
- Route .seal(mockApi().channel ) ~>
125
+ Route .seal(mockApi().route ) ~>
126
126
check {
127
127
assert(handled)
128
128
assert(status == BadRequest )
@@ -247,6 +247,17 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
247
247
assert(entityAs[String ] == " \" created channel 56d7d6eda04d80138270c49709f1eadb5ab4939e5061309ccdacdb98ce637d0e\" " )
248
248
eclair.open(nodeId, 50000 sat, None , None , Some (100 msat, 10 ), None , None )(any[Timeout ]).wasCalled(once)
249
249
}
250
+
251
+ Post (" /open" , FormData (" nodeId" -> nodeId.toString(), " fundingSatoshis" -> " 25000" , " feeBaseMsat" -> " 250" , " feeProportionalMillionths" -> " 10" ).toEntity) ~>
252
+ addCredentials(BasicHttpCredentials (" " , mockApi().password)) ~>
253
+ addHeader(" Content-Type" , " application/json" ) ~>
254
+ Route .seal(mockService.route) ~>
255
+ check {
256
+ assert(handled)
257
+ assert(status == OK )
258
+ assert(entityAs[String ] == " \" created channel 56d7d6eda04d80138270c49709f1eadb5ab4939e5061309ccdacdb98ce637d0e\" " )
259
+ eclair.open(nodeId, 25000 sat, None , None , Some (250 msat, 10 ), None , None )(any[Timeout ]).wasCalled(once)
260
+ }
250
261
}
251
262
252
263
test(" 'close' method should accept channelIds and shortChannelIds" ) {
@@ -338,7 +349,7 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
338
349
339
350
Post (" /payinvoice" , FormData (" invoice" -> invoice).toEntity) ~>
340
351
addCredentials(BasicHttpCredentials (" " , mockApi().password)) ~>
341
- Route .seal(mockService.payInvoice ) ~>
352
+ Route .seal(mockService.route ) ~>
342
353
check {
343
354
assert(handled)
344
355
assert(status == BadRequest )
@@ -372,6 +383,15 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
372
383
assert(status == OK )
373
384
eclair.send(Some (" 42" ), any, 123 msat, any, any, any, Some (112233 sat), Some (2.34 ))(any[Timeout ]).wasCalled(once)
374
385
}
386
+
387
+ Post (" /payinvoice" , FormData (" invoice" -> invoice, " amountMsat" -> " 456" , " feeThresholdSat" -> " 10" , " maxFeePct" -> " 0.5" ).toEntity) ~>
388
+ addCredentials(BasicHttpCredentials (" " , mockApi().password)) ~>
389
+ Route .seal(mockService.route) ~>
390
+ check {
391
+ assert(handled)
392
+ assert(status == OK )
393
+ eclair.send(None , any, 456 msat, any, any, any, Some (10 sat), Some (0.5 ))(any[Timeout ]).wasCalled(once)
394
+ }
375
395
}
376
396
377
397
test(" 'getreceivedinfo'" ) {
@@ -412,7 +432,7 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
412
432
413
433
Post (" /getreceivedinfo" , FormData (" paymentHash" -> expired.toHex).toEntity) ~>
414
434
addCredentials(BasicHttpCredentials (" " , mockApi().password)) ~>
415
- Route .seal(mockService.getReceivedInfo ) ~>
435
+ Route .seal(mockService.route ) ~>
416
436
check {
417
437
assert(handled)
418
438
assert(status == OK )
@@ -457,7 +477,7 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
457
477
458
478
Post (" /getsentinfo" , FormData (" id" -> failed.toString).toEntity) ~>
459
479
addCredentials(BasicHttpCredentials (" " , mockApi().password)) ~>
460
- Route .seal(mockService.getSentInfo ) ~>
480
+ Route .seal(mockService.route ) ~>
461
481
check {
462
482
assert(handled)
463
483
assert(status == OK )
0 commit comments