routing: use routingGraph interface in payment session

Preparation for more test coverage of payment session.

The function findPath now has the call signature of the former
findPathInternal function.
This commit is contained in:
Joost Jager
2020-03-17 11:32:07 +01:00
parent cb4cd49dc8
commit 47f9c1c3fd
9 changed files with 155 additions and 146 deletions

View File

@ -13,10 +13,11 @@ func TestRequestRoute(t *testing.T) {
height = 10
)
findPath := func(g *graphParams, r *RestrictParams,
cfg *PathFindingConfig, source, target route.Vertex,
amt lnwire.MilliSatoshi, finalHtlcExpiry int32) (
[]*channeldb.ChannelEdgePolicy, error) {
findPath := func(
g *graphParams,
r *RestrictParams, cfg *PathFindingConfig,
source, target route.Vertex, amt lnwire.MilliSatoshi,
finalHtlcExpiry int32) ([]*channeldb.ChannelEdgePolicy, error) {
// We expect find path to receive a cltv limit excluding the
// final cltv delta (including the block padding).
@ -37,13 +38,6 @@ func TestRequestRoute(t *testing.T) {
return path, nil
}
sessionSource := &SessionSource{
SelfNode: &channeldb.LightningNode{},
MissionControl: &MissionControl{
cfg: &MissionControlConfig{},
},
}
cltvLimit := uint32(30)
finalCltvDelta := uint16(8)
@ -60,9 +54,14 @@ func TestRequestRoute(t *testing.T) {
return nil, nil
},
sessionSource: sessionSource,
payment: payment,
pathFinder: findPath,
payment: payment,
pathFinder: findPath,
missionControl: &MissionControl{
cfg: &MissionControlConfig{},
},
getRoutingGraph: func() (routingGraph, func(), error) {
return &sessionGraph{}, func() {}, nil
},
}
route, err := session.RequestRoute(
@ -79,3 +78,11 @@ func TestRequestRoute(t *testing.T) {
route.TotalTimeLock)
}
}
type sessionGraph struct {
routingGraph
}
func (g *sessionGraph) sourceNode() route.Vertex {
return route.Vertex{}
}