-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2640 from joostjager/cltv-limit
routing: add cltv limit
- Loading branch information
Showing
12 changed files
with
842 additions
and
592 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package routing | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/lightningnetwork/lnd/channeldb" | ||
"github.com/lightningnetwork/lnd/lnwire" | ||
) | ||
|
||
func TestRequestRoute(t *testing.T) { | ||
const ( | ||
height = 10 | ||
) | ||
|
||
findPath := func(g *graphParams, r *RestrictParams, | ||
source, target 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{}, | ||
}, | ||
pruneViewSnapshot: graphPruneView{}, | ||
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.