forked from quic-go/quic-go
qlog: split serializiation and event definitions, remove logging abstraction (#5356)
* qlog: implement a Trace and a Writer struct * qlog: rename Trace to FileSeq * split qlog trace writer and QUIC qlog events into separate packages * use the new qlog.Recorder instead of the logging.ConnectionTracer
This commit is contained in:
@@ -4,35 +4,35 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/quic-go/quic-go/internal/wire"
|
||||
"github.com/quic-go/quic-go/logging"
|
||||
"github.com/quic-go/quic-go/qlog"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestConnectionLoggingCryptoFrame(t *testing.T) {
|
||||
f := toLoggingFrame(&wire.CryptoFrame{
|
||||
f := toQlogFrame(&wire.CryptoFrame{
|
||||
Offset: 1234,
|
||||
Data: []byte("foobar"),
|
||||
})
|
||||
require.Equal(t, &logging.CryptoFrame{
|
||||
require.Equal(t, &qlog.CryptoFrame{
|
||||
Offset: 1234,
|
||||
Length: 6,
|
||||
}, f)
|
||||
}, f.Frame)
|
||||
}
|
||||
|
||||
func TestConnectionLoggingStreamFrame(t *testing.T) {
|
||||
f := toLoggingFrame(&wire.StreamFrame{
|
||||
f := toQlogFrame(&wire.StreamFrame{
|
||||
StreamID: 42,
|
||||
Offset: 1234,
|
||||
Data: []byte("foo"),
|
||||
Fin: true,
|
||||
})
|
||||
require.Equal(t, &logging.StreamFrame{
|
||||
require.Equal(t, &qlog.StreamFrame{
|
||||
StreamID: 42,
|
||||
Offset: 1234,
|
||||
Length: 3,
|
||||
Fin: true,
|
||||
}, f)
|
||||
}, f.Frame)
|
||||
}
|
||||
|
||||
func TestConnectionLoggingAckFrame(t *testing.T) {
|
||||
@@ -46,10 +46,10 @@ func TestConnectionLoggingAckFrame(t *testing.T) {
|
||||
ECT0: 456,
|
||||
ECT1: 789,
|
||||
}
|
||||
f := toLoggingFrame(ack)
|
||||
f := toQlogFrame(ack)
|
||||
// now modify the ACK range in the original frame
|
||||
ack.AckRanges[0].Smallest = 2
|
||||
require.Equal(t, &logging.AckFrame{
|
||||
require.Equal(t, &qlog.AckFrame{
|
||||
AckRanges: []wire.AckRange{
|
||||
{Smallest: 1, Largest: 3}, // unchanged, since the ACK ranges were cloned
|
||||
{Smallest: 6, Largest: 7},
|
||||
@@ -58,15 +58,15 @@ func TestConnectionLoggingAckFrame(t *testing.T) {
|
||||
ECNCE: 123,
|
||||
ECT0: 456,
|
||||
ECT1: 789,
|
||||
}, f)
|
||||
}, f.Frame)
|
||||
}
|
||||
|
||||
func TestConnectionLoggingDatagramFrame(t *testing.T) {
|
||||
f := toLoggingFrame(&wire.DatagramFrame{Data: []byte("foobar")})
|
||||
require.Equal(t, &logging.DatagramFrame{Length: 6}, f)
|
||||
f := toQlogFrame(&wire.DatagramFrame{Data: []byte("foobar")})
|
||||
require.Equal(t, &qlog.DatagramFrame{Length: 6}, f.Frame)
|
||||
}
|
||||
|
||||
func TestConnectionLoggingOtherFrames(t *testing.T) {
|
||||
f := toLoggingFrame(&wire.MaxDataFrame{MaximumData: 1234})
|
||||
require.Equal(t, &logging.MaxDataFrame{MaximumData: 1234}, f)
|
||||
f := toQlogFrame(&wire.MaxDataFrame{MaximumData: 1234})
|
||||
require.Equal(t, &qlog.MaxDataFrame{MaximumData: 1234}, f.Frame)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user