@@ -73,13 +73,11 @@ var (
73
73
)
74
74
75
75
func createLightningNode (priv * btcec.PrivateKey ) * models.LightningNode {
76
- updateTime := prand .Int63 ()
77
-
78
76
pub := priv .PubKey ().SerializeCompressed ()
79
77
n := & models.LightningNode {
80
78
HaveNodeAnnouncement : true ,
81
79
AuthSigBytes : testSig .Serialize (),
82
- LastUpdate : time .Unix (updateTime , 0 ),
80
+ LastUpdate : time .Unix (nextUpdateTime () , 0 ),
83
81
Color : color.RGBA {1 , 2 , 3 , 0 },
84
82
Alias : "kek" + hex .EncodeToString (pub ),
85
83
Features : testFeatures ,
@@ -392,7 +390,7 @@ func TestEdgeInsertionDeletion(t *testing.T) {
392
390
t .Parallel ()
393
391
ctx := context .Background ()
394
392
395
- graph := MakeTestGraph (t )
393
+ graph := MakeTestGraphNew (t )
396
394
397
395
// We'd like to test the insertion/deletion of edges, so we create two
398
396
// vertexes to connect.
@@ -812,7 +810,7 @@ func TestEdgeInfoUpdates(t *testing.T) {
812
810
t .Parallel ()
813
811
ctx := context .Background ()
814
812
815
- graph := MakeTestGraph (t )
813
+ graph := MakeTestGraphNew (t )
816
814
817
815
// We'd like to test the update of edges inserted into the database, so
818
816
// we create two vertexes to connect.
@@ -2198,7 +2196,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
2198
2196
func TestFilterKnownChanIDsZombieRevival (t * testing.T ) {
2199
2197
t .Parallel ()
2200
2198
2201
- graph := MakeTestGraph (t )
2199
+ graph := MakeTestGraphNew (t )
2202
2200
2203
2201
var (
2204
2202
scid1 = lnwire.ShortChannelID {BlockHeight : 1 }
@@ -2264,7 +2262,7 @@ func TestFilterKnownChanIDs(t *testing.T) {
2264
2262
t .Parallel ()
2265
2263
ctx := context .Background ()
2266
2264
2267
- graph := MakeTestGraph (t )
2265
+ graph := MakeTestGraphNew (t )
2268
2266
2269
2267
isZombieUpdate := func (updateTime1 time.Time ,
2270
2268
updateTime2 time.Time ) bool {
@@ -2946,7 +2944,7 @@ func TestFetchChanInfos(t *testing.T) {
2946
2944
t .Parallel ()
2947
2945
ctx := context .Background ()
2948
2946
2949
- graph := MakeTestGraph (t )
2947
+ graph := MakeTestGraphNew (t )
2950
2948
2951
2949
// We'll first populate our graph with two nodes. All channels created
2952
2950
// below will be made between these two nodes.
@@ -3439,6 +3437,20 @@ func TestNodePruningUpdateIndexDeletion(t *testing.T) {
3439
3437
}
3440
3438
}
3441
3439
3440
+ var (
3441
+ updateTime = prand .Int63 ()
3442
+ updateTimeMu sync.Mutex
3443
+ )
3444
+
3445
+ func nextUpdateTime () int64 {
3446
+ updateTimeMu .Lock ()
3447
+ defer updateTimeMu .Unlock ()
3448
+
3449
+ updateTime ++
3450
+
3451
+ return updateTime
3452
+ }
3453
+
3442
3454
// TestNodeIsPublic ensures that we properly detect nodes that are seen as
3443
3455
// public within the network graph.
3444
3456
func TestNodeIsPublic (t * testing.T ) {
@@ -3453,19 +3465,19 @@ func TestNodeIsPublic(t *testing.T) {
3453
3465
// We'll need to create a separate database and channel graph for each
3454
3466
// participant to replicate real-world scenarios (private edges being in
3455
3467
// some graphs but not others, etc.).
3456
- aliceGraph := MakeTestGraph (t )
3468
+ aliceGraph := MakeTestGraphNew (t )
3457
3469
aliceNode := createTestVertex (t )
3458
3470
if err := aliceGraph .SetSourceNode (ctx , aliceNode ); err != nil {
3459
3471
t .Fatalf ("unable to set source node: %v" , err )
3460
3472
}
3461
3473
3462
- bobGraph := MakeTestGraph (t )
3474
+ bobGraph := MakeTestGraphNew (t )
3463
3475
bobNode := createTestVertex (t )
3464
3476
if err := bobGraph .SetSourceNode (ctx , bobNode ); err != nil {
3465
3477
t .Fatalf ("unable to set source node: %v" , err )
3466
3478
}
3467
3479
3468
- carolGraph := MakeTestGraph (t )
3480
+ carolGraph := MakeTestGraphNew (t )
3469
3481
carolNode := createTestVertex (t )
3470
3482
if err := carolGraph .SetSourceNode (ctx , carolNode ); err != nil {
3471
3483
t .Fatalf ("unable to set source node: %v" , err )
@@ -3481,13 +3493,13 @@ func TestNodeIsPublic(t *testing.T) {
3481
3493
graphs := []* ChannelGraph {aliceGraph , bobGraph , carolGraph }
3482
3494
for _ , graph := range graphs {
3483
3495
for _ , node := range nodes {
3496
+ node .LastUpdate = time .Unix (nextUpdateTime (), 0 )
3484
3497
err := graph .AddLightningNode (ctx , node )
3485
3498
require .NoError (t , err )
3486
3499
}
3487
3500
for _ , edge := range edges {
3488
- if err := graph .AddChannelEdge (ctx , edge ); err != nil {
3489
- t .Fatalf ("unable to add edge: %v" , err )
3490
- }
3501
+ err := graph .AddChannelEdge (ctx , edge )
3502
+ require .NoError (t , err )
3491
3503
}
3492
3504
}
3493
3505
@@ -3580,7 +3592,7 @@ func TestDisabledChannelIDs(t *testing.T) {
3580
3592
t .Parallel ()
3581
3593
ctx := context .Background ()
3582
3594
3583
- graph := MakeTestGraph (t )
3595
+ graph := MakeTestGraphNew (t )
3584
3596
3585
3597
// Create first node and add it to the graph.
3586
3598
node1 := createTestVertex (t )
@@ -3596,6 +3608,7 @@ func TestDisabledChannelIDs(t *testing.T) {
3596
3608
3597
3609
// Adding a new channel edge to the graph.
3598
3610
edgeInfo , edge1 , edge2 := createChannelEdge (node1 , node2 )
3611
+ node2 .LastUpdate = time .Unix (nextUpdateTime (), 0 )
3599
3612
if err := graph .AddLightningNode (ctx , node2 ); err != nil {
3600
3613
t .Fatalf ("unable to add node: %v" , err )
3601
3614
}
0 commit comments