@@ -70,18 +70,18 @@ var (
7070)
7171
7272func createNode (priv * btcec.PrivateKey ) * models.Node {
73- pub := priv .PubKey (). SerializeCompressed ( )
74- n := & models. Node {
75- AuthSigBytes : testSig . Serialize (),
76- LastUpdate : nextUpdateTime (),
77- Color : color. RGBA { 1 , 2 , 3 , 0 } ,
78- Alias : "kek" + hex . EncodeToString ( pub ) ,
79- Features : testFeatures ,
80- Addresses : testAddrs ,
81- }
82- copy ( n . PubKeyBytes [:], priv . PubKey (). SerializeCompressed ())
83-
84- return n
73+ pubKey := route . NewVertex ( priv .PubKey ())
74+
75+ return models . NewV1Node (
76+ pubKey , & models. NodeV1Fields {
77+ LastUpdate : nextUpdateTime () ,
78+ Color : color. RGBA { 1 , 2 , 3 , 0 } ,
79+ Alias : "kek" + hex . EncodeToString ( pubKey [:]) ,
80+ Addresses : testAddrs ,
81+ Features : testFeatures . RawFeatureVector ,
82+ AuthSigBytes : testSig . Serialize (),
83+ },
84+ )
8585}
8686
8787func createTestVertex (t testing.TB ) * models.Node {
@@ -105,16 +105,18 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
105105 timeStamp := int64 (1232342 )
106106 nodeWithAddrs := func (addrs []net.Addr ) * models.Node {
107107 timeStamp ++
108- return & models.Node {
109- AuthSigBytes : testSig .Serialize (),
110- LastUpdate : time .Unix (timeStamp , 0 ),
111- Color : color.RGBA {1 , 2 , 3 , 0 },
112- Alias : "kek" ,
113- Features : testFeatures ,
114- Addresses : addrs ,
115- ExtraOpaqueData : []byte {1 , 1 , 1 , 2 , 2 , 2 , 2 },
116- PubKeyBytes : testPub ,
117- }
108+
109+ return models .NewV1Node (
110+ testPub , & models.NodeV1Fields {
111+ AuthSigBytes : testSig .Serialize (),
112+ LastUpdate : time .Unix (timeStamp , 0 ),
113+ Color : color.RGBA {1 , 2 , 3 , 0 },
114+ Alias : "kek" ,
115+ Features : testFeatures .RawFeatureVector ,
116+ Addresses : addrs ,
117+ ExtraOpaqueData : []byte {1 , 1 , 1 , 2 , 2 , 2 , 2 },
118+ },
119+ )
118120 }
119121
120122 // First, insert the node into the graph DB. This should succeed
@@ -313,11 +315,7 @@ func TestPartialNode(t *testing.T) {
313315
314316 // The two nodes should match exactly! (with default values for
315317 // LastUpdate and db set to satisfy compareNodes())
316- expectedNode1 := & models.Node {
317- LastUpdate : time .Unix (0 , 0 ),
318- PubKeyBytes : pubKey1 ,
319- Features : lnwire .EmptyFeatureVector (),
320- }
318+ expectedNode1 := models .NewV1ShellNode (pubKey1 )
321319 compareNodes (t , expectedNode1 , dbNode1 )
322320
323321 _ , exists , err = graph .HasNode (ctx , dbNode2 .PubKeyBytes )
@@ -326,11 +324,7 @@ func TestPartialNode(t *testing.T) {
326324
327325 // The two nodes should match exactly! (with default values for
328326 // LastUpdate and db set to satisfy compareNodes())
329- expectedNode2 := & models.Node {
330- LastUpdate : time .Unix (0 , 0 ),
331- PubKeyBytes : pubKey2 ,
332- Features : lnwire .EmptyFeatureVector (),
333- }
327+ expectedNode2 := models .NewV1ShellNode (pubKey2 )
334328 compareNodes (t , expectedNode2 , dbNode2 )
335329
336330 // Next, delete the node from the graph, this should purge all data
@@ -365,7 +359,7 @@ func TestAliasLookup(t *testing.T) {
365359 require .NoError (t , err , "unable to generate pubkey" )
366360 dbAlias , err := graph .LookupAlias (ctx , nodePub )
367361 require .NoError (t , err , "unable to find alias" )
368- require .Equal (t , testNode .Alias , dbAlias )
362+ require .Equal (t , testNode .Alias . UnwrapOr ( "" ) , dbAlias )
369363
370364 // Ensure that looking up a non-existent alias results in an error.
371365 node := createTestVertex (t )
@@ -1600,7 +1594,7 @@ func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
16001594 node := createTestVertex (t )
16011595
16021596 nodes [i ] = node
1603- nodeIndex [node .Alias ] = struct {}{}
1597+ nodeIndex [node .Alias . UnwrapOr ( "" ) ] = struct {}{}
16041598 }
16051599
16061600 // Add each of the nodes into the graph, they should be inserted
@@ -1612,7 +1606,7 @@ func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
16121606 // Iterate over each node as returned by the graph, if all nodes are
16131607 // reached, then the map created above should be empty.
16141608 err := graph .ForEachNode (ctx , func (n * models.Node ) error {
1615- delete (nodeIndex , n .Alias )
1609+ delete (nodeIndex , n .Alias . UnwrapOr ( "" ) )
16161610 return nil
16171611 }, func () {})
16181612 require .NoError (t , err )
@@ -2289,7 +2283,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
22892283 require .Len (t , resp , len (queryCase .resp ))
22902284
22912285 for i := 0 ; i < len (resp ); i ++ {
2292- compareNodes (t , & queryCase .resp [i ], & resp [i ])
2286+ compareNodes (t , & queryCase .resp [i ], resp [i ])
22932287 }
22942288 }
22952289}
@@ -2487,7 +2481,7 @@ func TestNodeUpdatesInHorizonEarlyTermination(t *testing.T) {
24872481 )
24882482
24892483 // Collect only up to stopAt nodes, breaking afterwards.
2490- var collected []models.Node
2484+ var collected []* models.Node
24912485 count := 0
24922486 for node := range iter {
24932487 if count >= stopAt {
@@ -3824,7 +3818,7 @@ func TestNodePruningUpdateIndexDeletion(t *testing.T) {
38243818 t .Fatalf ("should have 1 nodes instead have: %v" ,
38253819 len (nodesInHorizon ))
38263820 }
3827- compareNodes (t , node1 , & nodesInHorizon [0 ])
3821+ compareNodes (t , node1 , nodesInHorizon [0 ])
38283822
38293823 // We'll now delete the node from the graph, this should result in it
38303824 // being removed from the update index as well.
0 commit comments