routing: move payment session constructor

This commit is contained in:
Joost Jager
2020-04-16 15:20:23 +02:00
parent eec3799da9
commit 6e8442b333
4 changed files with 73 additions and 52 deletions

View File

@ -13,9 +13,36 @@ func TestRequestRoute(t *testing.T) {
height = 10
)
findPath := func(
g *graphParams,
r *RestrictParams, cfg *PathFindingConfig,
cltvLimit := uint32(30)
finalCltvDelta := uint16(8)
payment := &LightningPayment{
CltvLimit: cltvLimit,
FinalCLTVDelta: finalCltvDelta,
Amount: 1000,
FeeLimit: 1000,
}
session, err := newPaymentSession(
payment,
func() (map[uint64]lnwire.MilliSatoshi,
error) {
return nil, nil
},
func() (routingGraph, func(), error) {
return &sessionGraph{}, func() {}, nil
},
&MissionControl{cfg: &MissionControlConfig{}},
PathFindingConfig{},
)
if err != nil {
t.Fatal(err)
}
// Override pathfinder with a mock.
session.pathFinder = func(
g *graphParams, r *RestrictParams, cfg *PathFindingConfig,
source, target route.Vertex, amt lnwire.MilliSatoshi,
finalHtlcExpiry int32) ([]*channeldb.ChannelEdgePolicy, error) {
@ -38,32 +65,6 @@ func TestRequestRoute(t *testing.T) {
return path, nil
}
cltvLimit := uint32(30)
finalCltvDelta := uint16(8)
payment := &LightningPayment{
CltvLimit: cltvLimit,
FinalCLTVDelta: finalCltvDelta,
Amount: 1000,
FeeLimit: 1000,
}
session := &paymentSession{
getBandwidthHints: func() (map[uint64]lnwire.MilliSatoshi,
error) {
return nil, nil
},
payment: payment,
pathFinder: findPath,
missionControl: &MissionControl{
cfg: &MissionControlConfig{},
},
getRoutingGraph: func() (routingGraph, func(), error) {
return &sessionGraph{}, func() {}, nil
},
}
route, err := session.RequestRoute(
payment.Amount, payment.FeeLimit, 0, height,
)