lnwire: replace all wire msg tests with a single property-based test

This commit does away with all the old manual message equality tests
and replace it with a single property-based test that uses the
testing/quick package. This test uses a single scenario which MUST hold
for all the messages type and all possible messages generated for those
types. As a result we are able to do away with all the prior manually
generated test data as the fuzzer to scan the input space looking for a
message that violates the scenario.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-04-19 16:17:00 -07:00
1 parent febc8c399a
commit e3686cbc69
23 files changed
+583 -853

No files matched your search

-32
View File
@@ -1,32 +0,0 @@
package lnwire
import (
"bytes"
"reflect"
"testing"
)
func TestCommitSigEncodeDecode(t *testing.T) {
commitSignature := &CommitSig{
ChanID: ChannelID(revHash),
CommitSig: commitSig,
}
// Next encode the CS message into an empty bytes buffer.
var b bytes.Buffer
if err := commitSignature.Encode(&b, 0); err != nil {
t.Fatalf("unable to encode CommitSig: %v", err)
}
// Deserialize the encoded EG message into a new empty struct.
commitSignature2 := &CommitSig{}
if err := commitSignature2.Decode(&b, 0); err != nil {
t.Fatalf("unable to decode CommitSig: %v", err)
}
// Assert equality of the two instances.
if !reflect.DeepEqual(commitSignature, commitSignature2) {
t.Fatalf("encode/decode error messages don't match %#v vs %#v",
commitSignature, commitSignature2)
}
}