mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 14:40:51 +02:00
lnwire: add support for Features in NodeAnnouncement
Add support for Features in NodeAnnouncment according to spec.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
3087bec4db
commit
085b7333cb
@@ -10,31 +10,37 @@ import (
|
||||
)
|
||||
|
||||
func TestNodeAnnouncementEncodeDecode(t *testing.T) {
|
||||
cua := &NodeAnnouncement{
|
||||
na := &NodeAnnouncement{
|
||||
Signature: someSig,
|
||||
Timestamp: maxUint32,
|
||||
NodeID: pubKey,
|
||||
RGBColor: someRGB,
|
||||
Alias: someAlias,
|
||||
Addresses: someAddresses,
|
||||
Features: someFeatures,
|
||||
}
|
||||
|
||||
// Next encode the NA message into an empty bytes buffer.
|
||||
var b bytes.Buffer
|
||||
if err := cua.Encode(&b, 0); err != nil {
|
||||
if err := na.Encode(&b, 0); err != nil {
|
||||
t.Fatalf("unable to encode NodeAnnouncement: %v", err)
|
||||
}
|
||||
|
||||
// Deserialize the encoded NA message into a new empty struct.
|
||||
cua2 := &NodeAnnouncement{}
|
||||
if err := cua2.Decode(&b, 0); err != nil {
|
||||
na2 := &NodeAnnouncement{}
|
||||
if err := na2.Decode(&b, 0); err != nil {
|
||||
t.Fatalf("unable to decode NodeAnnouncement: %v", err)
|
||||
}
|
||||
|
||||
// We do not encode the feature map in feature vector, for that reason
|
||||
// the node announcement messages will differ. Set feature map with nil
|
||||
// in order to use deep equal function.
|
||||
na.Features.featuresMap = nil
|
||||
|
||||
// Assert equality of the two instances.
|
||||
if !reflect.DeepEqual(cua, cua2) {
|
||||
if !reflect.DeepEqual(na, na2) {
|
||||
t.Fatalf("encode/decode error messages don't match %#v vs %#v",
|
||||
cua, cua2)
|
||||
na, na2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +58,7 @@ func TestNodeAnnouncementValidation(t *testing.T) {
|
||||
NodeID: nodePubKey,
|
||||
RGBColor: someRGB,
|
||||
Alias: someAlias,
|
||||
Features: someFeatures,
|
||||
}
|
||||
|
||||
dataToSign, _ := na.DataToSign()
|
||||
@@ -73,6 +80,7 @@ func TestNodeAnnouncementPayloadLength(t *testing.T) {
|
||||
RGBColor: someRGB,
|
||||
Alias: someAlias,
|
||||
Addresses: someAddresses,
|
||||
Features: someFeatures,
|
||||
}
|
||||
|
||||
var b bytes.Buffer
|
||||
@@ -81,9 +89,9 @@ func TestNodeAnnouncementPayloadLength(t *testing.T) {
|
||||
}
|
||||
|
||||
serializedLength := uint32(b.Len())
|
||||
if serializedLength != 164 {
|
||||
if serializedLength != 167 {
|
||||
t.Fatalf("payload length estimate is incorrect: expected %v "+
|
||||
"got %v", 164, serializedLength)
|
||||
"got %v", 167, serializedLength)
|
||||
}
|
||||
|
||||
if na.MaxPayloadLength(0) != 8192 {
|
||||
|
Reference in New Issue
Block a user