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

-30
View File
@@ -1,30 +0,0 @@
package lnwire
import (
"bytes"
"reflect"
"testing"
)
func TestUpdateFufillHTLCEncodeDecode(t *testing.T) {
// First create a new HTLCSR message.
settleReq := NewUpdateFufillHTLC(ChannelID(revHash), 23, revHash)
// Next encode the HTLCSR message into an empty bytes buffer.
var b bytes.Buffer
if err := settleReq.Encode(&b, 0); err != nil {
t.Fatalf("unable to encode UpdateFufillHTLC: %v", err)
}
// Deserialize the encoded SFOP message into a new empty struct.
settleReq2 := &UpdateFufillHTLC{}
if err := settleReq2.Decode(&b, 0); err != nil {
t.Fatalf("unable to decode UpdateFufillHTLC: %v", err)
}
// Assert equality of the two instances.
if !reflect.DeepEqual(settleReq, settleReq2) {
t.Fatalf("encode/decode error messages don't match %#v vs %#v",
settleReq, settleReq2)
}
}