mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
9a6bb19770
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.
81 lines
2.6 KiB
Go
81 lines
2.6 KiB
Go
package lnwire
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
|
)
|
|
|
|
// ReplyShortChanIDsEnd is a message that marks the end of a streaming message
|
|
// response to an initial QueryShortChanIDs message. This marks that the
|
|
// receiver of the original QueryShortChanIDs for the target chain has either
|
|
// sent all adequate responses it knows of, or doesn't know of any short chan
|
|
// ID's for the target chain.
|
|
type ReplyShortChanIDsEnd struct {
|
|
// ChainHash denotes the target chain that we're respond to a short
|
|
// chan ID query for.
|
|
ChainHash chainhash.Hash
|
|
|
|
// Complete will be set to 0 if we don't know of the chain that the
|
|
// remote peer sent their query for. Otherwise, we'll set this to 1 in
|
|
// order to indicate that we've sent all known responses for the prior
|
|
// set of short chan ID's in the corresponding QueryShortChanIDs
|
|
// message.
|
|
Complete uint8
|
|
|
|
// 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
|
|
}
|
|
|
|
// NewReplyShortChanIDsEnd creates a new empty ReplyShortChanIDsEnd message.
|
|
func NewReplyShortChanIDsEnd() *ReplyShortChanIDsEnd {
|
|
return &ReplyShortChanIDsEnd{}
|
|
}
|
|
|
|
// A compile time check to ensure ReplyShortChanIDsEnd implements the
|
|
// lnwire.Message interface.
|
|
var _ Message = (*ReplyShortChanIDsEnd)(nil)
|
|
|
|
// Decode deserializes a serialized ReplyShortChanIDsEnd message stored in the
|
|
// passed io.Reader observing the specified protocol version.
|
|
//
|
|
// This is part of the lnwire.Message interface.
|
|
func (c *ReplyShortChanIDsEnd) Decode(r io.Reader, pver uint32) error {
|
|
return ReadElements(r,
|
|
c.ChainHash[:],
|
|
&c.Complete,
|
|
&c.ExtraData,
|
|
)
|
|
}
|
|
|
|
// Encode serializes the target ReplyShortChanIDsEnd into the passed io.Writer
|
|
// observing the protocol version specified.
|
|
//
|
|
// This is part of the lnwire.Message interface.
|
|
func (c *ReplyShortChanIDsEnd) Encode(w io.Writer, pver uint32) error {
|
|
return WriteElements(w,
|
|
c.ChainHash[:],
|
|
c.Complete,
|
|
c.ExtraData,
|
|
)
|
|
}
|
|
|
|
// MsgType returns the integer uniquely identifying this message type on the
|
|
// wire.
|
|
//
|
|
// This is part of the lnwire.Message interface.
|
|
func (c *ReplyShortChanIDsEnd) MsgType() MessageType {
|
|
return MsgReplyShortChanIDsEnd
|
|
}
|
|
|
|
// MaxPayloadLength returns the maximum allowed payload size for a
|
|
// ReplyShortChanIDsEnd complete message observing the specified protocol
|
|
// version.
|
|
//
|
|
// This is part of the lnwire.Message interface.
|
|
func (c *ReplyShortChanIDsEnd) MaxPayloadLength(uint32) uint32 {
|
|
return MaxMsgBody
|
|
}
|