github.com/apernet/quic-go@v0.43.1-0.20240515053213-5e9e635fd9f0/internal/mocks/logging/connection_tracer.go (about)

     1  //go:build !gomock && !generate
     2  
     3  package mocklogging
     4  
     5  import (
     6  	"net"
     7  	"time"
     8  
     9  	"github.com/apernet/quic-go/internal/mocks/logging/internal"
    10  	"github.com/apernet/quic-go/logging"
    11  
    12  	"go.uber.org/mock/gomock"
    13  )
    14  
    15  type MockConnectionTracer = internal.MockConnectionTracer
    16  
    17  func NewMockConnectionTracer(ctrl *gomock.Controller) (*logging.ConnectionTracer, *MockConnectionTracer) {
    18  	t := internal.NewMockConnectionTracer(ctrl)
    19  	return &logging.ConnectionTracer{
    20  		StartedConnection: func(local, remote net.Addr, srcConnID, destConnID logging.ConnectionID) {
    21  			t.StartedConnection(local, remote, srcConnID, destConnID)
    22  		},
    23  		NegotiatedVersion: func(chosen logging.VersionNumber, clientVersions, serverVersions []logging.VersionNumber) {
    24  			t.NegotiatedVersion(chosen, clientVersions, serverVersions)
    25  		},
    26  		ClosedConnection: func(e error) {
    27  			t.ClosedConnection(e)
    28  		},
    29  		SentTransportParameters: func(tp *logging.TransportParameters) {
    30  			t.SentTransportParameters(tp)
    31  		},
    32  		ReceivedTransportParameters: func(tp *logging.TransportParameters) {
    33  			t.ReceivedTransportParameters(tp)
    34  		},
    35  		RestoredTransportParameters: func(tp *logging.TransportParameters) {
    36  			t.RestoredTransportParameters(tp)
    37  		},
    38  		SentLongHeaderPacket: func(hdr *logging.ExtendedHeader, size logging.ByteCount, ecn logging.ECN, ack *logging.AckFrame, frames []logging.Frame) {
    39  			t.SentLongHeaderPacket(hdr, size, ecn, ack, frames)
    40  		},
    41  		SentShortHeaderPacket: func(hdr *logging.ShortHeader, size logging.ByteCount, ecn logging.ECN, ack *logging.AckFrame, frames []logging.Frame) {
    42  			t.SentShortHeaderPacket(hdr, size, ecn, ack, frames)
    43  		},
    44  		ReceivedVersionNegotiationPacket: func(dest, src logging.ArbitraryLenConnectionID, versions []logging.VersionNumber) {
    45  			t.ReceivedVersionNegotiationPacket(dest, src, versions)
    46  		},
    47  		ReceivedRetry: func(hdr *logging.Header) {
    48  			t.ReceivedRetry(hdr)
    49  		},
    50  		ReceivedLongHeaderPacket: func(hdr *logging.ExtendedHeader, size logging.ByteCount, ecn logging.ECN, frames []logging.Frame) {
    51  			t.ReceivedLongHeaderPacket(hdr, size, ecn, frames)
    52  		},
    53  		ReceivedShortHeaderPacket: func(hdr *logging.ShortHeader, size logging.ByteCount, ecn logging.ECN, frames []logging.Frame) {
    54  			t.ReceivedShortHeaderPacket(hdr, size, ecn, frames)
    55  		},
    56  		BufferedPacket: func(typ logging.PacketType, size logging.ByteCount) {
    57  			t.BufferedPacket(typ, size)
    58  		},
    59  		DroppedPacket: func(typ logging.PacketType, pn logging.PacketNumber, size logging.ByteCount, reason logging.PacketDropReason) {
    60  			t.DroppedPacket(typ, pn, size, reason)
    61  		},
    62  		UpdatedMetrics: func(rttStats *logging.RTTStats, cwnd, bytesInFlight logging.ByteCount, packetsInFlight int) {
    63  			t.UpdatedMetrics(rttStats, cwnd, bytesInFlight, packetsInFlight)
    64  		},
    65  		AcknowledgedPacket: func(encLevel logging.EncryptionLevel, pn logging.PacketNumber) {
    66  			t.AcknowledgedPacket(encLevel, pn)
    67  		},
    68  		LostPacket: func(encLevel logging.EncryptionLevel, pn logging.PacketNumber, reason logging.PacketLossReason) {
    69  			t.LostPacket(encLevel, pn, reason)
    70  		},
    71  		UpdatedCongestionState: func(state logging.CongestionState) {
    72  			t.UpdatedCongestionState(state)
    73  		},
    74  		UpdatedPTOCount: func(value uint32) {
    75  			t.UpdatedPTOCount(value)
    76  		},
    77  		UpdatedKeyFromTLS: func(encLevel logging.EncryptionLevel, perspective logging.Perspective) {
    78  			t.UpdatedKeyFromTLS(encLevel, perspective)
    79  		},
    80  		UpdatedKey: func(generation logging.KeyPhase, remote bool) {
    81  			t.UpdatedKey(generation, remote)
    82  		},
    83  		DroppedEncryptionLevel: func(encLevel logging.EncryptionLevel) {
    84  			t.DroppedEncryptionLevel(encLevel)
    85  		},
    86  		DroppedKey: func(generation logging.KeyPhase) {
    87  			t.DroppedKey(generation)
    88  		},
    89  		SetLossTimer: func(typ logging.TimerType, encLevel logging.EncryptionLevel, exp time.Time) {
    90  			t.SetLossTimer(typ, encLevel, exp)
    91  		},
    92  		LossTimerExpired: func(typ logging.TimerType, encLevel logging.EncryptionLevel) {
    93  			t.LossTimerExpired(typ, encLevel)
    94  		},
    95  		LossTimerCanceled: func() {
    96  			t.LossTimerCanceled()
    97  		},
    98  		ECNStateUpdated: func(state logging.ECNState, trigger logging.ECNStateTrigger) {
    99  			t.ECNStateUpdated(state, trigger)
   100  		},
   101  		ChoseALPN: func(protocol string) {
   102  			t.ChoseALPN(protocol)
   103  		},
   104  		Close: func() {
   105  			t.Close()
   106  		},
   107  		Debug: func(name, msg string) {
   108  			t.Debug(name, msg)
   109  		},
   110  	}, t
   111  }