github.com/eagleql/xray-core@v1.4.4/transport/internet/headers/tls/dtls_test.go (about)

     1  package tls_test
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/eagleql/xray-core/common"
     8  	"github.com/eagleql/xray-core/common/buf"
     9  	. "github.com/eagleql/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  }