@@ -33,13 +33,21 @@ class DummyEclairClient(
3333 private val getinvoiceResponse : String = validGetInvoiceResponse,
3434 private val listinvoicesResponse : String = validListInvoicesResponse,
3535 private val listpendinginvoicesResponse : String = validListPendingInvoicesResponse,
36- private val findrouteResponse : String = validFindRouteResponse,
37- private val findroutetonodeResponse : String = validFindRouteToNodeResponse,
38- private val findroutebetweennodesResponse : String = validFindRouteBetweenNodesResponse,
36+ private val findrouteResponseNodeId : String = validRouteResponseNodeId,
37+ private val findrouteResponseShortChannelId : String = validRouteResponseShortChannelId,
38+ private val findrouteResponseFull : String = validRouteResponseFull,
39+ private val findroutetonodeResponseNodeId : String = validRouteResponseNodeId,
40+ private val findroutetonodeResponseShortChannelId : String = validRouteResponseShortChannelId,
41+ private val findroutetonodeResponseFull : String = validRouteResponseFull,
42+ private val findroutebetweennodesResponseNodeId : String = validRouteResponseNodeId,
43+ private val findroutebetweennodesResponseShortChannelId : String = validRouteResponseShortChannelId,
44+ private val findroutebetweennodesResponseFull : String = validRouteResponseFull,
3945) : IEclairClient, IEclairClientBuilder {
4046 override fun build (apiHost : String , apiPassword : String ): IEclairClient = this
4147 override suspend fun getInfo (): Either <ApiError , String > = Either .Right (getInfoResponse)
42- override suspend fun connect (target : ConnectionTarget ): Either <ApiError , String > = Either .Right (validConnectResponse)
48+ override suspend fun connect (target : ConnectionTarget ): Either <ApiError , String > =
49+ Either .Right (validConnectResponse)
50+
4351 override suspend fun rbfopen (
4452 channelId : String ,
4553 targetFeerateSatByte : Int ,
@@ -104,7 +112,8 @@ class DummyEclairClient(
104112 paymentPreimage : String?
105113 ): Either <ApiError , String > = Either .Right (createInvoiceResponse)
106114
107- override suspend fun deleteinvoice (paymentHash : String ): Either <ApiError , String > = Either .Right (deleteInvoiceResponse)
115+ override suspend fun deleteinvoice (paymentHash : String ): Either <ApiError , String > =
116+ Either .Right (deleteInvoiceResponse)
108117
109118 override suspend fun parseinvoice (invoice : String ): Either <ApiError , String > = Either .Right (parseInvoiceResponse)
110119
@@ -181,7 +190,14 @@ class DummyEclairClient(
181190 maxFeeMsat : Int? ,
182191 includeLocalChannelCost : Boolean? ,
183192 pathFindingExperimentName : String?
184- ): Either <ApiError , String > = Either .Right (findrouteResponse)
193+ ): Either <ApiError , String > {
194+ return when (format) {
195+ " nodeId" -> Either .Right (findrouteResponseNodeId)
196+ " shortChannelId" -> Either .Right (findrouteResponseShortChannelId)
197+ " full" -> Either .Right (findrouteResponseFull)
198+ else -> Either .Right (findrouteResponseNodeId)
199+ }
200+ }
185201
186202 override suspend fun findroutetonode (
187203 nodeId : String ,
@@ -192,7 +208,14 @@ class DummyEclairClient(
192208 maxFeeMsat : Int? ,
193209 includeLocalChannelCost : Boolean? ,
194210 pathFindingExperimentName : String?
195- ): Either <ApiError , String > = Either .Right (findroutetonodeResponse)
211+ ): Either <ApiError , String > {
212+ return when (format) {
213+ " nodeId" -> Either .Right (findrouteResponseNodeId)
214+ " shortChannelId" -> Either .Right (findrouteResponseShortChannelId)
215+ " full" -> Either .Right (findrouteResponseFull)
216+ else -> Either .Right (findrouteResponseNodeId)
217+ }
218+ }
196219
197220 override suspend fun findroutebetweennodes (
198221 sourceNodeId : String ,
@@ -204,7 +227,14 @@ class DummyEclairClient(
204227 maxFeeMsat : Int? ,
205228 includeLocalChannelCost : Boolean? ,
206229 pathFindingExperimentName : String?
207- ): Either <ApiError , String > = Either .Right (findroutebetweennodesResponse)
230+ ): Either <ApiError , String > {
231+ return when (format) {
232+ " nodeId" -> Either .Right (findrouteResponseNodeId)
233+ " shortChannelId" -> Either .Right (findrouteResponseShortChannelId)
234+ " full" -> Either .Right (findrouteResponseFull)
235+ else -> Either .Right (findrouteResponseNodeId)
236+ }
237+ }
208238
209239 companion object {
210240 val validGetInfoResponse =
@@ -422,7 +452,8 @@ class DummyEclairClient(
422452 },
423453 "routingInfo": []
424454}"""
425- val validDeleteInvoiceResponse = " deleted invoice 6f0864735283ca95eaf9c50ef77893f55ee3dd11cb90710cbbfb73f018798a68"
455+ val validDeleteInvoiceResponse =
456+ " deleted invoice 6f0864735283ca95eaf9c50ef77893f55ee3dd11cb90710cbbfb73f018798a68"
426457 val validParseInvoiceResponse = """ {
427458 "prefix": "lnbcrt",
428459 "timestamp": 1643718891,
@@ -793,7 +824,31 @@ class DummyEclairClient(
793824 "routingInfo": []
794825 }
795826]"""
796- val validFindRouteResponse = """ {
827+ val validRouteResponseNodeId = """ {
828+ "routes": [
829+ {
830+ "amount": 5000,
831+ "nodeIds": [
832+ "036d65409c41ab7380a43448f257809e7496b52bf92057c09c4f300cbd61c50d96",
833+ "03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f",
834+ "03d06758583bb5154774a6eb221b1276c9e82d65bbaceca806d90e20c108f4b1c7"
835+ ]
836+ }
837+ ]
838+ }"""
839+ val validRouteResponseShortChannelId = """ {
840+ "routes": [
841+ {
842+ "amount": 5000,
843+ "shortChannelIds": [
844+ "11203x1x0",
845+ "11203x7x5",
846+ "11205x3x3"
847+ ]
848+ }
849+ ]
850+ }"""
851+ val validRouteResponseFull = """ {
797852 "type": "types.FindRouteResponse",
798853 "routes": [
799854 {
@@ -904,30 +959,6 @@ class DummyEclairClient(
904959 ]
905960}
906961"""
907- val validFindRouteToNodeResponse = """ {
908- "routes": [
909- {
910- "amount": 5000,
911- "nodeIds": [
912- "036d65409c41ab7380a43448f257809e7496b52bf92057c09c4f300cbd61c50d96",
913- "03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f",
914- "03d06758583bb5154774a6eb221b1276c9e82d65bbaceca806d90e20c108f4b1c7"
915- ]
916- }
917- ]
918- }"""
919- val validFindRouteBetweenNodesResponse = """ {
920- "routes": [
921- {
922- "amount": 5000,
923- "nodeIds": [
924- "036d65409c41ab7380a43448f257809e7496b52bf92057c09c4f300cbd61c50d96",
925- "03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f",
926- "03d06758583bb5154774a6eb221b1276c9e82d65bbaceca806d90e20c108f4b1c7"
927- ]
928- }
929- ]
930- }"""
931962 }
932963}
933964
@@ -1037,17 +1068,21 @@ class FailingEclairClient(private val error: ApiError) : IEclairClient, IEclairC
10371068 externalId : String?
10381069 ): Either <ApiError , String > = Either .Left (error)
10391070
1040- override suspend fun getsentinfo (paymentHash : String , id : String? ): Either <ApiError , String > = Either .Left (error)
1071+ override suspend fun getsentinfo (paymentHash : String , id : String? ): Either <ApiError , String > = Either .Left (error)
10411072
1042- override suspend fun getreceivedinfo (paymentHash : String? , invoice : String? ): Either <ApiError , String > = Either .Left (error)
1073+ override suspend fun getreceivedinfo (paymentHash : String? , invoice : String? ): Either <ApiError , String > =
1074+ Either .Left (error)
10431075
1044- override suspend fun listreceivedpayments (from : Int? , to : Int? , count : Int? , skip : Int? ): Either <ApiError , String > = Either .Left (error)
1076+ override suspend fun listreceivedpayments (from : Int? , to : Int? , count : Int? , skip : Int? ): Either <ApiError , String > =
1077+ Either .Left (error)
10451078
10461079 override suspend fun getinvoice (paymentHash : String ): Either <ApiError , String > = Either .Left (error)
10471080
1048- override suspend fun listinvoices (from : Int? , to : Int? , count : Int? , skip : Int? ): Either <ApiError , String > = Either .Left (error)
1081+ override suspend fun listinvoices (from : Int? , to : Int? , count : Int? , skip : Int? ): Either <ApiError , String > =
1082+ Either .Left (error)
10491083
1050- override suspend fun listpendinginvoices (from : Int? , to : Int? , count : Int? , skip : Int? ): Either <ApiError , String > = Either .Left (error)
1084+ override suspend fun listpendinginvoices (from : Int? , to : Int? , count : Int? , skip : Int? ): Either <ApiError , String > =
1085+ Either .Left (error)
10511086
10521087 override suspend fun findroute (
10531088 invoice : String ,
0 commit comments