@@ -73,13 +73,11 @@ var (
7373)
7474
7575func createLightningNode (priv * btcec.PrivateKey ) * models.LightningNode {
76- updateTime := prand .Int63 ()
77-
7876 pub := priv .PubKey ().SerializeCompressed ()
7977 n := & models.LightningNode {
8078 HaveNodeAnnouncement : true ,
8179 AuthSigBytes : testSig .Serialize (),
82- LastUpdate : time .Unix (updateTime , 0 ),
80+ LastUpdate : time .Unix (nextUpdateTime () , 0 ),
8381 Color : color.RGBA {1 , 2 , 3 , 0 },
8482 Alias : "kek" + hex .EncodeToString (pub ),
8583 Features : testFeatures ,
@@ -392,7 +390,7 @@ func TestEdgeInsertionDeletion(t *testing.T) {
392390 t .Parallel ()
393391 ctx := context .Background ()
394392
395- graph := MakeTestGraph (t )
393+ graph := MakeTestGraphNew (t )
396394
397395 // We'd like to test the insertion/deletion of edges, so we create two
398396 // vertexes to connect.
@@ -812,7 +810,7 @@ func TestEdgeInfoUpdates(t *testing.T) {
812810 t .Parallel ()
813811 ctx := context .Background ()
814812
815- graph := MakeTestGraph (t )
813+ graph := MakeTestGraphNew (t )
816814
817815 // We'd like to test the update of edges inserted into the database, so
818816 // we create two vertexes to connect.
@@ -2198,7 +2196,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
21982196func TestFilterKnownChanIDsZombieRevival (t * testing.T ) {
21992197 t .Parallel ()
22002198
2201- graph := MakeTestGraph (t )
2199+ graph := MakeTestGraphNew (t )
22022200
22032201 var (
22042202 scid1 = lnwire.ShortChannelID {BlockHeight : 1 }
@@ -2264,7 +2262,7 @@ func TestFilterKnownChanIDs(t *testing.T) {
22642262 t .Parallel ()
22652263 ctx := context .Background ()
22662264
2267- graph := MakeTestGraph (t )
2265+ graph := MakeTestGraphNew (t )
22682266
22692267 isZombieUpdate := func (updateTime1 time.Time ,
22702268 updateTime2 time.Time ) bool {
@@ -2946,7 +2944,7 @@ func TestFetchChanInfos(t *testing.T) {
29462944 t .Parallel ()
29472945 ctx := context .Background ()
29482946
2949- graph := MakeTestGraph (t )
2947+ graph := MakeTestGraphNew (t )
29502948
29512949 // We'll first populate our graph with two nodes. All channels created
29522950 // below will be made between these two nodes.
@@ -3439,6 +3437,20 @@ func TestNodePruningUpdateIndexDeletion(t *testing.T) {
34393437 }
34403438}
34413439
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+
34423454// TestNodeIsPublic ensures that we properly detect nodes that are seen as
34433455// public within the network graph.
34443456func TestNodeIsPublic (t * testing.T ) {
@@ -3453,19 +3465,19 @@ func TestNodeIsPublic(t *testing.T) {
34533465 // We'll need to create a separate database and channel graph for each
34543466 // participant to replicate real-world scenarios (private edges being in
34553467 // some graphs but not others, etc.).
3456- aliceGraph := MakeTestGraph (t )
3468+ aliceGraph := MakeTestGraphNew (t )
34573469 aliceNode := createTestVertex (t )
34583470 if err := aliceGraph .SetSourceNode (ctx , aliceNode ); err != nil {
34593471 t .Fatalf ("unable to set source node: %v" , err )
34603472 }
34613473
3462- bobGraph := MakeTestGraph (t )
3474+ bobGraph := MakeTestGraphNew (t )
34633475 bobNode := createTestVertex (t )
34643476 if err := bobGraph .SetSourceNode (ctx , bobNode ); err != nil {
34653477 t .Fatalf ("unable to set source node: %v" , err )
34663478 }
34673479
3468- carolGraph := MakeTestGraph (t )
3480+ carolGraph := MakeTestGraphNew (t )
34693481 carolNode := createTestVertex (t )
34703482 if err := carolGraph .SetSourceNode (ctx , carolNode ); err != nil {
34713483 t .Fatalf ("unable to set source node: %v" , err )
@@ -3481,13 +3493,13 @@ func TestNodeIsPublic(t *testing.T) {
34813493 graphs := []* ChannelGraph {aliceGraph , bobGraph , carolGraph }
34823494 for _ , graph := range graphs {
34833495 for _ , node := range nodes {
3496+ node .LastUpdate = time .Unix (nextUpdateTime (), 0 )
34843497 err := graph .AddLightningNode (ctx , node )
34853498 require .NoError (t , err )
34863499 }
34873500 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 )
34913503 }
34923504 }
34933505
@@ -3580,7 +3592,7 @@ func TestDisabledChannelIDs(t *testing.T) {
35803592 t .Parallel ()
35813593 ctx := context .Background ()
35823594
3583- graph := MakeTestGraph (t )
3595+ graph := MakeTestGraphNew (t )
35843596
35853597 // Create first node and add it to the graph.
35863598 node1 := createTestVertex (t )
@@ -3596,6 +3608,7 @@ func TestDisabledChannelIDs(t *testing.T) {
35963608
35973609 // Adding a new channel edge to the graph.
35983610 edgeInfo , edge1 , edge2 := createChannelEdge (node1 , node2 )
3611+ node2 .LastUpdate = time .Unix (nextUpdateTime (), 0 )
35993612 if err := graph .AddLightningNode (ctx , node2 ); err != nil {
36003613 t .Fatalf ("unable to add node: %v" , err )
36013614 }
0 commit comments