Merge pull request #7143 from morehouse/test_warning

lnwire: add missing tests for Warning
This commit is contained in:
Oliver Gugger authored and GitHub committed 2022-11-14 17:46:46 +01:00
commit bace8d81fa
3 files changed
+28

No files matched your search

@@ -140,6 +140,9 @@ certain large transactions](https://github.com/lightningnetwork/lnd/pull/7100).
and documentation to reflect and documentation to reflect
this](https://github.com/lightningnetwork/lnd/pull/7142). this](https://github.com/lightningnetwork/lnd/pull/7142).
* [Added missing wire tests for Warning
message](https://github.com/lightningnetwork/lnd/pull/7143).
## `lncli` ## `lncli`
* [Add an `insecure` flag to skip tls auth as well as a `metadata` string slice * [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 flag](https://github.com/lightningnetwork/lnd/pull/6818) that allows the
+11
View File
@@ -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) { func FuzzFundingCreated(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) { f.Fuzz(func(t *testing.T, data []byte) {
// Prefix with MsgFundingCreated. // Prefix with MsgFundingCreated.
+14
View File
@@ -259,6 +259,7 @@ func BenchmarkReadMessage(b *testing.B) {
func makeAllMessages(t testing.TB, r *rand.Rand) []lnwire.Message { func makeAllMessages(t testing.TB, r *rand.Rand) []lnwire.Message {
msgAll := []lnwire.Message{} msgAll := []lnwire.Message{}
msgAll = append(msgAll, newMsgWarning(t, r))
msgAll = append(msgAll, newMsgInit(t, r)) msgAll = append(msgAll, newMsgInit(t, r))
msgAll = append(msgAll, newMsgError(t, r)) msgAll = append(msgAll, newMsgError(t, r))
msgAll = append(msgAll, newMsgPing(t, r)) msgAll = append(msgAll, newMsgPing(t, r))
@@ -293,6 +294,19 @@ func makeAllMessages(t testing.TB, r *rand.Rand) []lnwire.Message {
return msgAll 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 { func newMsgInit(t testing.TB, r io.Reader) *lnwire.Init {
t.Helper() t.Helper()