summaryrefslogtreecommitdiff
path: root/dialer_test.go
blob: aa00a60a95d62b7f2fa7cf91b64e62d0107562f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package obfsvpn

import (
	"context"
	"testing"
)

const cert = "8nuAbPJwFrKc/29KcCfL5LBuEWxQrjBASYXdUbwcm9d9pKseGK4r2Tg47e23+t6WghxGGw"

func TestDial(t *testing.T) {
	defer func() {
		if r := recover(); r != nil {
			t.Error("Dial paniced")
		}
	}()

	dialer, err := NewDialerFromCert(cert)
	if err != nil {
		t.Errorf("Error creating client from cert: %v", err)
	}

	_, err = dialer.Dial("tcp", "127.0.0.1:4430")
	if err == nil {
		t.Errorf("No Error in d.Dial when trying invalid address: %v", err)
	}
}

func TestDialContext(t *testing.T) {
	defer func() {
		if r := recover(); r != nil {
			t.Error("DialContext paniced")
		}
	}()

	dialer, err := NewDialerFromCert(cert)
	if err != nil {
		t.Errorf("Error creating client from cert: %v", err)
	}

	_, err = dialer.DialContext(context.Background(), "tcp", "127.0.0.1:4430")
	if err == nil {
		t.Errorf("No Error in d.Dial when trying invalid address: %v", err)
	}
}