Skip to content

Commit 62dc746

Browse files
committed
test
1 parent 653fbc5 commit 62dc746

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

eclair-core/src/test/scala/fr/acinq/eclair/router/RouteCalculationSpec.scala

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,38 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution {
19161916
val route :: Nil = routes
19171917
assert(route2Ids(route) == 3 :: 4 :: Nil)
19181918
}
1919+
1920+
test("take past attempts into account") {
1921+
// C
1922+
// / \
1923+
// A -- B E
1924+
// \ /
1925+
// D
1926+
val g = GraphWithBalanceEstimates(DirectedGraph(List(
1927+
makeEdge(1L, a, b, 100 msat, 100, minHtlc = 1000 msat, capacity = 100000000 sat),
1928+
makeEdge(2L, b, c, 100 msat, 100, minHtlc = 1000 msat, capacity = 100000000 sat),
1929+
makeEdge(3L, c, e, 100 msat, 100, minHtlc = 1000 msat, capacity = 100000000 sat),
1930+
makeEdge(4L, b, d, 1000 msat, 1000, minHtlc = 1000 msat, capacity = 100000 sat),
1931+
makeEdge(5L, d, e, 1000 msat, 1000, minHtlc = 1000 msat, capacity = 100000 sat),
1932+
)), 1 day)
1933+
1934+
val amount = 50000 msat
1935+
1936+
val hc = HeuristicsConstants(
1937+
lockedFundsRisk = 0,
1938+
failureCost = RelayFees(1000 msat, 1000),
1939+
hopCost = RelayFees(500 msat, 200),
1940+
useLogProbability = true,
1941+
usePastRelaysData = true
1942+
)
1943+
val Success(route1 :: Nil) = findRoute(g, a, e, amount, 100000000 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.copy(heuristics = Right(hc), includeLocalChannelCost = true), currentBlockHeight = BlockHeight(400000))
1944+
assert(route2Ids(route1) == 1 :: 2 :: 3 :: Nil)
1945+
1946+
val h = g.routeCouldRelay(route1.stopAt(c)).channelCouldNotSend(route1.hops.last, amount)
1947+
1948+
val Success(route2 :: Nil) = findRoute(h, a, e, amount, 100000000 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.copy(heuristics = Right(hc), includeLocalChannelCost = true), currentBlockHeight = BlockHeight(400000))
1949+
assert(route2Ids(route2) == 1 :: 4 :: 5 :: Nil)
1950+
}
19191951
}
19201952

19211953
object RouteCalculationSpec {

0 commit comments

Comments
 (0)