From 258cf6466d936ab99bdb0449f64b96fbf669106d Mon Sep 17 00:00:00 2001 From: Matt Morehouse Date: Fri, 11 Nov 2022 11:42:55 -0600 Subject: [PATCH 1/3] lnwire: add benchmark for Warning --- lnwire/message_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lnwire/message_test.go b/lnwire/message_test.go index b934b928d..f2b0892d7 100644 --- a/lnwire/message_test.go +++ b/lnwire/message_test.go @@ -259,6 +259,7 @@ func BenchmarkReadMessage(b *testing.B) { func makeAllMessages(t testing.TB, r *rand.Rand) []lnwire.Message { msgAll := []lnwire.Message{} + msgAll = append(msgAll, newMsgWarning(t, r)) msgAll = append(msgAll, newMsgInit(t, r)) msgAll = append(msgAll, newMsgError(t, r)) msgAll = append(msgAll, newMsgPing(t, r)) @@ -293,6 +294,19 @@ func makeAllMessages(t testing.TB, r *rand.Rand) []lnwire.Message { return msgAll } +func newMsgWarning(tb testing.TB, r io.Reader) *lnwire.Warning { + tb.Helper() + + msg := lnwire.NewWarning() + + _, err := r.Read(msg.ChanID[:]) + require.NoError(tb, err, "unable to generate chan id") + + msg.Data = createExtraData(tb, r) + + return msg +} + func newMsgInit(t testing.TB, r io.Reader) *lnwire.Init { t.Helper() From f0f99d7e360b457c275a9457003a21060bb7bcf9 Mon Sep 17 00:00:00 2001 From: Matt Morehouse Date: Fri, 11 Nov 2022 11:45:30 -0600 Subject: [PATCH 2/3] lnwire: add fuzz test for Warning --- lnwire/fuzz_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lnwire/fuzz_test.go b/lnwire/fuzz_test.go index ed7088280..4ec35e6dd 100644 --- a/lnwire/fuzz_test.go +++ b/lnwire/fuzz_test.go @@ -264,6 +264,17 @@ func FuzzError(f *testing.F) { }) } +func FuzzWarning(f *testing.F) { + f.Fuzz(func(t *testing.T, data []byte) { + // Prefix with MsgWarning. + data = prefixWithMsgType(data, MsgWarning) + + // Pass the message into our general fuzz harness for wire + // messages! + harness(t, data) + }) +} + func FuzzFundingCreated(f *testing.F) { f.Fuzz(func(t *testing.T, data []byte) { // Prefix with MsgFundingCreated. From 251725fc1151dd3951b76c03aa7f648f75756f79 Mon Sep 17 00:00:00 2001 From: Matt Morehouse Date: Fri, 11 Nov 2022 12:10:19 -0600 Subject: [PATCH 3/3] docs: update release notes --- docs/release-notes/release-notes-0.16.0.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/release-notes/release-notes-0.16.0.md b/docs/release-notes/release-notes-0.16.0.md index 07056586a..7266c5d7c 100644 --- a/docs/release-notes/release-notes-0.16.0.md +++ b/docs/release-notes/release-notes-0.16.0.md @@ -134,6 +134,9 @@ certain large transactions](https://github.com/lightningnetwork/lnd/pull/7100). * [Migrated from go-fuzz to Go 1.18's new standard fuzz testing library](https://github.com/lightningnetwork/lnd/pull/7127). +* [Added missing wire tests for Warning + message](https://github.com/lightningnetwork/lnd/pull/7143). + ## `lncli` * [Add an `insecure` flag to skip tls auth as well as a `metadata` string slice flag](https://github.com/lightningnetwork/lnd/pull/6818) that allows the