@@ -101,15 +101,17 @@ func createTestVertex(t testing.TB) *models.LightningNode {
101
101
func TestNodeInsertionAndDeletion (t * testing.T ) {
102
102
t .Parallel ()
103
103
104
- graph := MakeTestGraph (t )
104
+ graph := MakeTestGraphNew (t )
105
105
106
106
// We'd like to test basic insertion/deletion for vertexes from the
107
107
// graph, so we'll create a test vertex to start with.
108
+ timeStamp := int64 (1232342 )
108
109
nodeWithAddrs := func (addrs []net.Addr ) * models.LightningNode {
110
+ timeStamp ++
109
111
return & models.LightningNode {
110
112
HaveNodeAnnouncement : true ,
111
113
AuthSigBytes : testSig .Serialize (),
112
- LastUpdate : time .Unix (1232342 , 0 ),
114
+ LastUpdate : time .Unix (timeStamp , 0 ),
113
115
Color : color.RGBA {1 , 2 , 3 , 0 },
114
116
Alias : "kek" ,
115
117
Features : testFeatures ,
@@ -323,31 +325,27 @@ func TestPartialNode(t *testing.T) {
323
325
require .ErrorIs (t , err , ErrGraphNodeNotFound )
324
326
}
325
327
328
+ // TestAliasLookup tests the alias lookup functionality of the graph store.
326
329
func TestAliasLookup (t * testing.T ) {
327
330
t .Parallel ()
328
331
329
- graph := MakeTestGraph (t )
332
+ graph := MakeTestGraphNew (t )
330
333
331
334
// We'd like to test the alias index within the database, so first
332
335
// create a new test node.
333
336
testNode := createTestVertex (t )
334
337
335
338
// Add the node to the graph's database, this should also insert an
336
339
// entry into the alias index for this node.
337
- if err := graph .AddLightningNode (testNode ); err != nil {
338
- t .Fatalf ("unable to add node: %v" , err )
339
- }
340
+ require .NoError (t , graph .AddLightningNode (testNode ))
340
341
341
342
// Next, attempt to lookup the alias. The alias should exactly match
342
343
// the one which the test node was assigned.
343
344
nodePub , err := testNode .PubKey ()
344
345
require .NoError (t , err , "unable to generate pubkey" )
345
346
dbAlias , err := graph .LookupAlias (nodePub )
346
347
require .NoError (t , err , "unable to find alias" )
347
- if dbAlias != testNode .Alias {
348
- t .Fatalf ("aliases don't match, expected %v got %v" ,
349
- testNode .Alias , dbAlias )
350
- }
348
+ require .Equal (t , testNode .Alias , dbAlias )
351
349
352
350
// Ensure that looking up a non-existent alias results in an error.
353
351
node := createTestVertex (t )
@@ -357,10 +355,11 @@ func TestAliasLookup(t *testing.T) {
357
355
require .ErrorIs (t , err , ErrNodeAliasNotFound )
358
356
}
359
357
358
+ // TestSourceNode tests the source node functionality of the graph store.
360
359
func TestSourceNode (t * testing.T ) {
361
360
t .Parallel ()
362
361
363
- graph := MakeTestGraph (t )
362
+ graph := MakeTestGraphNew (t )
364
363
365
364
// We'd like to test the setting/getting of the source node, so we
366
365
// first create a fake node to use within the test.
@@ -371,11 +370,9 @@ func TestSourceNode(t *testing.T) {
371
370
_ , err := graph .SourceNode ()
372
371
require .ErrorIs (t , err , ErrSourceNodeNotSet )
373
372
374
- // Set the source the source node, this should insert the node into the
373
+ // Set the source node, this should insert the node into the
375
374
// database in a special way indicating it's the source node.
376
- if err := graph .SetSourceNode (testNode ); err != nil {
377
- t .Fatalf ("unable to set source node: %v" , err )
378
- }
375
+ require .NoError (t , graph .SetSourceNode (testNode ))
379
376
380
377
// Retrieve the source node from the database, it should exactly match
381
378
// the one we set above.
@@ -2082,7 +2079,7 @@ func TestChanUpdatesInHorizon(t *testing.T) {
2082
2079
func TestNodeUpdatesInHorizon (t * testing.T ) {
2083
2080
t .Parallel ()
2084
2081
2085
- graph := MakeTestGraph (t )
2082
+ graph := MakeTestGraphNew (t )
2086
2083
2087
2084
startTime := time .Unix (1234 , 0 )
2088
2085
endTime := startTime
@@ -2093,10 +2090,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
2093
2090
time .Unix (999 , 0 ), time .Unix (9999 , 0 ),
2094
2091
)
2095
2092
require .NoError (t , err , "unable to query for node updates" )
2096
- if len (nodeUpdates ) != 0 {
2097
- t .Fatalf ("expected 0 node updates, instead got %v" ,
2098
- len (nodeUpdates ))
2099
- }
2093
+ require .Len (t , nodeUpdates , 0 )
2100
2094
2101
2095
// We'll create 10 node announcements, each with an update timestamp 10
2102
2096
// seconds after the other.
@@ -2115,9 +2109,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
2115
2109
2116
2110
nodeAnns = append (nodeAnns , * nodeAnn )
2117
2111
2118
- if err := graph .AddLightningNode (nodeAnn ); err != nil {
2119
- t .Fatalf ("unable to add lightning node: %v" , err )
2120
- }
2112
+ require .NoError (t , graph .AddLightningNode (nodeAnn ))
2121
2113
}
2122
2114
2123
2115
queryCases := []struct {
@@ -2171,15 +2163,8 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
2171
2163
resp , err := graph .NodeUpdatesInHorizon (
2172
2164
queryCase .start , queryCase .end ,
2173
2165
)
2174
- if err != nil {
2175
- t .Fatalf ("unable to query for nodes: %v" , err )
2176
- }
2177
-
2178
- if len (resp ) != len (queryCase .resp ) {
2179
- t .Fatalf ("expected %v nodes, got %v nodes" ,
2180
- len (queryCase .resp ), len (resp ))
2181
-
2182
- }
2166
+ require .NoError (t , err )
2167
+ require .Len (t , resp , len (queryCase .resp ))
2183
2168
2184
2169
for i := 0 ; i < len (resp ); i ++ {
2185
2170
compareNodes (t , & queryCase .resp [i ], & resp [i ])
@@ -3384,7 +3369,7 @@ func TestAddChannelEdgeShellNodes(t *testing.T) {
3384
3369
func TestNodePruningUpdateIndexDeletion (t * testing.T ) {
3385
3370
t .Parallel ()
3386
3371
3387
- graph := MakeTestGraph (t )
3372
+ graph := MakeTestGraphNew (t )
3388
3373
3389
3374
// We'll first populate our graph with a single node that will be
3390
3375
// removed shortly.
@@ -4315,7 +4300,7 @@ func TestLightningNodePersistence(t *testing.T) {
4315
4300
t .Parallel ()
4316
4301
4317
4302
// Create a new test graph instance.
4318
- graph := MakeTestGraph (t )
4303
+ graph := MakeTestGraphNew (t )
4319
4304
4320
4305
nodeAnnBytes , err := hex .DecodeString (testNodeAnn )
4321
4306
require .NoError (t , err )
0 commit comments