routing/test: allow arbitrary graph source nodes
This commit is contained in:
2 files changed
+40
-17
No files matched your search
+24
-11
@@ -386,7 +386,9 @@ type testGraphInstance struct {
|
||||
// a deterministical way and added to the channel graph. A list of nodes is
|
||||
// not required and derived from the channel data. The goal is to keep
|
||||
// instantiating a test channel graph as light weight as possible.
|
||||
func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstance, error) {
|
||||
func createTestGraphFromChannels(testChannels []*testChannel, source string) (
|
||||
*testGraphInstance, error) {
|
||||
|
||||
// We'll use this fake address for the IP address of all the nodes in
|
||||
// our tests. This value isn't needed for path finding so it doesn't
|
||||
// need to be unique.
|
||||
@@ -444,13 +446,13 @@ func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstanc
|
||||
return dbNode, nil
|
||||
}
|
||||
|
||||
var source *channeldb.LightningNode
|
||||
if source, err = addNodeWithAlias("roasbeef"); err != nil {
|
||||
// Add the source node.
|
||||
dbNode, err := addNodeWithAlias(source)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Set the source node
|
||||
if err := graph.SetSourceNode(source); err != nil {
|
||||
if err = graph.SetSourceNode(dbNode); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -464,7 +466,10 @@ func createTestGraphFromChannels(testChannels []*testChannel) (*testGraphInstanc
|
||||
|
||||
_, exists := aliasMap[alias]
|
||||
if !exists {
|
||||
addNodeWithAlias(alias)
|
||||
_, err := addNodeWithAlias(alias)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -619,7 +624,9 @@ func TestFindLowestFeePath(t *testing.T) {
|
||||
}),
|
||||
}
|
||||
|
||||
testGraphInstance, err := createTestGraphFromChannels(testChannels)
|
||||
testGraphInstance, err := createTestGraphFromChannels(
|
||||
testChannels, "roasbeef",
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create graph: %v", err)
|
||||
}
|
||||
@@ -1367,7 +1374,7 @@ func TestRouteFailMaxHTLC(t *testing.T) {
|
||||
}),
|
||||
}
|
||||
|
||||
graph, err := createTestGraphFromChannels(testChannels)
|
||||
graph, err := createTestGraphFromChannels(testChannels, "roasbeef")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create graph: %v", err)
|
||||
}
|
||||
@@ -1862,7 +1869,9 @@ func TestRestrictOutgoingChannel(t *testing.T) {
|
||||
}),
|
||||
}
|
||||
|
||||
testGraphInstance, err := createTestGraphFromChannels(testChannels)
|
||||
testGraphInstance, err := createTestGraphFromChannels(
|
||||
testChannels, "roasbeef",
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create graph: %v", err)
|
||||
}
|
||||
@@ -1957,7 +1966,9 @@ func testCltvLimit(t *testing.T, limit uint32, expectedChannel uint64) {
|
||||
}),
|
||||
}
|
||||
|
||||
testGraphInstance, err := createTestGraphFromChannels(testChannels)
|
||||
testGraphInstance, err := createTestGraphFromChannels(
|
||||
testChannels, "roasbeef",
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create graph: %v", err)
|
||||
}
|
||||
@@ -2121,7 +2132,9 @@ func testProbabilityRouting(t *testing.T, p10, p11, p20, minProbability float64,
|
||||
}, 20),
|
||||
}
|
||||
|
||||
testGraphInstance, err := createTestGraphFromChannels(testChannels)
|
||||
testGraphInstance, err := createTestGraphFromChannels(
|
||||
testChannels, "roasbeef",
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create graph: %v", err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user