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 2017-08-28 21:16:03 -05:00 committed by Olaoluwa Osuntokun
parent fc5d307c1a
commit 42a263b29f

@ -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
}