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
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"image/color"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"unicode/utf8"
|
||||
)
|
||||
@@ -98,7 +97,7 @@ type NodeAnnouncement struct {
|
||||
// properly validate the set of signatures that cover these new fields,
|
||||
// and ensure we're able to make upgrades to the network in a forwards
|
||||
// compatible manner.
|
||||
ExtraOpaqueData []byte
|
||||
ExtraOpaqueData ExtraOpaqueData
|
||||
}
|
||||
|
||||
// A compile time check to ensure NodeAnnouncement implements the
|
||||
@@ -110,7 +109,7 @@ var _ Message = (*NodeAnnouncement)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (a *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||
err := ReadElements(r,
|
||||
return ReadElements(r,
|
||||
&a.Signature,
|
||||
&a.Features,
|
||||
&a.Timestamp,
|
||||
@@ -118,24 +117,8 @@ func (a *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||
&a.RGBColor,
|
||||
&a.Alias,
|
||||
&a.Addresses,
|
||||
&a.ExtraOpaqueData,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Now that we've read out all the fields that we explicitly know of,
|
||||
// we'll collect the remainder into the ExtraOpaqueData field. If there
|
||||
// aren't any bytes, then we'll snip off the slice to avoid carrying
|
||||
// around excess capacity.
|
||||
a.ExtraOpaqueData, err = ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(a.ExtraOpaqueData) == 0 {
|
||||
a.ExtraOpaqueData = nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target NodeAnnouncement into the passed io.Writer
|
||||
@@ -167,7 +150,7 @@ func (a *NodeAnnouncement) MsgType() MessageType {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (a *NodeAnnouncement) MaxPayloadLength(pver uint32) uint32 {
|
||||
return 65533
|
||||
return MaxMsgBody
|
||||
}
|
||||
|
||||
// DataToSign returns the part of the message that should be signed.
|
||||
|
||||
Reference in new issue
Block a user