2018-05-25 11:16:15 -04:00
|
|
|
package tls_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2022-01-02 10:16:23 -05:00
|
|
|
"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
|
|
|
}
|