lnwire: add fuzz tests for new dynamic commitment message types
This commit is contained in:
1 parent
3e84d22eeb
commit
564bf852bb
2 files changed
+46
No files matched your search
@@ -577,6 +577,39 @@ func FuzzUpdateFulfillHTLC(f *testing.F) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FuzzDynPropose(f *testing.F) {
|
||||||
|
f.Fuzz(func(t *testing.T, data []byte) {
|
||||||
|
// Prefix with DynPropose.
|
||||||
|
data = prefixWithMsgType(data, MsgDynPropose)
|
||||||
|
|
||||||
|
// Pass the message into our general fuzz harness for wire
|
||||||
|
// messages!
|
||||||
|
harness(t, data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func FuzzDynReject(f *testing.F) {
|
||||||
|
f.Fuzz(func(t *testing.T, data []byte) {
|
||||||
|
// Prefix with DynReject.
|
||||||
|
data = prefixWithMsgType(data, MsgDynReject)
|
||||||
|
|
||||||
|
// Pass the message into our general fuzz harness for wire
|
||||||
|
// messages!
|
||||||
|
harness(t, data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func FuzzDynAck(f *testing.F) {
|
||||||
|
f.Fuzz(func(t *testing.T, data []byte) {
|
||||||
|
// Prefix with DynReject.
|
||||||
|
data = prefixWithMsgType(data, MsgDynAck)
|
||||||
|
|
||||||
|
// Pass the message into our general fuzz harness for wire
|
||||||
|
// messages!
|
||||||
|
harness(t, data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func FuzzCustomMessage(f *testing.F) {
|
func FuzzCustomMessage(f *testing.F) {
|
||||||
f.Fuzz(func(t *testing.T, data []byte, customMessageType uint16) {
|
f.Fuzz(func(t *testing.T, data []byte, customMessageType uint16) {
|
||||||
if customMessageType < uint16(CustomTypeStart) {
|
if customMessageType < uint16(CustomTypeStart) {
|
||||||
|
|||||||
@@ -800,6 +800,13 @@ func TestLightningWireProtocol(t *testing.T) {
|
|||||||
|
|
||||||
v[0] = reflect.ValueOf(dr)
|
v[0] = reflect.ValueOf(dr)
|
||||||
},
|
},
|
||||||
|
MsgDynAck: func(v []reflect.Value, r *rand.Rand) {
|
||||||
|
var da DynAck
|
||||||
|
|
||||||
|
rand.Read(da.ChanID[:])
|
||||||
|
|
||||||
|
v[0] = reflect.ValueOf(da)
|
||||||
|
},
|
||||||
MsgCommitSig: func(v []reflect.Value, r *rand.Rand) {
|
MsgCommitSig: func(v []reflect.Value, r *rand.Rand) {
|
||||||
req := NewCommitSig()
|
req := NewCommitSig()
|
||||||
if _, err := r.Read(req.ChanID[:]); err != nil {
|
if _, err := r.Read(req.ChanID[:]); err != nil {
|
||||||
@@ -1257,6 +1264,12 @@ func TestLightningWireProtocol(t *testing.T) {
|
|||||||
return mainScenario(&m)
|
return mainScenario(&m)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
msgType: MsgDynAck,
|
||||||
|
scenario: func(m DynAck) bool {
|
||||||
|
return mainScenario(&m)
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
msgType: MsgUpdateAddHTLC,
|
msgType: MsgUpdateAddHTLC,
|
||||||
scenario: func(m UpdateAddHTLC) bool {
|
scenario: func(m UpdateAddHTLC) bool {
|
||||||
|
|||||||
Reference in new issue
Block a user