1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-14 08:15:55 -05:00
v2fly/transport/internet/headers/tls/dtls_test.go

27 lines
637 B
Go
Raw Normal View History

2018-05-25 11:16:15 -04:00
package tls_test
import (
"context"
"testing"
"github.com/v2fly/v2ray-core/v5/common"
"github.com/v2fly/v2ray-core/v5/common/buf"
. "github.com/v2fly/v2ray-core/v5/transport/internet/headers/tls"
2018-05-25 11:16:15 -04:00
)
func TestDTLSWrite(t *testing.T) {
content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
dtlsRaw, err := New(context.Background(), &PacketConfig{})
2019-02-02 16:19:30 -05:00
common.Must(err)
2018-05-25 11:16:15 -04:00
dtls := dtlsRaw.(*DTLS)
payload := buf.New()
2018-11-02 16:34:04 -04:00
dtls.Serialize(payload.Extend(dtls.Size()))
2018-05-25 11:16:15 -04:00
payload.Write(content)
2019-02-03 13:46:53 -05:00
if payload.Len() != int32(len(content))+dtls.Size() {
t.Error("payload len: ", payload.Len(), " want ", int32(len(content))+dtls.Size())
}
2018-05-25 11:16:15 -04:00
}