TUN-8641: Expose methods to simplify V3 Datagram parsing on the edge

This commit is contained in:
Gonçalo Garcia
2024-11-04 15:23:36 -08:00
parent 589c198d2d
commit 3d33f559b1
5 changed files with 37 additions and 11 deletions

View File

@@ -5,6 +5,8 @@ import (
"slices"
"testing"
"github.com/stretchr/testify/require"
v3 "github.com/cloudflare/cloudflared/quic/v3"
)
@@ -48,3 +50,15 @@ func TestRequestIDParsing(t *testing.T) {
t.Fatalf("buf1 != buf2: %+v %+v", buf1, buf2)
}
}
func TestRequestID_MarshalBinary(t *testing.T) {
buf := make([]byte, 16)
err := testRequestID.MarshalBinaryTo(buf)
require.NoError(t, err)
require.Len(t, buf, 16)
parsed := v3.RequestID{}
err = parsed.UnmarshalBinary(buf)
require.NoError(t, err)
require.Equal(t, testRequestID, parsed)
}