keep track of highest byte received in FlowController

ref #39
This commit is contained in:
Marten Seemann
2016-05-18 09:32:36 +07:00
parent d6ef71a54c
commit daeb601cdc
3 changed files with 30 additions and 5 deletions

View File

@@ -103,12 +103,26 @@ var _ = Describe("Flow controller", func() {
Expect(updateNecessary).To(BeFalse())
})
It("updates the highestReceived", func() {
controller.highestReceived = 1337
controller.UpdateHighestReceived(1338)
Expect(controller.highestReceived).To(Equal(protocol.ByteCount(1338)))
})
It("does not decrease the highestReceived", func() {
controller.highestReceived = 1337
controller.UpdateHighestReceived(1000)
Expect(controller.highestReceived).To(Equal(protocol.ByteCount(1337)))
})
It("detects a flow control violation", func() {
Expect(controller.CheckFlowControlViolation(receiveFlowControlWindow + 1)).To(BeTrue())
controller.UpdateHighestReceived(receiveFlowControlWindow + 1)
Expect(controller.CheckFlowControlViolation()).To(BeTrue())
})
It("does not give a flow control violation when using the window completely", func() {
Expect(controller.CheckFlowControlViolation(receiveFlowControlWindow)).To(BeFalse())
controller.UpdateHighestReceived(receiveFlowControlWindow)
Expect(controller.CheckFlowControlViolation()).To(BeFalse())
})
})
})