wire: Correct fuzz test for MsgCommitSig.

This corrects the fuzz test in TestLightningWireProtocol for
MsgCommitSig to avoid creating an empty slice since the decoded message
only creates a slice when there are greater than zero signatures and an
empty slice is not considered equal to a nil slice under reflection.

This can be tested by running the TestLightningWireProtocol 1000 times
in a loop with and without this change.
This commit is contained in:
Dave Collins authored and Olaoluwa Osuntokun committed 2017-08-30 18:07:33 -07:00
1 parent fc5d307c1a
commit 42a263b29f
1 file changed
+6 -1
+6 -1
View File
@@ -316,8 +316,13 @@ func TestLightningWireProtocol(t *testing.T) {
}
req.CommitSig = testSig
// Only create the slice if there will be any signatures
// in it to prevent false positive test failures due to
// an empty slice versus a nil slice.
numSigs := uint16(r.Int31n(1020))
req.HtlcSigs = make([]*btcec.Signature, numSigs)
if numSigs > 0 {
req.HtlcSigs = make([]*btcec.Signature, numSigs)
}
for i := 0; i < int(numSigs); i++ {
req.HtlcSigs[i] = testSig
}