2017-12-12 02:51:45 +00:00
|
|
|
package ackhandler
|
|
|
|
|
|
|
|
import (
|
2018-01-03 19:19:49 +00:00
|
|
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
2017-12-12 02:51:45 +00:00
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("Packet", func() {
|
|
|
|
Context("getting frames for retransmission", func() {
|
2018-01-03 19:19:49 +00:00
|
|
|
ackFrame := &wire.AckFrame{LargestAcked: 13}
|
|
|
|
stopWaitingFrame := &wire.StopWaitingFrame{LeastUnacked: 7331}
|
|
|
|
maxStreamDataFrame := &wire.MaxStreamDataFrame{StreamID: 999}
|
2017-12-12 02:51:45 +00:00
|
|
|
|
2018-01-03 19:19:49 +00:00
|
|
|
streamFrame := &wire.StreamFrame{
|
2017-12-12 02:51:45 +00:00
|
|
|
StreamID: 5,
|
|
|
|
Data: []byte{0x13, 0x37},
|
|
|
|
}
|
|
|
|
|
2018-01-03 19:19:49 +00:00
|
|
|
rstStreamFrame := &wire.RstStreamFrame{
|
2017-12-12 02:51:45 +00:00
|
|
|
StreamID: 555,
|
|
|
|
ErrorCode: 1337,
|
|
|
|
}
|
|
|
|
|
|
|
|
It("returns nil if there are no retransmittable frames", func() {
|
|
|
|
packet := &Packet{
|
2018-01-03 19:19:49 +00:00
|
|
|
Frames: []wire.Frame{ackFrame, stopWaitingFrame},
|
2017-12-12 02:51:45 +00:00
|
|
|
}
|
|
|
|
Expect(packet.GetFramesForRetransmission()).To(BeNil())
|
|
|
|
})
|
|
|
|
|
|
|
|
It("returns all retransmittable frames", func() {
|
|
|
|
packet := &Packet{
|
2018-01-03 19:19:49 +00:00
|
|
|
Frames: []wire.Frame{
|
|
|
|
maxStreamDataFrame,
|
2017-12-12 02:51:45 +00:00
|
|
|
ackFrame,
|
|
|
|
stopWaitingFrame,
|
|
|
|
streamFrame,
|
|
|
|
rstStreamFrame,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
fs := packet.GetFramesForRetransmission()
|
|
|
|
Expect(fs).To(ContainElement(streamFrame))
|
|
|
|
Expect(fs).To(ContainElement(rstStreamFrame))
|
2018-01-03 19:19:49 +00:00
|
|
|
Expect(fs).To(ContainElement(maxStreamDataFrame))
|
2017-12-12 02:51:45 +00:00
|
|
|
Expect(fs).ToNot(ContainElement(stopWaitingFrame))
|
|
|
|
Expect(fs).ToNot(ContainElement(ackFrame))
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|