add a multiplexer for the logging.ConnectionTracer

This commit is contained in:
Marten Seemann 2020-07-06 13:57:18 +07:00
parent 2f5cba0856
commit 2d4eca1dd6
6 changed files with 597 additions and 3 deletions

View file

@ -89,13 +89,13 @@ type ConnectionTracer interface {
ClosedConnection(CloseReason)
SentTransportParameters(*TransportParameters)
ReceivedTransportParameters(*TransportParameters)
SentPacket(hdr *ExtendedHeader, packetSize ByteCount, ack *AckFrame, frames []Frame)
SentPacket(hdr *ExtendedHeader, size ByteCount, ack *AckFrame, frames []Frame)
ReceivedVersionNegotiationPacket(*Header, []VersionNumber)
ReceivedRetry(*Header)
ReceivedPacket(hdr *ExtendedHeader, packetSize ByteCount, frames []Frame)
ReceivedPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame)
BufferedPacket(PacketType)
DroppedPacket(PacketType, ByteCount, PacketDropReason)
UpdatedMetrics(rttStats *RTTStats, cwnd ByteCount, bytesInFLight ByteCount, packetsInFlight int)
UpdatedMetrics(rttStats *RTTStats, cwnd, bytesInFlight ByteCount, packetsInFlight int)
LostPacket(EncryptionLevel, PacketNumber, PacketLossReason)
UpdatedPTOCount(value uint32)
UpdatedKeyFromTLS(EncryptionLevel, Perspective)

View file

@ -3,6 +3,8 @@ package logging
import (
"testing"
"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@ -11,3 +13,13 @@ func TestLogging(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Logging Suite")
}
var mockCtrl *gomock.Controller
var _ = BeforeEach(func() {
mockCtrl = gomock.NewController(GinkgoT())
})
var _ = AfterEach(func() {
mockCtrl.Finish()
})

View file

@ -0,0 +1,278 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/lucas-clemente/quic-go/logging (interfaces: ConnectionTracer)
// Package logging is a generated GoMock package.
package logging
import (
gomock "github.com/golang/mock/gomock"
congestion "github.com/lucas-clemente/quic-go/internal/congestion"
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
wire "github.com/lucas-clemente/quic-go/internal/wire"
net "net"
reflect "reflect"
time "time"
)
// MockConnectionTracer is a mock of ConnectionTracer interface
type MockConnectionTracer struct {
ctrl *gomock.Controller
recorder *MockConnectionTracerMockRecorder
}
// MockConnectionTracerMockRecorder is the mock recorder for MockConnectionTracer
type MockConnectionTracerMockRecorder struct {
mock *MockConnectionTracer
}
// NewMockConnectionTracer creates a new mock instance
func NewMockConnectionTracer(ctrl *gomock.Controller) *MockConnectionTracer {
mock := &MockConnectionTracer{ctrl: ctrl}
mock.recorder = &MockConnectionTracerMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use
func (m *MockConnectionTracer) EXPECT() *MockConnectionTracerMockRecorder {
return m.recorder
}
// BufferedPacket mocks base method
func (m *MockConnectionTracer) BufferedPacket(arg0 protocol.PacketType) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "BufferedPacket", arg0)
}
// BufferedPacket indicates an expected call of BufferedPacket
func (mr *MockConnectionTracerMockRecorder) BufferedPacket(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BufferedPacket", reflect.TypeOf((*MockConnectionTracer)(nil).BufferedPacket), arg0)
}
// Close mocks base method
func (m *MockConnectionTracer) Close() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "Close")
}
// Close indicates an expected call of Close
func (mr *MockConnectionTracerMockRecorder) Close() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockConnectionTracer)(nil).Close))
}
// ClosedConnection mocks base method
func (m *MockConnectionTracer) ClosedConnection(arg0 CloseReason) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "ClosedConnection", arg0)
}
// ClosedConnection indicates an expected call of ClosedConnection
func (mr *MockConnectionTracerMockRecorder) ClosedConnection(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClosedConnection", reflect.TypeOf((*MockConnectionTracer)(nil).ClosedConnection), arg0)
}
// DroppedEncryptionLevel mocks base method
func (m *MockConnectionTracer) DroppedEncryptionLevel(arg0 protocol.EncryptionLevel) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "DroppedEncryptionLevel", arg0)
}
// DroppedEncryptionLevel indicates an expected call of DroppedEncryptionLevel
func (mr *MockConnectionTracerMockRecorder) DroppedEncryptionLevel(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DroppedEncryptionLevel", reflect.TypeOf((*MockConnectionTracer)(nil).DroppedEncryptionLevel), arg0)
}
// DroppedPacket mocks base method
func (m *MockConnectionTracer) DroppedPacket(arg0 protocol.PacketType, arg1 protocol.ByteCount, arg2 PacketDropReason) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "DroppedPacket", arg0, arg1, arg2)
}
// DroppedPacket indicates an expected call of DroppedPacket
func (mr *MockConnectionTracerMockRecorder) DroppedPacket(arg0, arg1, arg2 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DroppedPacket", reflect.TypeOf((*MockConnectionTracer)(nil).DroppedPacket), arg0, arg1, arg2)
}
// LossTimerCanceled mocks base method
func (m *MockConnectionTracer) LossTimerCanceled() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "LossTimerCanceled")
}
// LossTimerCanceled indicates an expected call of LossTimerCanceled
func (mr *MockConnectionTracerMockRecorder) LossTimerCanceled() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LossTimerCanceled", reflect.TypeOf((*MockConnectionTracer)(nil).LossTimerCanceled))
}
// LossTimerExpired mocks base method
func (m *MockConnectionTracer) LossTimerExpired(arg0 TimerType, arg1 protocol.EncryptionLevel) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "LossTimerExpired", arg0, arg1)
}
// LossTimerExpired indicates an expected call of LossTimerExpired
func (mr *MockConnectionTracerMockRecorder) LossTimerExpired(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LossTimerExpired", reflect.TypeOf((*MockConnectionTracer)(nil).LossTimerExpired), arg0, arg1)
}
// LostPacket mocks base method
func (m *MockConnectionTracer) LostPacket(arg0 protocol.EncryptionLevel, arg1 protocol.PacketNumber, arg2 PacketLossReason) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "LostPacket", arg0, arg1, arg2)
}
// LostPacket indicates an expected call of LostPacket
func (mr *MockConnectionTracerMockRecorder) LostPacket(arg0, arg1, arg2 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LostPacket", reflect.TypeOf((*MockConnectionTracer)(nil).LostPacket), arg0, arg1, arg2)
}
// ReceivedPacket mocks base method
func (m *MockConnectionTracer) ReceivedPacket(arg0 *wire.ExtendedHeader, arg1 protocol.ByteCount, arg2 []Frame) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "ReceivedPacket", arg0, arg1, arg2)
}
// ReceivedPacket indicates an expected call of ReceivedPacket
func (mr *MockConnectionTracerMockRecorder) ReceivedPacket(arg0, arg1, arg2 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedPacket", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedPacket), arg0, arg1, arg2)
}
// ReceivedRetry mocks base method
func (m *MockConnectionTracer) ReceivedRetry(arg0 *wire.Header) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "ReceivedRetry", arg0)
}
// ReceivedRetry indicates an expected call of ReceivedRetry
func (mr *MockConnectionTracerMockRecorder) ReceivedRetry(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedRetry", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedRetry), arg0)
}
// ReceivedTransportParameters mocks base method
func (m *MockConnectionTracer) ReceivedTransportParameters(arg0 *wire.TransportParameters) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "ReceivedTransportParameters", arg0)
}
// ReceivedTransportParameters indicates an expected call of ReceivedTransportParameters
func (mr *MockConnectionTracerMockRecorder) ReceivedTransportParameters(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedTransportParameters", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedTransportParameters), arg0)
}
// ReceivedVersionNegotiationPacket mocks base method
func (m *MockConnectionTracer) ReceivedVersionNegotiationPacket(arg0 *wire.Header, arg1 []protocol.VersionNumber) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "ReceivedVersionNegotiationPacket", arg0, arg1)
}
// ReceivedVersionNegotiationPacket indicates an expected call of ReceivedVersionNegotiationPacket
func (mr *MockConnectionTracerMockRecorder) ReceivedVersionNegotiationPacket(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedVersionNegotiationPacket", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedVersionNegotiationPacket), arg0, arg1)
}
// SentPacket mocks base method
func (m *MockConnectionTracer) SentPacket(arg0 *wire.ExtendedHeader, arg1 protocol.ByteCount, arg2 *wire.AckFrame, arg3 []Frame) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SentPacket", arg0, arg1, arg2, arg3)
}
// SentPacket indicates an expected call of SentPacket
func (mr *MockConnectionTracerMockRecorder) SentPacket(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SentPacket", reflect.TypeOf((*MockConnectionTracer)(nil).SentPacket), arg0, arg1, arg2, arg3)
}
// SentTransportParameters mocks base method
func (m *MockConnectionTracer) SentTransportParameters(arg0 *wire.TransportParameters) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SentTransportParameters", arg0)
}
// SentTransportParameters indicates an expected call of SentTransportParameters
func (mr *MockConnectionTracerMockRecorder) SentTransportParameters(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SentTransportParameters", reflect.TypeOf((*MockConnectionTracer)(nil).SentTransportParameters), arg0)
}
// SetLossTimer mocks base method
func (m *MockConnectionTracer) SetLossTimer(arg0 TimerType, arg1 protocol.EncryptionLevel, arg2 time.Time) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetLossTimer", arg0, arg1, arg2)
}
// SetLossTimer indicates an expected call of SetLossTimer
func (mr *MockConnectionTracerMockRecorder) SetLossTimer(arg0, arg1, arg2 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLossTimer", reflect.TypeOf((*MockConnectionTracer)(nil).SetLossTimer), arg0, arg1, arg2)
}
// StartedConnection mocks base method
func (m *MockConnectionTracer) StartedConnection(arg0, arg1 net.Addr, arg2 protocol.VersionNumber, arg3, arg4 protocol.ConnectionID) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "StartedConnection", arg0, arg1, arg2, arg3, arg4)
}
// StartedConnection indicates an expected call of StartedConnection
func (mr *MockConnectionTracerMockRecorder) StartedConnection(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartedConnection", reflect.TypeOf((*MockConnectionTracer)(nil).StartedConnection), arg0, arg1, arg2, arg3, arg4)
}
// UpdatedKey mocks base method
func (m *MockConnectionTracer) UpdatedKey(arg0 protocol.KeyPhase, arg1 bool) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "UpdatedKey", arg0, arg1)
}
// UpdatedKey indicates an expected call of UpdatedKey
func (mr *MockConnectionTracerMockRecorder) UpdatedKey(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdatedKey", reflect.TypeOf((*MockConnectionTracer)(nil).UpdatedKey), arg0, arg1)
}
// UpdatedKeyFromTLS mocks base method
func (m *MockConnectionTracer) UpdatedKeyFromTLS(arg0 protocol.EncryptionLevel, arg1 protocol.Perspective) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "UpdatedKeyFromTLS", arg0, arg1)
}
// UpdatedKeyFromTLS indicates an expected call of UpdatedKeyFromTLS
func (mr *MockConnectionTracerMockRecorder) UpdatedKeyFromTLS(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdatedKeyFromTLS", reflect.TypeOf((*MockConnectionTracer)(nil).UpdatedKeyFromTLS), arg0, arg1)
}
// UpdatedMetrics mocks base method
func (m *MockConnectionTracer) UpdatedMetrics(arg0 *congestion.RTTStats, arg1, arg2 protocol.ByteCount, arg3 int) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "UpdatedMetrics", arg0, arg1, arg2, arg3)
}
// UpdatedMetrics indicates an expected call of UpdatedMetrics
func (mr *MockConnectionTracerMockRecorder) UpdatedMetrics(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdatedMetrics", reflect.TypeOf((*MockConnectionTracer)(nil).UpdatedMetrics), arg0, arg1, arg2, arg3)
}
// UpdatedPTOCount mocks base method
func (m *MockConnectionTracer) UpdatedPTOCount(arg0 uint32) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "UpdatedPTOCount", arg0)
}
// UpdatedPTOCount indicates an expected call of UpdatedPTOCount
func (mr *MockConnectionTracerMockRecorder) UpdatedPTOCount(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdatedPTOCount", reflect.TypeOf((*MockConnectionTracer)(nil).UpdatedPTOCount), arg0)
}

3
logging/mockgen.go Normal file
View file

@ -0,0 +1,3 @@
package logging
//go:generate sh -c "mockgen -package logging -destination mock_connection_tracer_test.go github.com/lucas-clemente/quic-go/logging ConnectionTracer"

142
logging/multiplex.go Normal file
View file

@ -0,0 +1,142 @@
package logging
import (
"net"
"time"
)
type connTracerMultiplexer struct {
tracers []ConnectionTracer
}
var _ ConnectionTracer = &connTracerMultiplexer{}
func NewConnectionMultiplexer(tracers ...ConnectionTracer) ConnectionTracer {
if len(tracers) == 0 {
panic("no tracers")
}
if len(tracers) == 1 {
return tracers[0]
}
return &connTracerMultiplexer{tracers: tracers}
}
func (m *connTracerMultiplexer) StartedConnection(local, remote net.Addr, version VersionNumber, srcConnID, destConnID ConnectionID) {
for _, t := range m.tracers {
t.StartedConnection(local, remote, version, srcConnID, destConnID)
}
}
func (m *connTracerMultiplexer) ClosedConnection(reason CloseReason) {
for _, t := range m.tracers {
t.ClosedConnection(reason)
}
}
func (m *connTracerMultiplexer) SentTransportParameters(tp *TransportParameters) {
for _, t := range m.tracers {
t.SentTransportParameters(tp)
}
}
func (m *connTracerMultiplexer) ReceivedTransportParameters(tp *TransportParameters) {
for _, t := range m.tracers {
t.ReceivedTransportParameters(tp)
}
}
func (m *connTracerMultiplexer) SentPacket(hdr *ExtendedHeader, size ByteCount, ack *AckFrame, frames []Frame) {
for _, t := range m.tracers {
t.SentPacket(hdr, size, ack, frames)
}
}
func (m *connTracerMultiplexer) ReceivedVersionNegotiationPacket(hdr *Header, versions []VersionNumber) {
for _, t := range m.tracers {
t.ReceivedVersionNegotiationPacket(hdr, versions)
}
}
func (m *connTracerMultiplexer) ReceivedRetry(hdr *Header) {
for _, t := range m.tracers {
t.ReceivedRetry(hdr)
}
}
func (m *connTracerMultiplexer) ReceivedPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame) {
for _, t := range m.tracers {
t.ReceivedPacket(hdr, size, frames)
}
}
func (m *connTracerMultiplexer) BufferedPacket(typ PacketType) {
for _, t := range m.tracers {
t.BufferedPacket(typ)
}
}
func (m *connTracerMultiplexer) DroppedPacket(typ PacketType, size ByteCount, reason PacketDropReason) {
for _, t := range m.tracers {
t.DroppedPacket(typ, size, reason)
}
}
func (m *connTracerMultiplexer) UpdatedMetrics(rttStats *RTTStats, cwnd, bytesInFLight ByteCount, packetsInFlight int) {
for _, t := range m.tracers {
t.UpdatedMetrics(rttStats, cwnd, bytesInFLight, packetsInFlight)
}
}
func (m *connTracerMultiplexer) LostPacket(encLevel EncryptionLevel, pn PacketNumber, reason PacketLossReason) {
for _, t := range m.tracers {
t.LostPacket(encLevel, pn, reason)
}
}
func (m *connTracerMultiplexer) UpdatedPTOCount(value uint32) {
for _, t := range m.tracers {
t.UpdatedPTOCount(value)
}
}
func (m *connTracerMultiplexer) UpdatedKeyFromTLS(encLevel EncryptionLevel, perspective Perspective) {
for _, t := range m.tracers {
t.UpdatedKeyFromTLS(encLevel, perspective)
}
}
func (m *connTracerMultiplexer) UpdatedKey(generation KeyPhase, remote bool) {
for _, t := range m.tracers {
t.UpdatedKey(generation, remote)
}
}
func (m *connTracerMultiplexer) DroppedEncryptionLevel(encLevel EncryptionLevel) {
for _, t := range m.tracers {
t.DroppedEncryptionLevel(encLevel)
}
}
func (m *connTracerMultiplexer) SetLossTimer(typ TimerType, encLevel EncryptionLevel, exp time.Time) {
for _, t := range m.tracers {
t.SetLossTimer(typ, encLevel, exp)
}
}
func (m *connTracerMultiplexer) LossTimerExpired(typ TimerType, encLevel EncryptionLevel) {
for _, t := range m.tracers {
t.LossTimerExpired(typ, encLevel)
}
}
func (m *connTracerMultiplexer) LossTimerCanceled() {
for _, t := range m.tracers {
t.LossTimerCanceled()
}
}
func (m *connTracerMultiplexer) Close() {
for _, t := range m.tracers {
t.Close()
}
}

159
logging/multiplex_test.go Normal file
View file

@ -0,0 +1,159 @@
package logging
import (
"net"
"time"
"github.com/lucas-clemente/quic-go/internal/wire"
. "github.com/onsi/ginkgo"
)
var _ = Describe("Tracing", func() {
var (
tracer ConnectionTracer
tr1 *MockConnectionTracer
tr2 *MockConnectionTracer
)
BeforeEach(func() {
tr1 = NewMockConnectionTracer(mockCtrl)
tr2 = NewMockConnectionTracer(mockCtrl)
tracer = NewConnectionMultiplexer(tr1, tr2)
})
It("trace the ConnectionStarted event", func() {
local := &net.UDPAddr{IP: net.IPv4(1, 2, 3, 4)}
remote := &net.UDPAddr{IP: net.IPv4(4, 3, 2, 1)}
tr1.EXPECT().StartedConnection(local, remote, VersionNumber(1234), ConnectionID{1, 2, 3, 4}, ConnectionID{4, 3, 2, 1})
tr2.EXPECT().StartedConnection(local, remote, VersionNumber(1234), ConnectionID{1, 2, 3, 4}, ConnectionID{4, 3, 2, 1})
tracer.StartedConnection(local, remote, VersionNumber(1234), ConnectionID{1, 2, 3, 4}, ConnectionID{4, 3, 2, 1})
})
It("traces the ClosedConnection event", func() {
reason := NewTimeoutCloseReason(TimeoutReasonIdle)
tr1.EXPECT().ClosedConnection(reason)
tr2.EXPECT().ClosedConnection(reason)
tracer.ClosedConnection(reason)
})
It("traces the SentTransportParameters event", func() {
tp := &wire.TransportParameters{InitialMaxData: 1337}
tr1.EXPECT().SentTransportParameters(tp)
tr2.EXPECT().SentTransportParameters(tp)
tracer.SentTransportParameters(tp)
})
It("traces the ReceivedTransportParameters event", func() {
tp := &wire.TransportParameters{InitialMaxData: 1337}
tr1.EXPECT().ReceivedTransportParameters(tp)
tr2.EXPECT().ReceivedTransportParameters(tp)
tracer.ReceivedTransportParameters(tp)
})
It("traces the SentPacket event", func() {
hdr := &ExtendedHeader{Header: Header{DestConnectionID: ConnectionID{1, 2, 3}}}
ack := &AckFrame{AckRanges: []AckRange{{Smallest: 1, Largest: 10}}}
ping := &PingFrame{}
tr1.EXPECT().SentPacket(hdr, ByteCount(1337), ack, []Frame{ping})
tr2.EXPECT().SentPacket(hdr, ByteCount(1337), ack, []Frame{ping})
tracer.SentPacket(hdr, 1337, ack, []Frame{ping})
})
It("traces the ReceivedVersionNegotiationPacket event", func() {
hdr := &Header{DestConnectionID: ConnectionID{1, 2, 3}}
tr1.EXPECT().ReceivedVersionNegotiationPacket(hdr, []VersionNumber{1337})
tr2.EXPECT().ReceivedVersionNegotiationPacket(hdr, []VersionNumber{1337})
tracer.ReceivedVersionNegotiationPacket(hdr, []VersionNumber{1337})
})
It("traces the ReceivedRetry event", func() {
hdr := &Header{DestConnectionID: ConnectionID{1, 2, 3}}
tr1.EXPECT().ReceivedRetry(hdr)
tr2.EXPECT().ReceivedRetry(hdr)
tracer.ReceivedRetry(hdr)
})
It("traces the ReceivedPacket event", func() {
hdr := &ExtendedHeader{Header: Header{DestConnectionID: ConnectionID{1, 2, 3}}}
ping := &PingFrame{}
tr1.EXPECT().ReceivedPacket(hdr, ByteCount(1337), []Frame{ping})
tr2.EXPECT().ReceivedPacket(hdr, ByteCount(1337), []Frame{ping})
tracer.ReceivedPacket(hdr, 1337, []Frame{ping})
})
It("traces the BufferedPacket event", func() {
tr1.EXPECT().BufferedPacket(PacketTypeHandshake)
tr2.EXPECT().BufferedPacket(PacketTypeHandshake)
tracer.BufferedPacket(PacketTypeHandshake)
})
It("traces the DroppedPacket event", func() {
tr1.EXPECT().DroppedPacket(PacketTypeInitial, ByteCount(1337), PacketDropHeaderParseError)
tr2.EXPECT().DroppedPacket(PacketTypeInitial, ByteCount(1337), PacketDropHeaderParseError)
tracer.DroppedPacket(PacketTypeInitial, 1337, PacketDropHeaderParseError)
})
It("traces the UpdatedMetrics event", func() {
rttStats := &RTTStats{}
rttStats.UpdateRTT(time.Second, 0, time.Now())
tr1.EXPECT().UpdatedMetrics(rttStats, ByteCount(1337), ByteCount(42), 13)
tr2.EXPECT().UpdatedMetrics(rttStats, ByteCount(1337), ByteCount(42), 13)
tracer.UpdatedMetrics(rttStats, 1337, 42, 13)
})
It("traces the LostPacket event", func() {
tr1.EXPECT().LostPacket(EncryptionHandshake, PacketNumber(42), PacketLossReorderingThreshold)
tr2.EXPECT().LostPacket(EncryptionHandshake, PacketNumber(42), PacketLossReorderingThreshold)
tracer.LostPacket(EncryptionHandshake, 42, PacketLossReorderingThreshold)
})
It("traces the UpdatedPTOCount event", func() {
tr1.EXPECT().UpdatedPTOCount(uint32(88))
tr2.EXPECT().UpdatedPTOCount(uint32(88))
tracer.UpdatedPTOCount(88)
})
It("traces the UpdatedKeyFromTLS event", func() {
tr1.EXPECT().UpdatedKeyFromTLS(EncryptionHandshake, PerspectiveClient)
tr2.EXPECT().UpdatedKeyFromTLS(EncryptionHandshake, PerspectiveClient)
tracer.UpdatedKeyFromTLS(EncryptionHandshake, PerspectiveClient)
})
It("traces the UpdatedKey event", func() {
tr1.EXPECT().UpdatedKey(KeyPhase(42), true)
tr2.EXPECT().UpdatedKey(KeyPhase(42), true)
tracer.UpdatedKey(KeyPhase(42), true)
})
It("traces the DroppedEncryptionLevel event", func() {
tr1.EXPECT().DroppedEncryptionLevel(EncryptionHandshake)
tr2.EXPECT().DroppedEncryptionLevel(EncryptionHandshake)
tracer.DroppedEncryptionLevel(EncryptionHandshake)
})
It("traces the SetLossTimer event", func() {
now := time.Now()
tr1.EXPECT().SetLossTimer(TimerTypePTO, EncryptionHandshake, now)
tr2.EXPECT().SetLossTimer(TimerTypePTO, EncryptionHandshake, now)
tracer.SetLossTimer(TimerTypePTO, EncryptionHandshake, now)
})
It("traces the LossTimerExpired event", func() {
tr1.EXPECT().LossTimerExpired(TimerTypePTO, EncryptionHandshake)
tr2.EXPECT().LossTimerExpired(TimerTypePTO, EncryptionHandshake)
tracer.LossTimerExpired(TimerTypePTO, EncryptionHandshake)
})
It("traces the LossTimerCanceled event", func() {
tr1.EXPECT().LossTimerCanceled()
tr2.EXPECT().LossTimerCanceled()
tracer.LossTimerCanceled()
})
It("traces the Close event", func() {
tr1.EXPECT().Close()
tr2.EXPECT().Close()
tracer.Close()
})
})