utp_test.go 512 B

1234567891011121314151617181920212223242526
  1. package utp_test
  2. import (
  3. "context"
  4. "testing"
  5. "v2ray.com/core/common/buf"
  6. . "v2ray.com/core/transport/internet/headers/utp"
  7. . "v2ray.com/ext/assert"
  8. )
  9. func TestUTPWrite(t *testing.T) {
  10. assert := With(t)
  11. content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
  12. utpRaw, err := New(context.Background(), &Config{})
  13. assert(err, IsNil)
  14. utp := utpRaw.(*UTP)
  15. payload := buf.New()
  16. payload.AppendSupplier(utp.Write)
  17. payload.Append(content)
  18. assert(payload.Len(), Equals, int32(len(content))+utp.Size())
  19. }