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:
1 parent
a603ac4938
commit
9a6bb19770
32 files changed
+278
-231
No files matched your search
+8
-14
@@ -15,6 +15,11 @@ type Shutdown struct {
|
||||
|
||||
// Address is the script to which the channel funds will be paid.
|
||||
Address DeliveryAddress
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// DeliveryAddress is used to communicate the address to which funds from a
|
||||
@@ -48,7 +53,7 @@ var _ Message = (*Shutdown)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (s *Shutdown) Decode(r io.Reader, pver uint32) error {
|
||||
return ReadElements(r, &s.ChannelID, &s.Address)
|
||||
return ReadElements(r, &s.ChannelID, &s.Address, &s.ExtraData)
|
||||
}
|
||||
|
||||
// Encode serializes the target Shutdown into the passed io.Writer observing
|
||||
@@ -56,7 +61,7 @@ func (s *Shutdown) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (s *Shutdown) Encode(w io.Writer, pver uint32) error {
|
||||
return WriteElements(w, s.ChannelID, s.Address)
|
||||
return WriteElements(w, s.ChannelID, s.Address, s.ExtraData)
|
||||
}
|
||||
|
||||
// MsgType returns the integer uniquely identifying this message type on the
|
||||
@@ -72,16 +77,5 @@ func (s *Shutdown) MsgType() MessageType {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (s *Shutdown) MaxPayloadLength(pver uint32) uint32 {
|
||||
var length uint32
|
||||
|
||||
// ChannelID - 32bytes
|
||||
length += 32
|
||||
|
||||
// Len - 2 bytes
|
||||
length += 2
|
||||
|
||||
// ScriptPubKey - maximum delivery address size.
|
||||
length += deliveryAddressMaxSize
|
||||
|
||||
return length
|
||||
return MaxMsgBody
|
||||
}
|
||||
Reference in new issue
Block a user