Skip to content

Commit 5235f3b

Browse files
authored
Merge pull request #9623 from Roasbeef/size-msg-test-msg
Size msg test msg
2 parents 5d92172 + 05a6b68 commit 5235f3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2635
-1781
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,5 @@ coverage.txt
8080
# Release build directory (to avoid build.vcs.modified Golang build tag to be
8181
# set to true by having untracked files in the working directory).
8282
/lnd-*/
83+
84+
.aider*

lnwire/accept_channel.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ type AcceptChannel struct {
128128
// interface.
129129
var _ Message = (*AcceptChannel)(nil)
130130

131+
// A compile time check to ensure AcceptChannel implements the
132+
// lnwire.SizeableMessage interface.
133+
var _ SizeableMessage = (*AcceptChannel)(nil)
134+
131135
// Encode serializes the target AcceptChannel into the passed io.Writer
132136
// implementation. Serialization will observe the rules defined by the passed
133137
// protocol version.
@@ -281,3 +285,10 @@ func (a *AcceptChannel) Decode(r io.Reader, pver uint32) error {
281285
func (a *AcceptChannel) MsgType() MessageType {
282286
return MsgAcceptChannel
283287
}
288+
289+
// SerializedSize returns the serialized size of the message in bytes.
290+
//
291+
// This is part of the lnwire.SizeableMessage interface.
292+
func (a *AcceptChannel) SerializedSize() (uint32, error) {
293+
return MessageSerializedSize(a)
294+
}

lnwire/announcement_signatures.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ type AnnounceSignatures1 struct {
4747
// lnwire.Message interface.
4848
var _ Message = (*AnnounceSignatures1)(nil)
4949

50+
// A compile time check to ensure AnnounceSignatures1 implements the
51+
// lnwire.SizeableMessage interface.
52+
var _ SizeableMessage = (*AnnounceSignatures1)(nil)
53+
5054
// A compile time check to ensure AnnounceSignatures1 implements the
5155
// lnwire.AnnounceSignatures interface.
5256
var _ AnnounceSignatures = (*AnnounceSignatures1)(nil)
@@ -97,6 +101,13 @@ func (a *AnnounceSignatures1) MsgType() MessageType {
97101
return MsgAnnounceSignatures
98102
}
99103

104+
// SerializedSize returns the serialized size of the message in bytes.
105+
//
106+
// This is part of the lnwire.SizeableMessage interface.
107+
func (a *AnnounceSignatures1) SerializedSize() (uint32, error) {
108+
return MessageSerializedSize(a)
109+
}
110+
100111
// SCID returns the ShortChannelID of the channel.
101112
//
102113
// This is part of the lnwire.AnnounceSignatures interface.

lnwire/announcement_signatures_2.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ type AnnounceSignatures2 struct {
4141
// lnwire.Message interface.
4242
var _ Message = (*AnnounceSignatures2)(nil)
4343

44+
// A compile time check to ensure AnnounceSignatures2 implements the
45+
// lnwire.SizeableMessage interface.
46+
var _ SizeableMessage = (*AnnounceSignatures2)(nil)
47+
4448
// Decode deserializes a serialized AnnounceSignatures2 stored in the passed
4549
// io.Reader observing the specified protocol version.
4650
//
@@ -82,6 +86,13 @@ func (a *AnnounceSignatures2) MsgType() MessageType {
8286
return MsgAnnounceSignatures2
8387
}
8488

89+
// SerializedSize returns the serialized size of the message in bytes.
90+
//
91+
// This is part of the lnwire.SizeableMessage interface.
92+
func (a *AnnounceSignatures2) SerializedSize() (uint32, error) {
93+
return MessageSerializedSize(a)
94+
}
95+
8596
// SCID returns the ShortChannelID of the channel.
8697
//
8798
// NOTE: this is part of the AnnounceSignatures interface.

lnwire/channel_announcement.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ type ChannelAnnouncement1 struct {
6262
// lnwire.Message interface.
6363
var _ Message = (*ChannelAnnouncement1)(nil)
6464

65+
// A compile time check to ensure ChannelAnnouncement1 implements the
66+
// lnwire.SizeableMessage interface.
67+
var _ SizeableMessage = (*ChannelAnnouncement1)(nil)
68+
6569
// Decode deserializes a serialized ChannelAnnouncement stored in the passed
6670
// io.Reader observing the specified protocol version.
6771
//
@@ -143,6 +147,13 @@ func (a *ChannelAnnouncement1) MsgType() MessageType {
143147
return MsgChannelAnnouncement
144148
}
145149

150+
// SerializedSize returns the serialized size of the message in bytes.
151+
//
152+
// This is part of the lnwire.SizeableMessage interface.
153+
func (a *ChannelAnnouncement1) SerializedSize() (uint32, error) {
154+
return MessageSerializedSize(a)
155+
}
156+
146157
// DataToSign is used to retrieve part of the announcement message which should
147158
// be signed.
148159
func (a *ChannelAnnouncement1) DataToSign() ([]byte, error) {

lnwire/channel_announcement_2.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,21 @@ func (c *ChannelAnnouncement2) MsgType() MessageType {
194194
return MsgChannelAnnouncement2
195195
}
196196

197+
// SerializedSize returns the serialized size of the message in bytes.
198+
//
199+
// This is part of the lnwire.SizeableMessage interface.
200+
func (c *ChannelAnnouncement2) SerializedSize() (uint32, error) {
201+
return MessageSerializedSize(c)
202+
}
203+
197204
// A compile time check to ensure ChannelAnnouncement2 implements the
198205
// lnwire.Message interface.
199206
var _ Message = (*ChannelAnnouncement2)(nil)
200207

208+
// A compile time check to ensure ChannelAnnouncement2 implements the
209+
// lnwire.SizeableMessage interface.
210+
var _ SizeableMessage = (*ChannelAnnouncement2)(nil)
211+
201212
// Node1KeyBytes returns the bytes representing the public key of node 1 in the
202213
// channel.
203214
//

lnwire/channel_ready.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ func NewChannelReady(cid ChannelID, npcp *btcec.PublicKey) *ChannelReady {
6363
// interface.
6464
var _ Message = (*ChannelReady)(nil)
6565

66+
// A compile time check to ensure ChannelReady implements the
67+
// lnwire.SizeableMessage interface.
68+
var _ SizeableMessage = (*ChannelReady)(nil)
69+
6670
// Decode deserializes the serialized ChannelReady message stored in the
6771
// passed io.Reader into the target ChannelReady using the deserialization
6872
// rules defined by the passed protocol version.
@@ -170,3 +174,10 @@ func (c *ChannelReady) Encode(w *bytes.Buffer, _ uint32) error {
170174
func (c *ChannelReady) MsgType() MessageType {
171175
return MsgChannelReady
172176
}
177+
178+
// SerializedSize returns the serialized size of the message in bytes.
179+
//
180+
// This is part of the lnwire.SizeableMessage interface.
181+
func (c *ChannelReady) SerializedSize() (uint32, error) {
182+
return MessageSerializedSize(c)
183+
}

lnwire/channel_reestablish.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ type ChannelReestablish struct {
9999
// lnwire.Message interface.
100100
var _ Message = (*ChannelReestablish)(nil)
101101

102+
// A compile time check to ensure ChannelReestablish implements the
103+
// lnwire.SizeableMessage interface.
104+
var _ SizeableMessage = (*ChannelReestablish)(nil)
105+
102106
// Encode serializes the target ChannelReestablish into the passed io.Writer
103107
// observing the protocol version specified.
104108
//
@@ -234,3 +238,10 @@ func (a *ChannelReestablish) Decode(r io.Reader, pver uint32) error {
234238
func (a *ChannelReestablish) MsgType() MessageType {
235239
return MsgChannelReestablish
236240
}
241+
242+
// SerializedSize returns the serialized size of the message in bytes.
243+
//
244+
// This is part of the lnwire.SizeableMessage interface.
245+
func (a *ChannelReestablish) SerializedSize() (uint32, error) {
246+
return MessageSerializedSize(a)
247+
}

lnwire/channel_update.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ type ChannelUpdate1 struct {
124124
// interface.
125125
var _ Message = (*ChannelUpdate1)(nil)
126126

127+
// A compile time check to ensure ChannelUpdate1 implements the
128+
// lnwire.SizeableMessage interface.
129+
var _ SizeableMessage = (*ChannelUpdate1)(nil)
130+
127131
// Decode deserializes a serialized ChannelUpdate stored in the passed
128132
// io.Reader observing the specified protocol version.
129133
//
@@ -367,3 +371,10 @@ func (a *ChannelUpdate1) SetSCID(scid ShortChannelID) {
367371
// A compile time assertion to ensure ChannelUpdate1 implements the
368372
// ChannelUpdate interface.
369373
var _ ChannelUpdate = (*ChannelUpdate1)(nil)
374+
375+
// SerializedSize returns the serialized size of the message in bytes.
376+
//
377+
// This is part of the lnwire.SizeableMessage interface.
378+
func (a *ChannelUpdate1) SerializedSize() (uint32, error) {
379+
return MessageSerializedSize(a)
380+
}

lnwire/channel_update_2.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,13 @@ func (c *ChannelUpdate2) MsgType() MessageType {
241241
return MsgChannelUpdate2
242242
}
243243

244+
// SerializedSize returns the serialized size of the message in bytes.
245+
//
246+
// This is part of the lnwire.SizeableMessage interface.
247+
func (c *ChannelUpdate2) SerializedSize() (uint32, error) {
248+
return MessageSerializedSize(c)
249+
}
250+
244251
func (c *ChannelUpdate2) ExtraData() ExtraOpaqueData {
245252
return c.ExtraOpaqueData
246253
}

0 commit comments

Comments
 (0)