lnwire: prep wire messages for TLV extensions

Messages:
- UpdateFulfillHTLC
- UpdateFee
- UpdateFailMalformedHTLC
- UpdateFailHTLC
- UpdateAddHTLC
- Shutdown
- RevokeAndAck
- ReplyShortChanIDsEnd
- ReplyChannelRange
- QueryShortChanIDs
- QueryChannelRange
- NodeAnnouncement
- Init
- GossipTimestampRange
- FundingSigned
- FundingLocked
- FundingCreated
- CommitSig
- ClosingSigned
- ChannelUpdate
- ChannelReestablish
- ChannelAnnouncement
- AnnounceSignatures

lnwire: update quickcheck tests, use constant for Error

multi: update unit tests to pass deep equal assertions with messages

In this commit, we update a series of unit tests in the code base to now
pass due to the new wire message encode/decode logic. In many instances,
we'll now manually set the extra bytes to an empty byte slice to avoid
comparisons that fail due to one message having an empty byte slice and
the other having a nil pointer.
This commit is contained in:
Olaoluwa Osuntokun
2020-01-27 17:25:36 -08:00
committed by Johan T. Halseth
parent a603ac4938
commit 9a6bb19770
32 changed files with 278 additions and 231 deletions

View File

@@ -27,6 +27,11 @@ type ClosingSigned struct {
// Signature is for the proposed channel close transaction.
Signature Sig
// ExtraData is the set of data that was appended to this message to
// fill out the full maximum transport message size. These fields can
// be used to specify optional data such as custom TLV fields.
ExtraData ExtraOpaqueData
}
// NewClosingSigned creates a new empty ClosingSigned message.
@@ -49,7 +54,9 @@ var _ Message = (*ClosingSigned)(nil)
//
// This is part of the lnwire.Message interface.
func (c *ClosingSigned) Decode(r io.Reader, pver uint32) error {
return ReadElements(r, &c.ChannelID, &c.FeeSatoshis, &c.Signature)
return ReadElements(
r, &c.ChannelID, &c.FeeSatoshis, &c.Signature, &c.ExtraData,
)
}
// Encode serializes the target ClosingSigned into the passed io.Writer
@@ -57,7 +64,9 @@ func (c *ClosingSigned) Decode(r io.Reader, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (c *ClosingSigned) Encode(w io.Writer, pver uint32) error {
return WriteElements(w, c.ChannelID, c.FeeSatoshis, c.Signature)
return WriteElements(
w, c.ChannelID, c.FeeSatoshis, c.Signature, c.ExtraData,
)
}
// MsgType returns the integer uniquely identifying this message type on the
@@ -73,16 +82,5 @@ func (c *ClosingSigned) MsgType() MessageType {
//
// This is part of the lnwire.Message interface.
func (c *ClosingSigned) MaxPayloadLength(uint32) uint32 {
var length uint32
// ChannelID - 32 bytes
length += 32
// FeeSatoshis - 8 bytes
length += 8
// Signature - 64 bytes
length += 64
return length
return MaxMsgBody
}