@@ -160,7 +160,9 @@ func makeTestGraph(t *testing.T, useCache bool) (*graphdb.ChannelGraph,
160
160
kvdb.Backend , error ) {
161
161
162
162
// Create channelgraph for the first time.
163
- graph := graphdb .MakeTestGraph (t , graphdb .WithUseGraphCache (useCache ))
163
+ graph := graphdb .MakeTestGraphNew (
164
+ t , graphdb .WithUseGraphCache (useCache ),
165
+ )
164
166
require .NoError (t , graph .Start ())
165
167
t .Cleanup (func () {
166
168
require .NoError (t , graph .Stop ())
@@ -289,6 +291,11 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
289
291
}
290
292
291
293
source = dbNode
294
+
295
+ // If this is the source node, we don't have to call
296
+ // AddLightningNode below since we will call
297
+ // SetSourceNode later.
298
+ continue
292
299
}
293
300
294
301
// With the node fully parsed, add it as a vertex within the
@@ -540,8 +547,8 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
540
547
privKeyMap := make (map [string ]* btcec.PrivateKey )
541
548
542
549
nodeIndex := byte (0 )
543
- addNodeWithAlias := func (alias string , features * lnwire. FeatureVector ) (
544
- * models. LightningNode , error ) {
550
+ addNodeWithAlias := func (alias string ,
551
+ features * lnwire. FeatureVector ) error {
545
552
546
553
keyBytes := []byte {
547
554
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
@@ -571,29 +578,29 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
571
578
572
579
// With the node fully parsed, add it as a vertex within the
573
580
// graph.
574
- if err := graph .AddLightningNode (ctx , dbNode ); err != nil {
575
- return nil , err
581
+ if alias == source {
582
+ err = graph .SetSourceNode (ctx , dbNode )
583
+ require .NoError (t , err )
584
+ } else {
585
+ err := graph .AddLightningNode (ctx , dbNode )
586
+ require .NoError (t , err )
576
587
}
577
588
578
589
aliasMap [alias ] = dbNode .PubKeyBytes
579
590
nodeIndex ++
580
591
581
- return dbNode , nil
592
+ return nil
582
593
}
583
594
584
595
// Add the source node.
585
- dbNode , err : = addNodeWithAlias (
596
+ err = addNodeWithAlias (
586
597
source , lnwire .NewFeatureVector (
587
598
lnwire .NewRawFeatureVector (sourceFeatureBits ... ),
588
599
lnwire .Features ,
589
600
),
590
601
)
591
602
require .NoError (t , err )
592
603
593
- if err = graph .SetSourceNode (ctx , dbNode ); err != nil {
594
- return nil , err
595
- }
596
-
597
604
// Initialize variable that keeps track of the next channel id to assign
598
605
// if none is specified.
599
606
nextUnassignedChannelID := uint64 (100000 )
@@ -611,7 +618,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
611
618
features =
612
619
node .testChannelPolicy .Features
613
620
}
614
- _ , err := addNodeWithAlias (
621
+ err := addNodeWithAlias (
615
622
node .Alias , features ,
616
623
)
617
624
if err != nil {
@@ -2157,6 +2164,7 @@ func runRouteFailMaxHTLC(t *testing.T, useCache bool) {
2157
2164
require .NoError (t , err , "unable to fetch channel edges by ID" )
2158
2165
midEdge .MessageFlags = 1
2159
2166
midEdge .MaxHTLC = payAmt - 1
2167
+ midEdge .LastUpdate = midEdge .LastUpdate .Add (time .Second )
2160
2168
err = graph .UpdateEdgePolicy (context .Background (), midEdge )
2161
2169
require .NoError (t , err )
2162
2170
@@ -2199,10 +2207,12 @@ func runRouteFailDisabledEdge(t *testing.T, useCache bool) {
2199
2207
_ , e1 , e2 , err := graph .graph .FetchChannelEdgesByID (roasToPham )
2200
2208
require .NoError (t , err , "unable to fetch edge" )
2201
2209
e1 .ChannelFlags |= lnwire .ChanUpdateDisabled
2210
+ e1 .LastUpdate = e1 .LastUpdate .Add (time .Second )
2202
2211
if err := graph .graph .UpdateEdgePolicy (ctx , e1 ); err != nil {
2203
2212
t .Fatalf ("unable to update edge: %v" , err )
2204
2213
}
2205
2214
e2 .ChannelFlags |= lnwire .ChanUpdateDisabled
2215
+ e2 .LastUpdate = e2 .LastUpdate .Add (time .Second )
2206
2216
if err := graph .graph .UpdateEdgePolicy (ctx , e2 ); err != nil {
2207
2217
t .Fatalf ("unable to update edge: %v" , err )
2208
2218
}
@@ -2220,6 +2230,7 @@ func runRouteFailDisabledEdge(t *testing.T, useCache bool) {
2220
2230
_ , e , _ , err := graph .graph .FetchChannelEdgesByID (phamToSophon )
2221
2231
require .NoError (t , err , "unable to fetch edge" )
2222
2232
e .ChannelFlags |= lnwire .ChanUpdateDisabled
2233
+ e .LastUpdate = e .LastUpdate .Add (time .Second )
2223
2234
if err := graph .graph .UpdateEdgePolicy (ctx , e ); err != nil {
2224
2235
t .Fatalf ("unable to update edge: %v" , err )
2225
2236
}
@@ -2302,10 +2313,12 @@ func runPathSourceEdgesBandwidth(t *testing.T, useCache bool) {
2302
2313
_ , e1 , e2 , err := graph .graph .FetchChannelEdgesByID (roasToSongoku )
2303
2314
require .NoError (t , err , "unable to fetch edge" )
2304
2315
e1 .ChannelFlags |= lnwire .ChanUpdateDisabled
2316
+ e1 .LastUpdate = e1 .LastUpdate .Add (time .Second )
2305
2317
if err := graph .graph .UpdateEdgePolicy (ctx , e1 ); err != nil {
2306
2318
t .Fatalf ("unable to update edge: %v" , err )
2307
2319
}
2308
2320
e2 .ChannelFlags |= lnwire .ChanUpdateDisabled
2321
+ e2 .LastUpdate = e2 .LastUpdate .Add (time .Second )
2309
2322
if err := graph .graph .UpdateEdgePolicy (ctx , e2 ); err != nil {
2310
2323
t .Fatalf ("unable to update edge: %v" , err )
2311
2324
}
0 commit comments