7133f37bb8
Previously every payment had its own local mission control state which was in effect only for that payment. In this commit most of the local state is removed and payments all tap into the global mission control probability estimator. Furthermore the decay time of pruned edges and nodes is extended, so that observations about the network can better benefit future payment processes. Last, the probability function is transformed from a binary output to a gradual curve, allowing for a better trade off between candidate routes.
61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
package routing
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/lightningnetwork/lnd/channeldb"
|
|
"github.com/lightningnetwork/lnd/lnwire"
|
|
"github.com/lightningnetwork/lnd/routing/route"
|
|
)
|
|
|
|
func TestRequestRoute(t *testing.T) {
|
|
const (
|
|
height = 10
|
|
)
|
|
|
|
findPath := func(g *graphParams, r *RestrictParams,
|
|
source, target route.Vertex, amt lnwire.MilliSatoshi) (
|
|
[]*channeldb.ChannelEdgePolicy, error) {
|
|
|
|
// We expect find path to receive a cltv limit excluding the
|
|
// final cltv delta.
|
|
if *r.CltvLimit != 22 {
|
|
t.Fatal("wrong cltv limit")
|
|
}
|
|
|
|
path := []*channeldb.ChannelEdgePolicy{
|
|
{
|
|
Node: &channeldb.LightningNode{},
|
|
},
|
|
}
|
|
|
|
return path, nil
|
|
}
|
|
|
|
session := &paymentSession{
|
|
mc: &MissionControl{
|
|
selfNode: &channeldb.LightningNode{},
|
|
},
|
|
pathFinder: findPath,
|
|
}
|
|
|
|
cltvLimit := uint32(30)
|
|
finalCltvDelta := uint16(8)
|
|
|
|
payment := &LightningPayment{
|
|
CltvLimit: &cltvLimit,
|
|
FinalCLTVDelta: &finalCltvDelta,
|
|
}
|
|
|
|
route, err := session.RequestRoute(payment, height, finalCltvDelta)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// We expect an absolute route lock value of height + finalCltvDelta
|
|
if route.TotalTimeLock != 18 {
|
|
t.Fatalf("unexpected total time lock of %v",
|
|
route.TotalTimeLock)
|
|
}
|
|
}
|