Skip to content

Commit b8ff9fb

Browse files
committed
lnwire: define NodeAnnouncement2
In this commit, the lnwire.NodeAnnouncement2 type is defined. This will be used to represent the `node_announcement_2` message used in the Gossip 2 (1.75) protocol.
1 parent e24dd2f commit b8ff9fb

File tree

6 files changed

+873
-0
lines changed

6 files changed

+873
-0
lines changed

lnwire/fuzz_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,30 @@ func FuzzNodeAnnouncement(f *testing.F) {
244244
})
245245
}
246246

247+
func FuzzNodeAnnouncement2(f *testing.F) {
248+
f.Fuzz(func(t *testing.T, data []byte) {
249+
// We can't use require.Equal for Features, since we consider
250+
// the empty map and nil to be equivalent.
251+
assertEq := func(t *testing.T, x, y any) {
252+
require.IsType(t, &NodeAnnouncement2{}, x)
253+
first, _ := x.(*NodeAnnouncement2)
254+
require.IsType(t, &NodeAnnouncement2{}, y)
255+
second, _ := y.(*NodeAnnouncement2)
256+
257+
require.True(
258+
t,
259+
first.Features.Val.Equals(&second.Features.Val),
260+
)
261+
first.Features.Val = *NewRawFeatureVector()
262+
second.Features.Val = *NewRawFeatureVector()
263+
264+
require.Equal(t, first, second)
265+
}
266+
267+
wireMsgHarnessCustom(t, data, MsgNodeAnnouncement2, assertEq)
268+
})
269+
}
270+
247271
func FuzzOpenChannel(f *testing.F) {
248272
f.Fuzz(func(t *testing.T, data []byte) {
249273
// We can't use require.Equal for UpfrontShutdownScript, since

lnwire/message.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const (
6464
MsgReplyChannelRange = 264
6565
MsgGossipTimestampRange = 265
6666
MsgChannelAnnouncement2 = 267
67+
MsgNodeAnnouncement2 = 269
6768
MsgChannelUpdate2 = 271
6869
MsgKickoffSig = 777
6970

@@ -193,6 +194,8 @@ func (t MessageType) String() string {
193194
return "MsgAnnounceSignatures2"
194195
case MsgChannelAnnouncement2:
195196
return "ChannelAnnouncement2"
197+
case MsgNodeAnnouncement2:
198+
return "NodeAnnouncement2"
196199
case MsgChannelUpdate2:
197200
return "ChannelUpdate2"
198201
default:
@@ -355,6 +358,8 @@ func makeEmptyMessage(msgType MessageType) (Message, error) {
355358
msg = &AnnounceSignatures2{}
356359
case MsgChannelAnnouncement2:
357360
msg = &ChannelAnnouncement2{}
361+
case MsgNodeAnnouncement2:
362+
msg = &NodeAnnouncement2{}
358363
case MsgChannelUpdate2:
359364
msg = &ChannelUpdate2{}
360365
default:

0 commit comments

Comments
 (0)