mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 07:00:55 +02:00
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:
committed by
Johan T. Halseth
parent
a603ac4938
commit
9a6bb19770
@@ -24,6 +24,11 @@ type FundingCreated struct {
|
||||
// CommitSig is Alice's signature from Bob's version of the commitment
|
||||
// transaction.
|
||||
CommitSig 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
|
||||
}
|
||||
|
||||
// A compile time check to ensure FundingCreated implements the lnwire.Message
|
||||
@@ -36,7 +41,10 @@ var _ Message = (*FundingCreated)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (f *FundingCreated) Encode(w io.Writer, pver uint32) error {
|
||||
return WriteElements(w, f.PendingChannelID[:], f.FundingPoint, f.CommitSig)
|
||||
return WriteElements(
|
||||
w, f.PendingChannelID[:], f.FundingPoint, f.CommitSig,
|
||||
f.ExtraData,
|
||||
)
|
||||
}
|
||||
|
||||
// Decode deserializes the serialized FundingCreated stored in the passed
|
||||
@@ -45,7 +53,10 @@ func (f *FundingCreated) Encode(w io.Writer, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (f *FundingCreated) Decode(r io.Reader, pver uint32) error {
|
||||
return ReadElements(r, f.PendingChannelID[:], &f.FundingPoint, &f.CommitSig)
|
||||
return ReadElements(
|
||||
r, f.PendingChannelID[:], &f.FundingPoint, &f.CommitSig,
|
||||
&f.ExtraData,
|
||||
)
|
||||
}
|
||||
|
||||
// MsgType returns the uint32 code which uniquely identifies this message as a
|
||||
@@ -61,6 +72,5 @@ func (f *FundingCreated) MsgType() MessageType {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (f *FundingCreated) MaxPayloadLength(uint32) uint32 {
|
||||
// 32 + 32 + 2 + 64
|
||||
return 130
|
||||
return MaxMsgBody
|
||||
}
|
||||
|
Reference in New Issue
Block a user