routing: update test to account for proper time locks
This commit is contained in:
parent
67f17b319a
commit
8c3441b30f
@ -310,6 +310,7 @@ func TestBasicGraphPathFinding(t *testing.T) {
|
|||||||
// the pre-generated graph. Consult the testdata/basic_graph.json file
|
// the pre-generated graph. Consult the testdata/basic_graph.json file
|
||||||
// to follow along with the assumptions we'll use to test the path
|
// to follow along with the assumptions we'll use to test the path
|
||||||
// finding.
|
// finding.
|
||||||
|
const startingHeight = 100
|
||||||
|
|
||||||
const paymentAmt = btcutil.Amount(100)
|
const paymentAmt = btcutil.Amount(100)
|
||||||
target := aliases["sophon"]
|
target := aliases["sophon"]
|
||||||
@ -318,7 +319,7 @@ func TestBasicGraphPathFinding(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to find path: %v", err)
|
t.Fatalf("unable to find path: %v", err)
|
||||||
}
|
}
|
||||||
route, err := newRoute(paymentAmt, path)
|
route, err := newRoute(paymentAmt, path, startingHeight)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create path: %v", err)
|
t.Fatalf("unable to create path: %v", err)
|
||||||
}
|
}
|
||||||
@ -330,8 +331,9 @@ func TestBasicGraphPathFinding(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// As each hop only decrements a single block from the time-lock, the
|
// As each hop only decrements a single block from the time-lock, the
|
||||||
// total time lock value should be two.
|
// total time lock value should two more than our starting block
|
||||||
if route.TotalTimeLock != 2 {
|
// height.
|
||||||
|
if route.TotalTimeLock != 102 {
|
||||||
t.Fatalf("expected time lock of %v, instead have %v", 2,
|
t.Fatalf("expected time lock of %v, instead have %v", 2,
|
||||||
route.TotalTimeLock)
|
route.TotalTimeLock)
|
||||||
}
|
}
|
||||||
@ -375,7 +377,7 @@ func TestBasicGraphPathFinding(t *testing.T) {
|
|||||||
|
|
||||||
// We'll also assert that the outgoing CLTV value for each hop was set
|
// We'll also assert that the outgoing CLTV value for each hop was set
|
||||||
// accordingly.
|
// accordingly.
|
||||||
if route.Hops[0].OutgoingTimeLock != 1 {
|
if route.Hops[0].OutgoingTimeLock != 101 {
|
||||||
t.Fatalf("expected outgoing time-lock of %v, instead have %v",
|
t.Fatalf("expected outgoing time-lock of %v, instead have %v",
|
||||||
1, route.Hops[0].OutgoingTimeLock)
|
1, route.Hops[0].OutgoingTimeLock)
|
||||||
}
|
}
|
||||||
@ -413,7 +415,7 @@ func TestBasicGraphPathFinding(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to find route: %v", err)
|
t.Fatalf("unable to find route: %v", err)
|
||||||
}
|
}
|
||||||
route, err = newRoute(paymentAmt, path)
|
route, err = newRoute(paymentAmt, path, startingHeight)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create path: %v", err)
|
t.Fatalf("unable to create path: %v", err)
|
||||||
}
|
}
|
||||||
@ -426,8 +428,8 @@ func TestBasicGraphPathFinding(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// As we have a direct path, the total time lock value should be
|
// As we have a direct path, the total time lock value should be
|
||||||
// exactly one.
|
// exactly the current block height plus one.
|
||||||
if route.TotalTimeLock != 1 {
|
if route.TotalTimeLock != 101 {
|
||||||
t.Fatalf("expected time lock of %v, instead have %v", 1,
|
t.Fatalf("expected time lock of %v, instead have %v", 1,
|
||||||
route.TotalTimeLock)
|
route.TotalTimeLock)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user