mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-05 18:03:09 +02:00
lnwire: add FuzzParseRawSignature test
Test parsing and serialization of raw DER-encoded signatures.
This commit is contained in:
@@ -822,3 +822,24 @@ func FuzzCustomMessage(f *testing.F) {
|
||||
harness(t, data)
|
||||
})
|
||||
}
|
||||
|
||||
// FuzzParseRawSignature tests that our DER-encoded signature parsing does not
|
||||
// panic for arbitrary inputs and that serializing and reparsing the signatures
|
||||
// does not mutate them.
|
||||
func FuzzParseRawSignature(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
sig, err := NewSigFromRawSignature(data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
sig2, err := NewSigFromRawSignature(sig.ToSignatureBytes())
|
||||
if err != nil {
|
||||
t.Fatalf("failed to reparse signature: %v", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(sig, sig2) {
|
||||
t.Fatalf("signature mismatch: %v != %v", sig, sig2)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user