mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-05 13:17:36 +03:00
add logging aliases for frames, create a logging.STREAM and CRYPTO frame
This commit is contained in:
parent
fea17a671b
commit
ed120f670c
12 changed files with 300 additions and 184 deletions
44
internal/logutils/frame_test.go
Normal file
44
internal/logutils/frame_test.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package logutils
|
||||
|
||||
import (
|
||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||
"github.com/lucas-clemente/quic-go/logging"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("CRYPTO frame", func() {
|
||||
It("converts CRYPTO frames", func() {
|
||||
f := ConvertFrame(&wire.CryptoFrame{
|
||||
Offset: 1234,
|
||||
Data: []byte("foobar"),
|
||||
})
|
||||
Expect(f).To(BeAssignableToTypeOf(&logging.CryptoFrame{}))
|
||||
cf := f.(*logging.CryptoFrame)
|
||||
Expect(cf.Offset).To(Equal(logging.ByteCount(1234)))
|
||||
Expect(cf.Length).To(Equal(logging.ByteCount(6)))
|
||||
})
|
||||
|
||||
It("converts STREAM frames", func() {
|
||||
f := ConvertFrame(&wire.StreamFrame{
|
||||
StreamID: 42,
|
||||
Offset: 1234,
|
||||
Data: []byte("foo"),
|
||||
Fin: true,
|
||||
})
|
||||
Expect(f).To(BeAssignableToTypeOf(&logging.StreamFrame{}))
|
||||
sf := f.(*logging.StreamFrame)
|
||||
Expect(sf.StreamID).To(Equal(logging.StreamID(42)))
|
||||
Expect(sf.Offset).To(Equal(logging.ByteCount(1234)))
|
||||
Expect(sf.Length).To(Equal(logging.ByteCount(3)))
|
||||
Expect(sf.Fin).To(BeTrue())
|
||||
})
|
||||
|
||||
It("converts other frames", func() {
|
||||
f := ConvertFrame(&wire.MaxDataFrame{MaximumData: 1234})
|
||||
Expect(f).To(BeAssignableToTypeOf(&logging.MaxDataFrame{}))
|
||||
Expect(f).ToNot(BeAssignableToTypeOf(&logging.MaxStreamDataFrame{}))
|
||||
mdf := f.(*logging.MaxDataFrame)
|
||||
Expect(mdf.MaximumData).To(Equal(logging.ByteCount(1234)))
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue