create interface for the ConnectionParametersManager

This commit is contained in:
Marten Seemann 2016-12-08 18:39:14 +07:00
parent 5af50c8fd0
commit ebc053dbe0
No known key found for this signature in database
GPG key ID: 3603F40B121FCDEA
15 changed files with 108 additions and 94 deletions

View file

@ -14,7 +14,7 @@ import (
// set private variables of the ConnectionParametersManager
// those are normally read from the server parameter constants in the constructor of the ConnectionParametersManager
func setConnectionParametersManagerWindow(cpm *handshake.ConnectionParametersManager, name string, value protocol.ByteCount) {
func setConnectionParametersManagerWindow(cpm handshake.ConnectionParametersManager, name string, value protocol.ByteCount) {
*(*protocol.ByteCount)(unsafe.Pointer(reflect.ValueOf(cpm).Elem().FieldByName(name).UnsafeAddr())) = value
}
@ -27,11 +27,11 @@ var _ = Describe("Flow controller", func() {
})
Context("Constructor", func() {
var cpm *handshake.ConnectionParametersManager
var cpm handshake.ConnectionParametersManager
var rttStats *congestion.RTTStats
BeforeEach(func() {
cpm = &handshake.ConnectionParametersManager{}
cpm = handshake.NewConnectionParamatersManager(protocol.VersionWhatever)
rttStats = &congestion.RTTStats{}
setConnectionParametersManagerWindow(cpm, "sendStreamFlowControlWindow", 1000)
setConnectionParametersManagerWindow(cpm, "receiveStreamFlowControlWindow", 2000)
@ -65,13 +65,13 @@ var _ = Describe("Flow controller", func() {
})
Context("send flow control", func() {
var cpm *handshake.ConnectionParametersManager
var cpm handshake.ConnectionParametersManager
BeforeEach(func() {
cpm = &handshake.ConnectionParametersManager{}
cpm = handshake.NewConnectionParamatersManager(protocol.VersionWhatever)
setConnectionParametersManagerWindow(cpm, "sendStreamFlowControlWindow", 1000)
setConnectionParametersManagerWindow(cpm, "sendConnectionFlowControlWindow", 3000)
controller.connectionParametersManager = cpm
controller.connectionParameters = cpm
})
It("adds bytes sent", func() {