github.com/Uhtred009/v2ray-core-1@v4.31.2+incompatible/transport/internet/headers/tls/dtls_test.go (about) 1 package tls_test 2 3 import ( 4 "context" 5 "testing" 6 7 "v2ray.com/core/common" 8 "v2ray.com/core/common/buf" 9 . "v2ray.com/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 }