Merge pull request #1471 from cfromknecht/lnwire-query-sids-corpus
[lnwire]: align behavior of query sids corpus for zero-length slices
This commit is contained in:
commit
bc04bfdde2
@ -668,11 +668,9 @@ func TestLightningWireProtocol(t *testing.T) {
|
|||||||
|
|
||||||
numChanIDs := rand.Int31n(5000)
|
numChanIDs := rand.Int31n(5000)
|
||||||
|
|
||||||
req.ShortChanIDs = make([]ShortChannelID, numChanIDs)
|
|
||||||
for i := int32(0); i < numChanIDs; i++ {
|
for i := int32(0); i < numChanIDs; i++ {
|
||||||
req.ShortChanIDs[i] = NewShortChanIDFromInt(
|
req.ShortChanIDs = append(req.ShortChanIDs,
|
||||||
uint64(r.Int63()),
|
NewShortChanIDFromInt(uint64(r.Int63())))
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v[0] = reflect.ValueOf(req)
|
v[0] = reflect.ValueOf(req)
|
||||||
|
@ -146,10 +146,13 @@ func decodeShortChanIDs(r io.Reader) (ShortChanIDEncoding, []ShortChannelID, err
|
|||||||
// compute the number of bytes encoded based on the size of the
|
// compute the number of bytes encoded based on the size of the
|
||||||
// query body.
|
// query body.
|
||||||
numShortChanIDs := len(queryBody) / 8
|
numShortChanIDs := len(queryBody) / 8
|
||||||
shortChanIDs := make([]ShortChannelID, numShortChanIDs)
|
if numShortChanIDs == 0 {
|
||||||
|
return encodingType, nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Finally, we'll read out the exact number of short channel
|
// Finally, we'll read out the exact number of short channel
|
||||||
// ID's to conclude our parsing.
|
// ID's to conclude our parsing.
|
||||||
|
shortChanIDs := make([]ShortChannelID, numShortChanIDs)
|
||||||
bodyReader := bytes.NewReader(queryBody)
|
bodyReader := bytes.NewReader(queryBody)
|
||||||
for i := 0; i < numShortChanIDs; i++ {
|
for i := 0; i < numShortChanIDs; i++ {
|
||||||
if err := readElements(bodyReader, &shortChanIDs[i]); err != nil {
|
if err := readElements(bodyReader, &shortChanIDs[i]); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user