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:
parent
47f9c1c3fd
commit
b13616a593
@ -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++
|
||||||
|
Loading…
Reference in New Issue
Block a user