github.com/xmplusdev/xray-core@v1.8.10/transport/internet/headers/tls/dtls_test.go (about) 1 package tls_test 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/xmplusdev/xray-core/common" 8 "github.com/xmplusdev/xray-core/common/buf" 9 . "github.com/xmplusdev/xray-core/transport/internet/headers/tls" 10 ) 11 12 func TestDTLSWrite(t *testing.T) { 13 content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'} 14 dtlsRaw, err := New(context.Background(), &PacketConfig{}) 15 common.Must(err) 16 17 dtls := dtlsRaw.(*DTLS) 18 19 payload := buf.New() 20 dtls.Serialize(payload.Extend(dtls.Size())) 21 payload.Write(content) 22 23 if payload.Len() != int32(len(content))+dtls.Size() { 24 t.Error("payload len: ", payload.Len(), " want ", int32(len(content))+dtls.Size()) 25 } 26 }