4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
6
6
import socket
7
+ import os
7
8
8
9
from test_framework .socks5 import Socks5Configuration , Socks5Command , Socks5Server , AddressType
9
10
from test_framework .test_framework import BitcoinTestFramework
10
- from test_framework .util import *
11
+ from test_framework .util import (
12
+ PORT_MIN ,
13
+ PORT_RANGE ,
14
+ start_nodes ,
15
+ assert_equal ,
16
+ )
11
17
from test_framework .netutil import test_ipv6_local
12
18
'''
13
19
Test plan:
33
39
addnode connect to generic DNS name
34
40
'''
35
41
42
+ RANGE_BEGIN = PORT_MIN + 2 * PORT_RANGE # Start after p2p and rpc ports
43
+
36
44
37
45
class ProxyTest (BitcoinTestFramework ):
38
46
def __init__ (self ):
@@ -44,19 +52,19 @@ def __init__(self):
44
52
# Create two proxies on different ports
45
53
# ... one unauthenticated
46
54
self .conf1 = Socks5Configuration ()
47
- self .conf1 .addr = ('127.0.0.1' , 13000 + (os .getpid () % 1000 ))
55
+ self .conf1 .addr = ('127.0.0.1' , RANGE_BEGIN + (os .getpid () % 1000 ))
48
56
self .conf1 .unauth = True
49
57
self .conf1 .auth = False
50
58
# ... one supporting authenticated and unauthenticated (Tor)
51
59
self .conf2 = Socks5Configuration ()
52
- self .conf2 .addr = ('127.0.0.1' , 14000 + (os .getpid () % 1000 ))
60
+ self .conf2 .addr = ('127.0.0.1' , RANGE_BEGIN + 1000 + (os .getpid () % 1000 ))
53
61
self .conf2 .unauth = True
54
62
self .conf2 .auth = True
55
63
if self .have_ipv6 :
56
64
# ... one on IPv6 with similar configuration
57
65
self .conf3 = Socks5Configuration ()
58
66
self .conf3 .af = socket .AF_INET6
59
- self .conf3 .addr = ('::1' , 15000 + (os .getpid () % 1000 ))
67
+ self .conf3 .addr = ('::1' , RANGE_BEGIN + 2000 + (os .getpid () % 1000 ))
60
68
self .conf3 .unauth = True
61
69
self .conf3 .auth = True
62
70
else :
0 commit comments