Merge pull request #3558 from joostjager/non-strict-pathfinding

routing: non-strict path finding
This commit is contained in:
Joost Jager
2019-10-30 08:42:28 +01:00
committed by GitHub
6 changed files with 479 additions and 316 deletions

View File

@@ -3410,6 +3410,8 @@ func TestBuildRoute(t *testing.T) {
defer cleanUp()
checkHops := func(rt *route.Route, expected []uint64) {
t.Helper()
if len(rt.Hops) != len(expected) {
t.Fatal("hop count mismatch")
}
@@ -3437,10 +3439,10 @@ func TestBuildRoute(t *testing.T) {
}
// Check that we get the expected route back. The total amount should be
// the amount to deliver to hop c (100 sats) plus the fee for hop b (5
// sats).
checkHops(rt, []uint64{1, 2})
if rt.TotalAmount != 105000 {
// the amount to deliver to hop c (100 sats) plus the max fee for the
// connection b->c (6 sats).
checkHops(rt, []uint64{1, 7})
if rt.TotalAmount != 106000 {
t.Fatalf("unexpected total amount %v", rt.TotalAmount)
}
@@ -3453,11 +3455,11 @@ func TestBuildRoute(t *testing.T) {
}
// Check that we get the expected route back. The minimum that we can
// send from b to c is 20 sats. Hop b charges 1 sat for the forwarding.
// The channel between hop a and b can carry amounts in the range [5,
// 100], so 21 sats is the minimum amount for this route.
checkHops(rt, []uint64{1, 2})
if rt.TotalAmount != 21000 {
// send from b to c is 20 sats. Hop b charges 1200 msat for the
// forwarding. The channel between hop a and b can carry amounts in the
// range [5, 100], so 21200 msats is the minimum amount for this route.
checkHops(rt, []uint64{1, 7})
if rt.TotalAmount != 21200 {
t.Fatalf("unexpected total amount %v", rt.TotalAmount)
}