lnwire: add new TestMessage interface for property tests

In this commit, we add a new `TestMessage` interface for use in property
tests. With this, we'll be able to generate a random instance of a given
message, using the rapid byte stream. This can also eventually be useful
for fuzzing.
This commit is contained in:
Olaoluwa Osuntokun
2025-03-19 15:10:35 -05:00
parent 56a100123b
commit eb877db2ff
25 changed files with 2090 additions and 32 deletions

View File

@@ -27,6 +27,10 @@ type KickoffSig struct {
// interface.
var _ Message = (*KickoffSig)(nil)
// A compile time check to ensure KickoffSig implements the
// lnwire.SizeableMessage interface.
var _ SizeableMessage = (*KickoffSig)(nil)
// Encode serializes the target KickoffSig into the passed bytes.Buffer
// observing the specified protocol version.
//
@@ -54,3 +58,10 @@ func (ks *KickoffSig) Decode(r io.Reader, _ uint32) error {
//
// This is part of the lnwire.Message interface.
func (ks *KickoffSig) MsgType() MessageType { return MsgKickoffSig }
// SerializedSize returns the serialized size of the message in bytes.
//
// This is part of the lnwire.SizeableMessage interface.
func (ks *KickoffSig) SerializedSize() (uint32, error) {
return MessageSerializedSize(ks)
}