add methods needed for connection-level FlowController

ref #39
This commit is contained in:
Marten Seemann
2016-05-18 12:28:00 +07:00
parent e0801262bc
commit 9ecbfa65ac
3 changed files with 40 additions and 10 deletions

View File

@@ -105,16 +105,24 @@ var _ = Describe("Flow controller", func() {
It("updates the highestReceived", func() {
controller.highestReceived = 1337
controller.UpdateHighestReceived(1338)
increment := controller.UpdateHighestReceived(1338)
Expect(increment).To(Equal(protocol.ByteCount(1338 - 1337)))
Expect(controller.highestReceived).To(Equal(protocol.ByteCount(1338)))
})
It("does not decrease the highestReceived", func() {
controller.highestReceived = 1337
controller.UpdateHighestReceived(1000)
increment := controller.UpdateHighestReceived(1000)
Expect(increment).To(Equal(protocol.ByteCount(0)))
Expect(controller.highestReceived).To(Equal(protocol.ByteCount(1337)))
})
It("increases the highestReceived by a given increment", func() {
controller.highestReceived = 1337
controller.IncrementHighestReceived(123)
Expect(controller.highestReceived).To(Equal(protocol.ByteCount(1337 + 123)))
})
It("detects a flow control violation", func() {
controller.UpdateHighestReceived(receiveFlowControlWindow + 1)
Expect(controller.CheckFlowControlViolation()).To(BeTrue())