Skip to content

Commit 4333b1c

Browse files
committed
Merge #9151: [qa] proxy_test: Calculate hardcoded port numbers
fa80ef8 [qa] proxy_test: Calculate hardcoded port numbers instead (MarcoFalke)
2 parents 918ea16 + fa80ef8 commit 4333b1c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

qa/rpc-tests/proxy_test.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

66
import socket
7+
import os
78

89
from test_framework.socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType
910
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+
)
1117
from test_framework.netutil import test_ipv6_local
1218
'''
1319
Test plan:
@@ -33,6 +39,8 @@
3339
addnode connect to generic DNS name
3440
'''
3541

42+
RANGE_BEGIN = PORT_MIN + 2 * PORT_RANGE # Start after p2p and rpc ports
43+
3644

3745
class ProxyTest(BitcoinTestFramework):
3846
def __init__(self):
@@ -44,19 +52,19 @@ def __init__(self):
4452
# Create two proxies on different ports
4553
# ... one unauthenticated
4654
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))
4856
self.conf1.unauth = True
4957
self.conf1.auth = False
5058
# ... one supporting authenticated and unauthenticated (Tor)
5159
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))
5361
self.conf2.unauth = True
5462
self.conf2.auth = True
5563
if self.have_ipv6:
5664
# ... one on IPv6 with similar configuration
5765
self.conf3 = Socks5Configuration()
5866
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))
6068
self.conf3.unauth = True
6169
self.conf3.auth = True
6270
else:

0 commit comments

Comments
 (0)