destination_test.go 742 B

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