dtls_test.go 556 B

123456789101112131415161718192021222324252627
  1. package tls_test
  2. import (
  3. "context"
  4. "testing"
  5. "v2ray.com/core/common"
  6. "v2ray.com/core/common/buf"
  7. . "v2ray.com/core/transport/internet/headers/tls"
  8. . "v2ray.com/ext/assert"
  9. )
  10. func TestDTLSWrite(t *testing.T) {
  11. assert := With(t)
  12. content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
  13. dtlsRaw, err := New(context.Background(), &PacketConfig{})
  14. common.Must(err)
  15. dtls := dtlsRaw.(*DTLS)
  16. payload := buf.New()
  17. dtls.Serialize(payload.Extend(dtls.Size()))
  18. payload.Write(content)
  19. assert(payload.Len(), Equals, int32(len(content))+dtls.Size())
  20. }