routing: add missing GlobalFeatures to NetworkNodeUpdate

This commit is contained in:
Andras Banki-Horvath
2020-12-03 16:41:20 +01:00
parent c58589db3b
commit 98c61be342
6 changed files with 832 additions and 789 deletions

View File

@@ -238,15 +238,14 @@ type NetworkNodeUpdate struct {
// updates.
IdentityKey *btcec.PublicKey
// GlobalFeatures is a set of opaque bytes that describe the set of
// features supported by the node.
GlobalFeatures []byte
// Alias is the alias or nick name of the node.
Alias string
// Color is the node's color in hex code format.
Color string
// Features holds the set of features the node supports.
Features *lnwire.FeatureVector
}
// ChannelEdgeUpdate is an update for a new channel within the ChannelGraph.
@@ -318,11 +317,13 @@ func addToTopologyChange(graph *channeldb.ChannelGraph, update *TopologyChange,
if err != nil {
return err
}
nodeUpdate := &NetworkNodeUpdate{
Addresses: m.Addresses,
IdentityKey: pubKey,
Alias: m.Alias,
Color: EncodeHexColor(m.Color),
Features: m.Features.Clone(),
}
nodeUpdate.IdentityKey.Curve = nil

View File

@@ -1,6 +1,7 @@
package routing
import (
"bytes"
"fmt"
"image/color"
"net"
@@ -21,6 +22,7 @@ import (
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/chainview"
"github.com/lightningnetwork/lnd/routing/route"
"github.com/stretchr/testify/require"
)
var (
@@ -572,6 +574,9 @@ func TestNodeUpdateNotification(t *testing.T) {
t.Fatalf("unable to create test node: %v", err)
}
testFeaturesBuf := new(bytes.Buffer)
require.NoError(t, testFeatures.Encode(testFeaturesBuf))
edge := &channeldb.ChannelEdgeInfo{
ChannelID: chanID.ToUint64(),
NodeKey1Bytes: node1.PubKeyBytes,
@@ -623,6 +628,14 @@ func TestNodeUpdateNotification(t *testing.T) {
"got %x", nodeKey.SerializeCompressed(),
nodeUpdate.IdentityKey.SerializeCompressed())
}
featuresBuf := new(bytes.Buffer)
require.NoError(t, nodeUpdate.Features.Encode(featuresBuf))
require.Equal(
t, testFeaturesBuf.Bytes(), featuresBuf.Bytes(),
)
if nodeUpdate.Alias != ann.Alias {
t.Fatalf("node alias doesn't match: expected %v, got %v",
ann.Alias, nodeUpdate.Alias)