don't send the same StopWaitingFrame twice

fixes #229
This commit is contained in:
Marten Seemann
2016-07-30 14:15:45 +07:00
parent b7d2a76811
commit 71243ccccb
4 changed files with 77 additions and 17 deletions

View File

@@ -0,0 +1,35 @@
package ackhandler
import (
"github.com/lucas-clemente/quic-go/frames"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("StopWaitingManager", func() {
var manager *stopWaitingManager
BeforeEach(func() {
manager = &stopWaitingManager{}
})
It("returns nil in the beginning", func() {
Expect(manager.GetStopWaitingFrame()).To(BeNil())
})
It("returns a StopWaitingFrame, when a new ACK arrives", func() {
manager.ReceivedAck(&frames.AckFrame{LargestAcked: 10})
Expect(manager.GetStopWaitingFrame()).To(Equal(&frames.StopWaitingFrame{LeastUnacked: 11}))
})
It("does not decrease the LeastUnacked", func() {
manager.ReceivedAck(&frames.AckFrame{LargestAcked: 10})
manager.ReceivedAck(&frames.AckFrame{LargestAcked: 9})
Expect(manager.GetStopWaitingFrame()).To(Equal(&frames.StopWaitingFrame{LeastUnacked: 11}))
})
It("does not send the same StopWaitingFrame twice", func() {
manager.ReceivedAck(&frames.AckFrame{LargestAcked: 10})
Expect(manager.GetStopWaitingFrame()).ToNot(BeNil())
Expect(manager.GetStopWaitingFrame()).To(BeNil())
})
})