From 3a17479ff414ce2d2deaace3eb57044ea2dfa316 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Mon, 23 Oct 2023 14:39:15 +0200 Subject: [PATCH] multi: remove LightningNode from ChannelEdgePolicy Finally, The LightningNode object is removed from ChannelEdgePolicy. This is a step towards letting ChannelEdgePolicy reflect exactly the schema that is on disk. This is also nice because the `Node` object is not necessarily always required when the ChannelEdgePolicy is loaded from the DB, so now it only get's loaded when needed. --- autopilot/graph.go | 7 +++- channeldb/graph.go | 78 ++++++++++++++++++++++------------- channeldb/graph_cache.go | 4 +- channeldb/graph_cache_test.go | 15 ++----- channeldb/graph_test.go | 69 ++++++++++++++++--------------- discovery/chan_series.go | 16 ++++--- routing/notifications_test.go | 2 +- routing/pathfind_test.go | 37 ++--------------- routing/router_test.go | 16 ++----- 9 files changed, 114 insertions(+), 130 deletions(-) diff --git a/autopilot/graph.go b/autopilot/graph.go index 633a7b986..7e362bc2e 100644 --- a/autopilot/graph.go +++ b/autopilot/graph.go @@ -104,6 +104,11 @@ func (d *dbNode) ForEachChannel(cb func(ChannelEdge) error) error { return nil } + node, err := d.db.FetchLightningNode(tx, ep.ToNode) + if err != nil { + return err + } + edge := ChannelEdge{ ChanID: lnwire.NewShortChanIDFromInt( ep.ChannelID, @@ -112,7 +117,7 @@ func (d *dbNode) ForEachChannel(cb func(ChannelEdge) error) error { Peer: &dbNode{ tx: tx, db: d.db, - node: ep.Node, + node: node, }, } diff --git a/channeldb/graph.go b/channeldb/graph.go index b9d99ed8c..e762f0be7 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -1858,6 +1858,14 @@ type ChannelEdge struct { // Policy2 points to the "second" edge policy of the channel containing // the dynamic information required to properly route through the edge. Policy2 *ChannelEdgePolicy + + // Node1 is "node 1" in the channel. This is the node that would have + // produced Policy1 if it exists. + Node1 *LightningNode + + // Node2 is "node 2" in the channel. This is the node that would have + // produced Policy2 if it exists. + Node2 *LightningNode } // ChanUpdatesInHorizon returns all the known channel edges which have at least @@ -1952,6 +1960,20 @@ func (c *ChannelGraph) ChanUpdatesInHorizon(startTime, err) } + node1, err := fetchLightningNode( + nodes, edgeInfo.NodeKey1Bytes[:], + ) + if err != nil { + return err + } + + node2, err := fetchLightningNode( + nodes, edgeInfo.NodeKey2Bytes[:], + ) + if err != nil { + return err + } + // Finally, we'll collate this edge with the rest of // edges to be returned. edgesSeen[chanIDInt] = struct{}{} @@ -1959,6 +1981,8 @@ func (c *ChannelGraph) ChanUpdatesInHorizon(startTime, Info: &edgeInfo, Policy1: edge1, Policy2: edge2, + Node1: &node1, + Node2: &node2, } edgesInHorizon = append(edgesInHorizon, channel) edgesToCache[chanIDInt] = channel @@ -2279,10 +2303,26 @@ func (c *ChannelGraph) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge, error) { return err } + node1, err := fetchLightningNode( + nodes, edgeInfo.NodeKey1Bytes[:], + ) + if err != nil { + return err + } + + node2, err := fetchLightningNode( + nodes, edgeInfo.NodeKey2Bytes[:], + ) + if err != nil { + return err + } + chanEdges = append(chanEdges, ChannelEdge{ Info: &edgeInfo, Policy1: edge1, Policy2: edge2, + Node1: &node1, + Node2: &node2, }) } return nil @@ -2558,10 +2598,6 @@ func updateEdgePolicy(tx kvdb.RwTx, edge *ChannelEdgePolicy, if edgeIndex == nil { return false, ErrEdgeNotFound } - nodes, err := tx.CreateTopLevelBucket(nodeBucket) - if err != nil { - return false, err - } // Create the channelID key be converting the channel ID // integer into a byte slice. @@ -2591,7 +2627,7 @@ func updateEdgePolicy(tx kvdb.RwTx, edge *ChannelEdgePolicy, // Finally, with the direction of the edge being updated // identified, we update the on-disk edge representation. - err = putChanEdgePolicy(edges, nodes, edge, fromNode, toNode) + err := putChanEdgePolicy(edges, edge, fromNode, toNode) if err != nil { return false, err } @@ -3441,9 +3477,9 @@ type ChannelEdgePolicy struct { // HTLCs for each millionth of a satoshi forwarded. FeeProportionalMillionths lnwire.MilliSatoshi - // Node is the LightningNode that this directed edge leads to. Using - // this pointer the channel graph can further be traversed. - Node *LightningNode + // ToNode is the public key of the node that this directed edge leads + // to. Using this pub key, the channel graph can further be traversed. + ToNode [33]byte // ExtraOpaqueData is the set of data that was appended to this // message, some of which we may not actually know how to iterate or @@ -4460,8 +4496,8 @@ func deserializeChanEdgeInfo(r io.Reader) (ChannelEdgeInfo, error) { return edgeInfo, nil } -func putChanEdgePolicy(edges, nodes kvdb.RwBucket, edge *ChannelEdgePolicy, - from, to []byte) error { +func putChanEdgePolicy(edges kvdb.RwBucket, edge *ChannelEdgePolicy, from, + to []byte) error { var edgeKey [33 + 8]byte copy(edgeKey[:], from) @@ -4501,7 +4537,7 @@ func putChanEdgePolicy(edges, nodes kvdb.RwBucket, edge *ChannelEdgePolicy, // TODO(halseth): get rid of these invalid policies in a // migration. oldEdgePolicy, err := deserializeChanEdgePolicy( - bytes.NewReader(edgeBytes), nodes, + bytes.NewReader(edgeBytes), ) if err != nil && err != ErrEdgePolicyOptionalFieldNotFound { return err @@ -4599,7 +4635,7 @@ func fetchChanEdgePolicy(edges kvdb.RBucket, chanID []byte, edgeReader := bytes.NewReader(edgeBytes) - ep, err := deserializeChanEdgePolicy(edgeReader, nodes) + ep, err := deserializeChanEdgePolicy(edgeReader) switch { // If the db policy was missing an expected optional field, we return // nil as if the policy was unknown. @@ -4709,9 +4745,7 @@ func serializeChanEdgePolicy(w io.Writer, edge *ChannelEdgePolicy, return nil } -func deserializeChanEdgePolicy(r io.Reader, - nodes kvdb.RBucket) (*ChannelEdgePolicy, error) { - +func deserializeChanEdgePolicy(r io.Reader) (*ChannelEdgePolicy, error) { // Deserialize the policy. Note that in case an optional field is not // found, both an error and a populated policy object are returned. edge, deserializeErr := deserializeChanEdgePolicyRaw(r) @@ -4721,14 +4755,6 @@ func deserializeChanEdgePolicy(r io.Reader, return nil, deserializeErr } - // Populate full LightningNode struct. - pub := edge.Node.PubKeyBytes[:] - node, err := fetchLightningNode(nodes, pub) - if err != nil { - return nil, fmt.Errorf("unable to fetch node: %x, %v", pub, err) - } - edge.Node = &node - return edge, deserializeErr } @@ -4778,13 +4804,9 @@ func deserializeChanEdgePolicyRaw(r io.Reader) (*ChannelEdgePolicy, error) { } edge.FeeProportionalMillionths = lnwire.MilliSatoshi(n) - var pub [33]byte - if _, err := r.Read(pub[:]); err != nil { + if _, err := r.Read(edge.ToNode[:]); err != nil { return nil, err } - edge.Node = &LightningNode{ - PubKeyBytes: pub, - } // We'll try and see if there are any opaque bytes left, if not, then // we'll ignore the EOF error and return the edge as is. diff --git a/channeldb/graph_cache.go b/channeldb/graph_cache.go index 1aae21d06..84e340b56 100644 --- a/channeldb/graph_cache.go +++ b/channeldb/graph_cache.go @@ -271,7 +271,7 @@ func (c *GraphCache) AddChannel(info *ChannelEdgeInfo, // of node 2 then we have the policy 1 as seen from node 1. if policy1 != nil { fromNode, toNode := info.NodeKey1Bytes, info.NodeKey2Bytes - if policy1.Node.PubKeyBytes != info.NodeKey2Bytes { + if policy1.ToNode != info.NodeKey2Bytes { fromNode, toNode = toNode, fromNode } isEdge1 := policy1.ChannelFlags&lnwire.ChanUpdateDirection == 0 @@ -279,7 +279,7 @@ func (c *GraphCache) AddChannel(info *ChannelEdgeInfo, } if policy2 != nil { fromNode, toNode := info.NodeKey2Bytes, info.NodeKey1Bytes - if policy2.Node.PubKeyBytes != info.NodeKey1Bytes { + if policy2.ToNode != info.NodeKey1Bytes { fromNode, toNode = toNode, fromNode } isEdge1 := policy2.ChannelFlags&lnwire.ChanUpdateDirection == 0 diff --git a/channeldb/graph_cache_test.go b/channeldb/graph_cache_test.go index b408ec36d..4a6711191 100644 --- a/channeldb/graph_cache_test.go +++ b/channeldb/graph_cache_test.go @@ -73,18 +73,12 @@ func TestGraphCacheAddNode(t *testing.T) { outPolicy1 := &ChannelEdgePolicy{ ChannelID: 1000, ChannelFlags: lnwire.ChanUpdateChanFlags(channelFlagA), - Node: &LightningNode{ - PubKeyBytes: nodeB, - Features: lnwire.EmptyFeatureVector(), - }, + ToNode: nodeB, } inPolicy1 := &ChannelEdgePolicy{ ChannelID: 1000, ChannelFlags: lnwire.ChanUpdateChanFlags(channelFlagB), - Node: &LightningNode{ - PubKeyBytes: nodeA, - Features: lnwire.EmptyFeatureVector(), - }, + ToNode: nodeA, } node := &node{ pubKey: nodeA, @@ -159,9 +153,6 @@ func assertCachedPolicyEqual(t *testing.T, original *ChannelEdgePolicy, cached.FeeProportionalMillionths, ) require.Equal( - t, - route.Vertex(original.Node.PubKeyBytes), - cached.ToNodePubKey(), + t, route.Vertex(original.ToNode), cached.ToNodePubKey(), ) - require.Equal(t, original.Node.Features, cached.ToNodeFeatures) } diff --git a/channeldb/graph_test.go b/channeldb/graph_test.go index 242fed4a7..f88c46726 100644 --- a/channeldb/graph_test.go +++ b/channeldb/graph_test.go @@ -619,15 +619,15 @@ func createChannelEdge(db kvdb.Backend, node1, node2 *LightningNode) (*ChannelEd *ChannelEdgePolicy, *ChannelEdgePolicy) { var ( - firstNode *LightningNode - secondNode *LightningNode + firstNode [33]byte + secondNode [33]byte ) if bytes.Compare(node1.PubKeyBytes[:], node2.PubKeyBytes[:]) == -1 { - firstNode = node1 - secondNode = node2 + firstNode = node1.PubKeyBytes + secondNode = node2.PubKeyBytes } else { - firstNode = node2 - secondNode = node1 + firstNode = node2.PubKeyBytes + secondNode = node1.PubKeyBytes } // In addition to the fake vertexes we create some fake channel @@ -653,10 +653,10 @@ func createChannelEdge(db kvdb.Backend, node1, node2 *LightningNode) (*ChannelEd Capacity: 1000, ExtraOpaqueData: []byte("new unknown feature"), } - copy(edgeInfo.NodeKey1Bytes[:], firstNode.PubKeyBytes[:]) - copy(edgeInfo.NodeKey2Bytes[:], secondNode.PubKeyBytes[:]) - copy(edgeInfo.BitcoinKey1Bytes[:], firstNode.PubKeyBytes[:]) - copy(edgeInfo.BitcoinKey2Bytes[:], secondNode.PubKeyBytes[:]) + copy(edgeInfo.NodeKey1Bytes[:], firstNode[:]) + copy(edgeInfo.NodeKey2Bytes[:], secondNode[:]) + copy(edgeInfo.BitcoinKey1Bytes[:], firstNode[:]) + copy(edgeInfo.BitcoinKey2Bytes[:], secondNode[:]) edge1 := &ChannelEdgePolicy{ SigBytes: testSig.Serialize(), @@ -669,7 +669,7 @@ func createChannelEdge(db kvdb.Backend, node1, node2 *LightningNode) (*ChannelEd MaxHTLC: 13928598, FeeBaseMSat: 4352345, FeeProportionalMillionths: 3452352, - Node: secondNode, + ToNode: secondNode, ExtraOpaqueData: []byte("new unknown feature2"), } edge2 := &ChannelEdgePolicy{ @@ -683,7 +683,7 @@ func createChannelEdge(db kvdb.Backend, node1, node2 *LightningNode) (*ChannelEd MaxHTLC: 13928598, FeeBaseMSat: 4352345, FeeProportionalMillionths: 90392423, - Node: firstNode, + ToNode: firstNode, ExtraOpaqueData: []byte("new unknown feature1"), } @@ -1063,8 +1063,7 @@ func TestGraphTraversal(t *testing.T) { // Each should indicate that it's outgoing (pointed // towards the second node). if !bytes.Equal( - outEdge.Node.PubKeyBytes[:], - secondNode.PubKeyBytes[:], + outEdge.ToNode[:], secondNode.PubKeyBytes[:], ) { return fmt.Errorf("wrong outgoing edge") @@ -1073,14 +1072,14 @@ func TestGraphTraversal(t *testing.T) { // The incoming edge should also indicate that it's // pointing to the origin node. if !bytes.Equal( - inEdge.Node.PubKeyBytes[:], - firstNode.PubKeyBytes[:], + inEdge.ToNode[:], firstNode.PubKeyBytes[:], ) { return fmt.Errorf("wrong outgoing edge") } numNodeChans++ + return nil }) require.NoError(t, err) @@ -1275,7 +1274,7 @@ func fillTestGraph(t require.TestingT, graph *ChannelGraph, numNodes, // from node1 -> node2. edge := randEdgePolicy(chanID, graph.db) edge.ChannelFlags = 0 - edge.Node = node2 + edge.ToNode = node2.PubKeyBytes edge.SigBytes = testSig.Serialize() require.NoError(t, graph.UpdateEdgePolicy(edge)) @@ -1283,7 +1282,7 @@ func fillTestGraph(t require.TestingT, graph *ChannelGraph, numNodes, // node2 -> node1 this time. edge = randEdgePolicy(chanID, graph.db) edge.ChannelFlags = 1 - edge.Node = node1 + edge.ToNode = node1.PubKeyBytes edge.SigBytes = testSig.Serialize() require.NoError(t, graph.UpdateEdgePolicy(edge)) @@ -1468,7 +1467,7 @@ func TestGraphPruning(t *testing.T) { // node_i -> node_i+1 edge := randEdgePolicy(chanID, graph.db) edge.ChannelFlags = 0 - edge.Node = graphNodes[i] + edge.ToNode = graphNodes[i].PubKeyBytes edge.SigBytes = testSig.Serialize() if err := graph.UpdateEdgePolicy(edge); err != nil { t.Fatalf("unable to update edge: %v", err) @@ -1478,7 +1477,7 @@ func TestGraphPruning(t *testing.T) { // node_i this time. edge = randEdgePolicy(chanID, graph.db) edge.ChannelFlags = 1 - edge.Node = graphNodes[i] + edge.ToNode = graphNodes[i].PubKeyBytes edge.SigBytes = testSig.Serialize() if err := graph.UpdateEdgePolicy(edge); err != nil { t.Fatalf("unable to update edge: %v", err) @@ -1693,7 +1692,7 @@ func TestChanUpdatesInHorizon(t *testing.T) { chanID.ToUint64(), graph.db, edge1UpdateTime.Unix(), ) edge1.ChannelFlags = 0 - edge1.Node = node2 + edge1.ToNode = node2.PubKeyBytes edge1.SigBytes = testSig.Serialize() if err := graph.UpdateEdgePolicy(edge1); err != nil { t.Fatalf("unable to update edge: %v", err) @@ -1703,7 +1702,7 @@ func TestChanUpdatesInHorizon(t *testing.T) { chanID.ToUint64(), graph.db, edge2UpdateTime.Unix(), ) edge2.ChannelFlags = 1 - edge2.Node = node1 + edge2.ToNode = node1.PubKeyBytes edge2.SigBytes = testSig.Serialize() if err := graph.UpdateEdgePolicy(edge2); err != nil { t.Fatalf("unable to update edge: %v", err) @@ -2187,7 +2186,7 @@ func TestFetchChanInfos(t *testing.T) { chanID.ToUint64(), graph.db, updateTime.Unix(), ) edge1.ChannelFlags = 0 - edge1.Node = node2 + edge1.ToNode = node2.PubKeyBytes edge1.SigBytes = testSig.Serialize() if err := graph.UpdateEdgePolicy(edge1); err != nil { t.Fatalf("unable to update edge: %v", err) @@ -2197,7 +2196,7 @@ func TestFetchChanInfos(t *testing.T) { chanID.ToUint64(), graph.db, updateTime.Unix(), ) edge2.ChannelFlags = 1 - edge2.Node = node1 + edge2.ToNode = node1.PubKeyBytes edge2.SigBytes = testSig.Serialize() if err := graph.UpdateEdgePolicy(edge2); err != nil { t.Fatalf("unable to update edge: %v", err) @@ -2326,7 +2325,7 @@ func TestIncompleteChannelPolicies(t *testing.T) { chanID.ToUint64(), graph.db, updateTime.Unix(), ) edgePolicy.ChannelFlags = 0 - edgePolicy.Node = node2 + edgePolicy.ToNode = node2.PubKeyBytes edgePolicy.SigBytes = testSig.Serialize() if err := graph.UpdateEdgePolicy(edgePolicy); err != nil { t.Fatalf("unable to update edge: %v", err) @@ -2341,7 +2340,7 @@ func TestIncompleteChannelPolicies(t *testing.T) { chanID.ToUint64(), graph.db, updateTime.Unix(), ) edgePolicy.ChannelFlags = 1 - edgePolicy.Node = node1 + edgePolicy.ToNode = node1.PubKeyBytes edgePolicy.SigBytes = testSig.Serialize() if err := graph.UpdateEdgePolicy(edgePolicy); err != nil { t.Fatalf("unable to update edge: %v", err) @@ -2388,7 +2387,7 @@ func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) { edge1 := randEdgePolicy(chanID.ToUint64(), graph.db) edge1.ChannelFlags = 0 - edge1.Node = node1 + edge1.ToNode = node1.PubKeyBytes edge1.SigBytes = testSig.Serialize() if err := graph.UpdateEdgePolicy(edge1); err != nil { t.Fatalf("unable to update edge: %v", err) @@ -2396,7 +2395,7 @@ func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) { edge2 := randEdgePolicy(chanID.ToUint64(), graph.db) edge2.ChannelFlags = 1 - edge2.Node = node2 + edge2.ToNode = node2.PubKeyBytes edge2.SigBytes = testSig.Serialize() if err := graph.UpdateEdgePolicy(edge2); err != nil { t.Fatalf("unable to update edge: %v", err) @@ -2541,7 +2540,7 @@ func TestPruneGraphNodes(t *testing.T) { // points from the first to the second node. edge1 := randEdgePolicy(chanID.ToUint64(), graph.db) edge1.ChannelFlags = 0 - edge1.Node = node1 + edge1.ToNode = node1.PubKeyBytes edge1.SigBytes = testSig.Serialize() if err := graph.UpdateEdgePolicy(edge1); err != nil { t.Fatalf("unable to update edge: %v", err) @@ -2908,8 +2907,8 @@ func TestEdgePolicyMissingMaxHtcl(t *testing.T) { } chanID := edgeInfo.ChannelID - from := edge2.Node.PubKeyBytes[:] - to := edge1.Node.PubKeyBytes[:] + from := edge2.ToNode[:] + to := edge1.ToNode[:] // We'll remove the no max_htlc field from the first edge policy, and // all other opaque data, and serialize it. @@ -2945,7 +2944,7 @@ func TestEdgePolicyMissingMaxHtcl(t *testing.T) { return ErrGraphNotFound } - _, err = deserializeChanEdgePolicy(r, nodes) + _, err = deserializeChanEdgePolicy(r) if err != ErrEdgePolicyOptionalFieldNotFound { t.Fatalf("expected "+ "ErrEdgePolicyOptionalFieldNotFound, got %v", @@ -3196,9 +3195,11 @@ func compareEdgePolicies(a, b *ChannelEdgePolicy) error { return fmt.Errorf("extra data doesn't match: %v vs %v", a.ExtraOpaqueData, b.ExtraOpaqueData) } - if err := compareNodes(a.Node, b.Node); err != nil { - return err + if !bytes.Equal(a.ToNode[:], b.ToNode[:]) { + return fmt.Errorf("ToNode doesn't match: expected %x, got %x", + a.ToNode, b.ToNode) } + return nil } diff --git a/discovery/chan_series.go b/discovery/chan_series.go index 18f806316..c811017ab 100644 --- a/discovery/chan_series.go +++ b/discovery/chan_series.go @@ -280,10 +280,12 @@ func (c *ChanSeries) FetchChanAnns(chain chainhash.Hash, // If this edge has a validated node announcement, that // we haven't yet sent, then we'll send that as well. - nodePub := channel.Policy1.Node.PubKeyBytes - hasNodeAnn := channel.Policy1.Node.HaveNodeAnnouncement + nodePub := channel.Node2.PubKeyBytes + hasNodeAnn := channel.Node2.HaveNodeAnnouncement if _, ok := nodePubsSent[nodePub]; !ok && hasNodeAnn { - nodeAnn, err := channel.Policy1.Node.NodeAnnouncement(true) + nodeAnn, err := channel.Node2.NodeAnnouncement( + true, + ) if err != nil { return nil, err } @@ -297,10 +299,12 @@ func (c *ChanSeries) FetchChanAnns(chain chainhash.Hash, // If this edge has a validated node announcement, that // we haven't yet sent, then we'll send that as well. - nodePub := channel.Policy2.Node.PubKeyBytes - hasNodeAnn := channel.Policy2.Node.HaveNodeAnnouncement + nodePub := channel.Node1.PubKeyBytes + hasNodeAnn := channel.Node1.HaveNodeAnnouncement if _, ok := nodePubsSent[nodePub]; !ok && hasNodeAnn { - nodeAnn, err := channel.Policy2.Node.NodeAnnouncement(true) + nodeAnn, err := channel.Node1.NodeAnnouncement( + true, + ) if err != nil { return nil, err } diff --git a/routing/notifications_test.go b/routing/notifications_test.go index 00bc29f6b..50788fc67 100644 --- a/routing/notifications_test.go +++ b/routing/notifications_test.go @@ -85,7 +85,7 @@ func randEdgePolicy(chanID *lnwire.ShortChannelID, MaxHTLC: lnwire.MilliSatoshi(prand.Int31()), FeeBaseMSat: lnwire.MilliSatoshi(prand.Int31()), FeeProportionalMillionths: lnwire.MilliSatoshi(prand.Int31()), - Node: node, + ToNode: node.PubKeyBytes, } } diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go index b615d8969..ddb847722 100644 --- a/routing/pathfind_test.go +++ b/routing/pathfind_test.go @@ -303,16 +303,6 @@ func parseTestGraph(t *testing.T, useCache bool, path string) ( } } - aliasForNode := func(node route.Vertex) string { - for alias, pubKey := range aliasMap { - if pubKey == node { - return alias - } - } - - return "" - } - // With all the vertexes inserted, we can now insert the edges into the // test graph. for _, edge := range g.Edges { @@ -387,10 +377,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) ( MaxHTLC: lnwire.MilliSatoshi(edge.MaxHTLC), FeeBaseMSat: lnwire.MilliSatoshi(edge.FeeBaseMsat), FeeProportionalMillionths: lnwire.MilliSatoshi(edge.FeeRate), - Node: &channeldb.LightningNode{ - Alias: aliasForNode(targetNode), - PubKeyBytes: targetNode, - }, + ToNode: targetNode, } if err := graph.UpdateEdgePolicy(edgePolicy); err != nil { return nil, err @@ -684,11 +671,6 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, channelFlags |= lnwire.ChanUpdateDisabled } - node2Features := lnwire.EmptyFeatureVector() - if node2.testChannelPolicy != nil { - node2Features = node2.Features - } - edgePolicy := &channeldb.ChannelEdgePolicy{ SigBytes: testSig.Serialize(), MessageFlags: msgFlags, @@ -700,11 +682,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, MaxHTLC: node1.MaxHTLC, FeeBaseMSat: node1.FeeBaseMsat, FeeProportionalMillionths: node1.FeeRate, - Node: &channeldb.LightningNode{ - Alias: node2.Alias, - PubKeyBytes: node2Vertex, - Features: node2Features, - }, + ToNode: node2Vertex, } if err := graph.UpdateEdgePolicy(edgePolicy); err != nil { return nil, err @@ -722,11 +700,6 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, } channelFlags |= lnwire.ChanUpdateDirection - node1Features := lnwire.EmptyFeatureVector() - if node1.testChannelPolicy != nil { - node1Features = node1.Features - } - edgePolicy := &channeldb.ChannelEdgePolicy{ SigBytes: testSig.Serialize(), MessageFlags: msgFlags, @@ -738,11 +711,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, MaxHTLC: node2.MaxHTLC, FeeBaseMSat: node2.FeeBaseMsat, FeeProportionalMillionths: node2.FeeRate, - Node: &channeldb.LightningNode{ - Alias: node1.Alias, - PubKeyBytes: node1Vertex, - Features: node1Features, - }, + ToNode: node1Vertex, } if err := graph.UpdateEdgePolicy(edgePolicy); err != nil { return nil, err diff --git a/routing/router_test.go b/routing/router_test.go index ce05be561..7ff5f2acf 100644 --- a/routing/router_test.go +++ b/routing/router_test.go @@ -1431,9 +1431,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { MinHTLC: 1, FeeBaseMSat: 10, FeeProportionalMillionths: 10000, - Node: &channeldb.LightningNode{ - PubKeyBytes: edge.NodeKey2Bytes, - }, + ToNode: edge.NodeKey2Bytes, } edgePolicy.ChannelFlags = 0 @@ -1450,9 +1448,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { MinHTLC: 1, FeeBaseMSat: 10, FeeProportionalMillionths: 10000, - Node: &channeldb.LightningNode{ - PubKeyBytes: edge.NodeKey1Bytes, - }, + ToNode: edge.NodeKey1Bytes, } edgePolicy.ChannelFlags = 1 @@ -1528,9 +1524,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { MinHTLC: 1, FeeBaseMSat: 10, FeeProportionalMillionths: 10000, - Node: &channeldb.LightningNode{ - PubKeyBytes: edge.NodeKey2Bytes, - }, + ToNode: edge.NodeKey2Bytes, } edgePolicy.ChannelFlags = 0 @@ -1546,9 +1540,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { MinHTLC: 1, FeeBaseMSat: 10, FeeProportionalMillionths: 10000, - Node: &channeldb.LightningNode{ - PubKeyBytes: edge.NodeKey1Bytes, - }, + ToNode: edge.NodeKey1Bytes, } edgePolicy.ChannelFlags = 1