utp_test.go 546 B

1234567891011121314151617181920212223242526
  1. package utp_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/utp"
  8. )
  9. func TestUTPWrite(t *testing.T) {
  10. content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
  11. utpRaw, err := New(context.Background(), &Config{})
  12. common.Must(err)
  13. utp := utpRaw.(*UTP)
  14. payload := buf.New()
  15. utp.Serialize(payload.Extend(utp.Size()))
  16. payload.Write(content)
  17. if payload.Len() != int32(len(content))+utp.Size() {
  18. t.Error("unexpected payload length: ", payload.Len())
  19. }
  20. }