forked from quic-go/quic-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tracer.go
35 lines (29 loc) · 1013 Bytes
/
tracer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//go:build !gomock && !generate
package mocklogging
import (
"net"
"github.com/YCK1130/quic-go/internal/mocks/logging/internal"
"github.com/YCK1130/quic-go/logging"
"go.uber.org/mock/gomock"
)
type MockTracer = internal.MockTracer
func NewMockTracer(ctrl *gomock.Controller) (*logging.Tracer, *MockTracer) {
t := internal.NewMockTracer(ctrl)
return &logging.Tracer{
SentPacket: func(remote net.Addr, hdr *logging.Header, size logging.ByteCount, frames []logging.Frame) {
t.SentPacket(remote, hdr, size, frames)
},
SentVersionNegotiationPacket: func(remote net.Addr, dest, src logging.ArbitraryLenConnectionID, versions []logging.VersionNumber) {
t.SentVersionNegotiationPacket(remote, dest, src, versions)
},
DroppedPacket: func(remote net.Addr, typ logging.PacketType, size logging.ByteCount, reason logging.PacketDropReason) {
t.DroppedPacket(remote, typ, size, reason)
},
Debug: func(name, msg string) {
t.Debug(name, msg)
},
Close: func() {
t.Close()
},
}, t
}