destination_test.go 801 B

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