routing/test: use payment session in integrated routing test

Cover the payment session in the integrated routing test as a
preparation for executing the upcoming mpp split logic as part of the
test.
This commit is contained in:
Joost Jager 2020-03-17 11:53:29 +01:00
parent 47f9c1c3fd
commit b13616a593
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -95,10 +95,31 @@ func (c *integratedRoutingContext) testPayment(expectedNofAttempts int) {
c.t.Fatal(err) c.t.Fatal(err)
} }
// Instruct pathfinding to use mission control as a probabiltiy source. getBandwidthHints := func() (map[uint64]lnwire.MilliSatoshi, error) {
restrictParams := RestrictParams{ // Create bandwidth hints based on local channel balances.
ProbabilitySource: mc.GetProbability, bandwidthHints := map[uint64]lnwire.MilliSatoshi{}
FeeLimit: lnwire.MaxMilliSatoshi, for _, ch := range c.graph.nodes[c.source.pubkey].channels {
bandwidthHints[ch.id] = ch.balance
}
return bandwidthHints, nil
}
payment := LightningPayment{
FinalCLTVDelta: uint16(c.finalExpiry),
FeeLimit: lnwire.MaxMilliSatoshi,
Target: c.target.pubkey,
}
session := &paymentSession{
getBandwidthHints: getBandwidthHints,
payment: &payment,
pathFinder: findPath,
getRoutingGraph: func() (routingGraph, func(), error) {
return c.graph, func() {}, nil
},
pathFindingConfig: c.pathFindingCfg,
missionControl: mc,
} }
// Now the payment control loop starts. It will keep trying routes until // Now the payment control loop starts. It will keep trying routes until
@ -111,30 +132,13 @@ func (c *integratedRoutingContext) testPayment(expectedNofAttempts int) {
} }
// Find a route. // Find a route.
path, err := findPath( route, err := session.RequestRoute(
&graphParams{ c.amt, lnwire.MaxMilliSatoshi, 0, 0,
graph: c.graph,
bandwidthHints: bandwidthHints,
},
&restrictParams,
&c.pathFindingCfg,
c.source.pubkey, c.target.pubkey,
c.amt, c.finalExpiry,
) )
if err != nil { if err != nil {
c.t.Fatal(err) c.t.Fatal(err)
} }
finalHop := finalHopParams{
amt: c.amt,
cltvDelta: uint16(c.finalExpiry),
}
route, err := newRoute(c.source.pubkey, path, 0, finalHop)
if err != nil {
c.t.Fatal(err)
}
// Send out the htlc on the mock graph. // Send out the htlc on the mock graph.
pid := nextPid pid := nextPid
nextPid++ nextPid++