improve frames coverage and fix a small stream frame parsing bug

ref #241
This commit is contained in:
Lucas Clemente
2016-08-02 13:11:30 +02:00
parent edc24ea795
commit b9abc5b2a1
11 changed files with 266 additions and 167 deletions

View File

@@ -35,6 +35,16 @@ var _ = Describe("ConnectionCloseFrame", func() {
_, err := ParseConnectionCloseFrame(b)
Expect(err).To(MatchError(qerr.Error(qerr.InvalidConnectionCloseData, "reason phrase too long")))
})
It("errors on EOFs", func() {
data := []byte{0x40, 0x19, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x4e, 0x6f, 0x20, 0x72, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x20, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e}
_, err := ParseConnectionCloseFrame(bytes.NewReader(data))
Expect(err).NotTo(HaveOccurred())
for i := range data {
_, err := ParseConnectionCloseFrame(bytes.NewReader(data[0:i]))
Expect(err).To(HaveOccurred())
}
})
})
Context("when writing", func() {