mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 19:49:57 +00:00
TUN-8641: Expose methods to simplify V3 Datagram parsing on the edge
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user