lnd.xprv/lnwire/close_complete.go
Olaoluwa Osuntokun e3686cbc69
lnwire: replace all wire msg tests with a single property-based test
This commit does away with all the old manual message equality tests
and replace it with a single property-based test that uses the
testing/quick package. This test uses a single scenario which MUST hold
for all the messages type and all possible messages generated for those
types. As a result we are able to do away with all the prior manually
generated test data as the fuzzer to scan the input space looking for a
message that violates the scenario.
2017-04-19 16:17:00 -07:00

69 lines
2.2 KiB
Go

package lnwire
import (
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/wire"
"io"
)
// CloseComplete is sent by Bob signalling a fufillment and completion of
// Alice's prior CloseRequest message. After Alice receives Bob's CloseComplete
// message, she is able to broadcast the fully signed transaction executing a
// cooperative closure of the channel.
//
// NOTE: The responder is able to only send a signature without any additional
// message as all transactions are assembled observing BIP 69 which defines a
// cannonical ordering for input/outputs. Therefore, both sides are able to
// arrive at an identical closure transaction as they know the order of the
// inputs/outputs.
type CloseComplete struct {
// ChannelPoint serves to identify which channel is to be closed.
ChannelPoint wire.OutPoint
// ResponderCloseSig is the signature of the responder for the
// transaction which closes the previously active channel.
ResponderCloseSig *btcec.Signature
}
// A compile time check to ensure CloseComplete implements the lnwire.Message
// interface.
var _ Message = (*CloseComplete)(nil)
// Decode deserializes a serialized CloseComplete message stored in the passed
// io.Reader observing the specified protocol version.
//
// This is part of the lnwire.Message interface.
func (c *CloseComplete) Decode(r io.Reader, pver uint32) error {
return readElements(r,
&c.ChannelPoint,
&c.ResponderCloseSig)
}
// Encode serializes the target CloseComplete into the passed io.Writer observing
// the protocol version specified.
//
// This is part of the lnwire.Message interface.
func (c *CloseComplete) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
c.ChannelPoint,
c.ResponderCloseSig)
}
// MsgType returns the integer uniquely identifying this message type on the
// wire.
//
// This is part of the lnwire.Message interface.
func (c *CloseComplete) MsgType() MessageType {
return MsgCloseComplete
}
// MaxPayloadLength returns the maximum allowed payload size for a CloseComplete
// complete message observing the specified protocol version.
//
// This is part of the lnwire.Message interface.
func (c *CloseComplete) MaxPayloadLength(uint32) uint32 {
// 141 + 73 + 32
return 141
}