@@ -26,6 +26,7 @@ import fr.acinq.eclair.router.Graph.GraphStructure.DirectedGraph.graphEdgeToHop
2626import fr .acinq .eclair .router .Graph .GraphStructure .{DirectedGraph , GraphEdge }
2727import fr .acinq .eclair .router .Graph .{HeuristicsConstants , PaymentPathWeight }
2828import fr .acinq .eclair .router .RouteCalculation ._
29+ import fr .acinq .eclair .router .Router .MultiPartParams .{FullCapacity , MaxExpectedAmount , Randomize }
2930import fr .acinq .eclair .router .Router ._
3031import fr .acinq .eclair .transactions .Transactions
3132import fr .acinq .eclair .wire .protocol ._
@@ -766,6 +767,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution {
766767 .modify(_.boundaries.maxFeeFlat).setTo(7 msat)
767768 .modify(_.boundaries.maxFeeProportional).setTo(0 )
768769 .modify(_.randomize).setTo(true )
770+ .modify(_.mpp.splittingStrategy).setTo(Randomize )
769771 val strictFee = strictFeeParams.getMaxFee(DEFAULT_AMOUNT_MSAT )
770772 assert(strictFee == 7 .msat)
771773
@@ -914,7 +916,13 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution {
914916 checkRouteAmounts(routes, amount, 0 msat)
915917 }
916918 {
917- val Success (routes) = findMultiPartRoute(g, a, b, amount, 1 msat, routeParams = routeParams.copy(randomize = true ), currentBlockHeight = BlockHeight (400000 ))
919+ val Success (routes) = findMultiPartRoute(g, a, b, amount, 1 msat, routeParams = routeParams.copy(randomize = true ).modify(_.mpp.splittingStrategy).setTo(Randomize ), currentBlockHeight = BlockHeight (400000 ))
920+ assert(routes.length >= 4 , routes)
921+ assert(routes.forall(_.hops.length == 1 ), routes)
922+ checkRouteAmounts(routes, amount, 0 msat)
923+ }
924+ {
925+ val Success (routes) = findMultiPartRoute(g, a, b, amount, 1 msat, routeParams = routeParams.modify(_.mpp.splittingStrategy).setTo(MaxExpectedAmount ), currentBlockHeight = BlockHeight (400000 ))
918926 assert(routes.length >= 4 , routes)
919927 assert(routes.forall(_.hops.length == 1 ), routes)
920928 checkRouteAmounts(routes, amount, 0 msat)
@@ -977,7 +985,14 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution {
977985 checkRouteAmounts(routes, amount, 0 msat)
978986 }
979987 {
980- val Success (routes) = findMultiPartRoute(g, a, b, amount, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = true ), currentBlockHeight = BlockHeight (400000 ))
988+ val Success (routes) = findMultiPartRoute(g, a, b, amount, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = true ).modify(_.mpp.splittingStrategy).setTo(Randomize ), currentBlockHeight = BlockHeight (400000 ))
989+ assert(routes.length >= 3 , routes)
990+ assert(routes.forall(_.hops.length == 1 ), routes)
991+ checkIgnoredChannels(routes, 2L )
992+ checkRouteAmounts(routes, amount, 0 msat)
993+ }
994+ {
995+ val Success (routes) = findMultiPartRoute(g, a, b, amount, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS .modify(_.mpp.splittingStrategy).setTo(MaxExpectedAmount ), currentBlockHeight = BlockHeight (400000 ))
981996 assert(routes.length >= 3 , routes)
982997 assert(routes.forall(_.hops.length == 1 ), routes)
983998 checkIgnoredChannels(routes, 2L )
@@ -1087,7 +1102,11 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution {
10871102 assert(result == Failure (RouteNotFound ))
10881103 }
10891104 {
1090- val result = findMultiPartRoute(g, a, b, 40000 msat, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = true ), currentBlockHeight = BlockHeight (400000 ))
1105+ val result = findMultiPartRoute(g, a, b, 40000 msat, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = true ).modify(_.mpp.splittingStrategy).setTo(Randomize ), currentBlockHeight = BlockHeight (400000 ))
1106+ assert(result == Failure (RouteNotFound ))
1107+ }
1108+ {
1109+ val result = findMultiPartRoute(g, a, b, 40000 msat, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS .modify(_.mpp.splittingStrategy).setTo(MaxExpectedAmount ), currentBlockHeight = BlockHeight (400000 ))
10911110 assert(result == Failure (RouteNotFound ))
10921111 }
10931112 }
@@ -1116,7 +1135,11 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution {
11161135 assert(result == Failure (RouteNotFound ))
11171136 }
11181137 {
1119- val result = findMultiPartRoute(g, a, b, 10000 msat, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = true ), currentBlockHeight = BlockHeight (400000 ))
1138+ val result = findMultiPartRoute(g, a, b, 10000 msat, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = true ).modify(_.mpp.splittingStrategy).setTo(Randomize ), currentBlockHeight = BlockHeight (400000 ))
1139+ assert(result == Failure (RouteNotFound ))
1140+ }
1141+ {
1142+ val result = findMultiPartRoute(g, a, b, 10000 msat, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS .modify(_.mpp.splittingStrategy).setTo(MaxExpectedAmount ), currentBlockHeight = BlockHeight (400000 ))
11201143 assert(result == Failure (RouteNotFound ))
11211144 }
11221145 }
@@ -1152,7 +1175,11 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution {
11521175 }
11531176 {
11541177 // Randomize routes.
1155- val Success (routes) = findMultiPartRoute(g, a, e, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = true ), currentBlockHeight = BlockHeight (400000 ))
1178+ val Success (routes) = findMultiPartRoute(g, a, e, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = true ).modify(_.mpp.splittingStrategy).setTo(Randomize ), currentBlockHeight = BlockHeight (400000 ))
1179+ checkRouteAmounts(routes, amount, maxFee)
1180+ }
1181+ {
1182+ val Success (routes) = findMultiPartRoute(g, a, e, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS .modify(_.mpp.splittingStrategy).setTo(MaxExpectedAmount ), currentBlockHeight = BlockHeight (400000 ))
11561183 checkRouteAmounts(routes, amount, maxFee)
11571184 }
11581185 {
@@ -1242,7 +1269,11 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution {
12421269 }
12431270 {
12441271 // Randomize routes.
1245- val Success (routes) = findMultiPartRoute(g, a, f, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = true ), currentBlockHeight = BlockHeight (400000 ))
1272+ val Success (routes) = findMultiPartRoute(g, a, f, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = true ).modify(_.mpp.splittingStrategy).setTo(Randomize ), currentBlockHeight = BlockHeight (400000 ))
1273+ checkRouteAmounts(routes, amount, maxFee)
1274+ }
1275+ {
1276+ val Success (routes) = findMultiPartRoute(g, a, f, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS .modify(_.mpp.splittingStrategy).setTo(MaxExpectedAmount ), currentBlockHeight = BlockHeight (400000 ))
12461277 checkRouteAmounts(routes, amount, maxFee)
12471278 }
12481279 {
@@ -1300,22 +1331,22 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution {
13001331 {
13011332 val amount = 15_000_000 msat
13021333 val maxFee = 50_000 msat // this fee is enough to go through the preferred route
1303- val routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = false , mpp = MultiPartParams (50_000 msat, 5 , DEFAULT_ROUTE_PARAMS .mpp.splittingStrategy ))
1334+ val routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = false , mpp = MultiPartParams (50_000 msat, 5 , FullCapacity ))
13041335 val Success (routes) = findMultiPartRoute(g, a, d, amount, maxFee, routeParams = routeParams, currentBlockHeight = BlockHeight (400000 ))
13051336 checkRouteAmounts(routes, amount, maxFee)
13061337 assert(routes2Ids(routes) == Set (Seq (100L , 101L )))
13071338 }
13081339 {
13091340 val amount = 15_000_000 msat
13101341 val maxFee = 10_000 msat // this fee is too low to go through the preferred route
1311- val routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = false , mpp = MultiPartParams (50_000 msat, 5 , DEFAULT_ROUTE_PARAMS .mpp.splittingStrategy ))
1342+ val routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = false , mpp = MultiPartParams (50_000 msat, 5 , FullCapacity ))
13121343 val failure = findMultiPartRoute(g, a, d, amount, maxFee, routeParams = routeParams, currentBlockHeight = BlockHeight (400000 ))
13131344 assert(failure == Failure (RouteNotFound ))
13141345 }
13151346 {
13161347 val amount = 5_000_000 msat
13171348 val maxFee = 10_000 msat // this fee is enough to go through the preferred route, but the cheaper ones can handle it
1318- val routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = false , mpp = MultiPartParams (50_000 msat, 5 , DEFAULT_ROUTE_PARAMS .mpp.splittingStrategy ))
1349+ val routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = false , mpp = MultiPartParams (50_000 msat, 5 , FullCapacity ))
13191350 val Success (routes) = findMultiPartRoute(g, a, d, amount, maxFee, routeParams = routeParams, currentBlockHeight = BlockHeight (400000 ))
13201351 assert(routes.length == 5 )
13211352 routes.foreach(route => {
@@ -1429,7 +1460,12 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution {
14291460 }
14301461 {
14311462 val (amount, maxFee) = (40000 msat, 100 msat)
1432- val Success (routes) = findMultiPartRoute(g, d, f, amount, maxFee, routeParams = routeParams.copy(randomize = true ), currentBlockHeight = BlockHeight (400000 ))
1463+ val Success (routes) = findMultiPartRoute(g, d, f, amount, maxFee, routeParams = routeParams.copy(randomize = true ).modify(_.mpp.splittingStrategy).setTo(Randomize ), currentBlockHeight = BlockHeight (400000 ))
1464+ checkRouteAmounts(routes, amount, maxFee)
1465+ }
1466+ {
1467+ val (amount, maxFee) = (40000 msat, 100 msat)
1468+ val Success (routes) = findMultiPartRoute(g, d, f, amount, maxFee, routeParams = routeParams.modify(_.mpp.splittingStrategy).setTo(MaxExpectedAmount ), currentBlockHeight = BlockHeight (400000 ))
14331469 checkRouteAmounts(routes, amount, maxFee)
14341470 }
14351471 {
@@ -1528,7 +1564,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution {
15281564 makeEdge(9L , c, f, Random .nextLong(250 ).msat, Random .nextInt(10000 ), minHtlc = Random .nextLong(100 ).msat, maxHtlc = Some ((20000 + Random .nextLong(80000 )).msat), CltvExpiryDelta (Random .nextInt(288 )), capacity = (10 + Random .nextLong(100 )).sat)
15291565 )), 1 day)
15301566
1531- findMultiPartRoute(g, d, f, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = true ), currentBlockHeight = BlockHeight (400000 )) match {
1567+ findMultiPartRoute(g, d, f, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS .copy(randomize = true ).modify(_.mpp.splittingStrategy).setTo( Randomize ) , currentBlockHeight = BlockHeight (400000 )) match {
15321568 case Success (routes) => checkRouteAmounts(routes, amount, maxFee)
15331569 case Failure (ex) => assert(ex == RouteNotFound )
15341570 }
@@ -1949,7 +1985,7 @@ object RouteCalculationSpec {
19491985 randomize = false ,
19501986 boundaries = SearchBoundaries (21000 msat, 0.03 , 6 , CltvExpiryDelta (2016 )),
19511987 NO_WEIGHT_RATIOS ,
1952- MultiPartParams (1000 msat, 10 , MultiPartParams . FullCapacity ),
1988+ MultiPartParams (1000 msat, 10 , FullCapacity ),
19531989 experimentName = " my-test-experiment" ,
19541990 experimentPercentage = 100 ).getDefaultRouteParams
19551991
0 commit comments