tlv/stream: create MaxRecordSize, remove lnwire import, add test

This commit is contained in:
Conner Fromknecht committed 2019-08-21 18:12:57 -07:00
1 parent dfd1b38648
commit 1cc48ceaf5
2 files changed
+20 -3

No files matched your search

+9
View File
@@ -49,6 +49,8 @@ type N1 struct {
nodeAmts nodeAmts
cltvDelta uint16
alias []byte
stream *tlv.Stream
}
@@ -66,6 +68,7 @@ func NewN1() *N1 {
tlv.MakePrimitiveRecord(2, &n.scid),
tlv.MakeStaticRecord(3, &n.nodeAmts, 49, ENodeAmts, DNodeAmts),
tlv.MakePrimitiveRecord(254, &n.cltvDelta),
tlv.MakePrimitiveRecord(401, &n.alias),
)
return n
@@ -396,6 +399,12 @@ var tlvDecodingFailureTests = []struct {
bytes: []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00},
expErr: tlv.ErrStreamNotCanonical,
},
{
name: "absurd record length",
bytes: []byte{0xfd, 0x01, 0x91, 0xfe, 0xff, 0xff, 0xff, 0xff},
expErr: tlv.ErrRecordTooLarge,
skipN2: true,
},
}
// TestTLVDecodingSuccess asserts that the TLV parser fails to decode invalid