destination_test.go 672 B

123456789101112131415161718192021222324252627
  1. package net_test
  2. import (
  3. "testing"
  4. . "v2ray.com/core/common/net"
  5. . "v2ray.com/core/common/net/testing"
  6. . "v2ray.com/ext/assert"
  7. )
  8. func TestTCPDestination(t *testing.T) {
  9. assert := With(t)
  10. dest := TCPDestination(IPAddress([]byte{1, 2, 3, 4}), 80)
  11. assert(dest, IsTCP)
  12. assert(dest, Not(IsUDP))
  13. assert(dest.String(), Equals, "tcp:1.2.3.4:80")
  14. }
  15. func TestUDPDestination(t *testing.T) {
  16. assert := With(t)
  17. dest := UDPDestination(IPAddress([]byte{0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88}), 53)
  18. assert(dest, Not(IsTCP))
  19. assert(dest, IsUDP)
  20. assert(dest.String(), Equals, "udp:[2001:4860:4860::8888]:53")
  21. }