use protocol.ByteCount in frames, streams and session

This commit is contained in:
Marten Seemann
2016-05-05 11:53:10 +07:00
parent 77f34a9207
commit 6556e2f695
11 changed files with 42 additions and 33 deletions

View File

@@ -5,6 +5,8 @@ import (
"encoding/binary"
"errors"
"sync"
"github.com/lucas-clemente/quic-go/protocol"
)
// ConnectionParametersManager stores the connection parameters
@@ -61,7 +63,7 @@ func (h *ConnectionParametersManager) GetSHLOMap() map[Tag][]byte {
}
// GetStreamFlowControlWindow gets the size of the stream-level flow control window
func (h *ConnectionParametersManager) GetStreamFlowControlWindow() (uint32, error) {
func (h *ConnectionParametersManager) GetStreamFlowControlWindow() (protocol.ByteCount, error) {
rawValue, err := h.GetRawValue(TagSFCW)
if err != nil {
@@ -75,5 +77,5 @@ func (h *ConnectionParametersManager) GetStreamFlowControlWindow() (uint32, erro
return 0, err
}
return value, nil
return protocol.ByteCount(value), nil
}

View File

@@ -1,6 +1,7 @@
package handshake
import (
"github.com/lucas-clemente/quic-go/protocol"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -46,14 +47,14 @@ var _ = Describe("ConnectionsParameterManager", func() {
It("has the correct default flow control window", func() {
val, err := cpm.GetStreamFlowControlWindow()
Expect(err).ToNot(HaveOccurred())
Expect(val).To(Equal(uint32(0x4000)))
Expect(val).To(Equal(protocol.ByteCount(0x4000)))
})
It("reads the stream-level flowControlWindow", func() {
cpm.params[TagSFCW] = []byte{0xDE, 0xAD, 0xBE, 0xEF}
val, err := cpm.GetStreamFlowControlWindow()
Expect(err).ToNot(HaveOccurred())
Expect(val).To(Equal(uint32(0xEFBEADDE)))
Expect(val).To(Equal(protocol.ByteCount(0xEFBEADDE)))
})
})
})