Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
thomash-acinq committed Nov 12, 2024
1 parent 5fc7841 commit 9fe0f9e
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,38 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution {
val route :: Nil = routes
assert(route2Ids(route) == 3 :: 4 :: Nil)
}

test("take past attempts into account") {
// C
// / \
// A -- B E
// \ /
// D
val g = GraphWithBalanceEstimates(DirectedGraph(List(
makeEdge(1L, a, b, 100 msat, 100, minHtlc = 1000 msat, capacity = 100000000 sat),
makeEdge(2L, b, c, 100 msat, 100, minHtlc = 1000 msat, capacity = 100000000 sat),
makeEdge(3L, c, e, 100 msat, 100, minHtlc = 1000 msat, capacity = 100000000 sat),
makeEdge(4L, b, d, 1000 msat, 1000, minHtlc = 1000 msat, capacity = 100000 sat),
makeEdge(5L, d, e, 1000 msat, 1000, minHtlc = 1000 msat, capacity = 100000 sat),
)), 1 day)

val amount = 50000 msat

val hc = HeuristicsConstants(
lockedFundsRisk = 0,
failureCost = RelayFees(1000 msat, 1000),
hopCost = RelayFees(500 msat, 200),
useLogProbability = true,
usePastRelaysData = true
)
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))
assert(route2Ids(route1) == 1 :: 2 :: 3 :: Nil)

val h = g.routeCouldRelay(route1.stopAt(c)).channelCouldNotSend(route1.hops.last, amount)

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))
assert(route2Ids(route2) == 1 :: 4 :: 5 :: Nil)
}
}

object RouteCalculationSpec {
Expand Down

0 comments on commit 9fe0f9e

Please sign in to comment.