40
40
"""
41
41
42
42
import socket
43
- import os
44
43
45
44
from test_framework .socks5 import Socks5Configuration , Socks5Command , Socks5Server , AddressType
46
45
from test_framework .test_framework import BitcoinTestFramework
47
46
from test_framework .util import (
48
- PORT_MIN ,
49
- PORT_RANGE ,
50
47
assert_equal ,
48
+ p2p_port ,
51
49
)
52
50
from test_framework .netutil import test_ipv6_local
53
51
54
- RANGE_BEGIN = PORT_MIN + 2 * PORT_RANGE # Start after p2p and rpc ports
55
-
56
52
# Networks returned by RPC getpeerinfo.
57
53
NET_UNROUTABLE = "not_publicly_routable"
58
54
NET_IPV4 = "ipv4"
@@ -75,19 +71,19 @@ def setup_nodes(self):
75
71
# Create two proxies on different ports
76
72
# ... one unauthenticated
77
73
self .conf1 = Socks5Configuration ()
78
- self .conf1 .addr = ('127.0.0.1' , RANGE_BEGIN + ( os . getpid () % 1000 ))
74
+ self .conf1 .addr = ('127.0.0.1' , p2p_port ( self . num_nodes ))
79
75
self .conf1 .unauth = True
80
76
self .conf1 .auth = False
81
77
# ... one supporting authenticated and unauthenticated (Tor)
82
78
self .conf2 = Socks5Configuration ()
83
- self .conf2 .addr = ('127.0.0.1' , RANGE_BEGIN + 1000 + ( os . getpid () % 1000 ))
79
+ self .conf2 .addr = ('127.0.0.1' , p2p_port ( self . num_nodes + 1 ))
84
80
self .conf2 .unauth = True
85
81
self .conf2 .auth = True
86
82
if self .have_ipv6 :
87
83
# ... one on IPv6 with similar configuration
88
84
self .conf3 = Socks5Configuration ()
89
85
self .conf3 .af = socket .AF_INET6
90
- self .conf3 .addr = ('::1' , RANGE_BEGIN + 2000 + ( os . getpid () % 1000 ))
86
+ self .conf3 .addr = ('::1' , p2p_port ( self . num_nodes + 2 ))
91
87
self .conf3 .unauth = True
92
88
self .conf3 .auth = True
93
89
else :
0 commit comments