destination_test.go 714 B

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