Changeset View
Changeset View
Standalone View
Standalone View
test/functional/proxy_test.py
Show All 37 Lines | from test_framework.util import ( | ||||
assert_equal, | assert_equal, | ||||
) | ) | ||||
from test_framework.netutil import test_ipv6_local | from test_framework.netutil import test_ipv6_local | ||||
RANGE_BEGIN = PORT_MIN + 2 * PORT_RANGE # Start after p2p and rpc ports | RANGE_BEGIN = PORT_MIN + 2 * PORT_RANGE # Start after p2p and rpc ports | ||||
class ProxyTest(BitcoinTestFramework): | class ProxyTest(BitcoinTestFramework): | ||||
def set_test_params(self): | |||||
def __init__(self): | |||||
super().__init__() | |||||
self.num_nodes = 4 | self.num_nodes = 4 | ||||
self.setup_clean_chain = False | |||||
def setup_nodes(self): | def setup_nodes(self): | ||||
self.have_ipv6 = test_ipv6_local() | self.have_ipv6 = test_ipv6_local() | ||||
# Create two proxies on different ports | # Create two proxies on different ports | ||||
# ... one unauthenticated | # ... one unauthenticated | ||||
self.conf1 = Socks5Configuration() | self.conf1 = Socks5Configuration() | ||||
self.conf1.addr = ('127.0.0.1', RANGE_BEGIN + (os.getpid() % 1000)) | self.conf1.addr = ('127.0.0.1', RANGE_BEGIN + (os.getpid() % 1000)) | ||||
self.conf1.unauth = True | self.conf1.unauth = True | ||||
Show All 33 Lines | def setup_nodes(self): | ||||
(self.conf1.addr), '-onion=%s:%i' % (self.conf2.addr), '-proxyrandomize=0'], | (self.conf1.addr), '-onion=%s:%i' % (self.conf2.addr), '-proxyrandomize=0'], | ||||
['-listen', '-proxy=%s:%i' % | ['-listen', '-proxy=%s:%i' % | ||||
(self.conf2.addr), '-proxyrandomize=1'], | (self.conf2.addr), '-proxyrandomize=1'], | ||||
[] | [] | ||||
] | ] | ||||
if self.have_ipv6: | if self.have_ipv6: | ||||
args[3] = ['-listen', '-proxy=[%s]:%i' % | args[3] = ['-listen', '-proxy=[%s]:%i' % | ||||
(self.conf3.addr), '-proxyrandomize=0', '-noonion'] | (self.conf3.addr), '-proxyrandomize=0', '-noonion'] | ||||
self.nodes = self.start_nodes( | self.add_nodes(self.num_nodes, extra_args=args) | ||||
self.num_nodes, self.options.tmpdir, extra_args=args) | self.start_nodes() | ||||
def node_test(self, node, proxies, auth, test_onion=True): | def node_test(self, node, proxies, auth, test_onion=True): | ||||
rv = [] | rv = [] | ||||
# Test: outgoing IPv4 connection through node | # Test: outgoing IPv4 connection through node | ||||
node.addnode("15.61.23.23:1234", "onetry") | node.addnode("15.61.23.23:1234", "onetry") | ||||
cmd = proxies[0].queue.get() | cmd = proxies[0].queue.get() | ||||
assert(isinstance(cmd, Socks5Command)) | assert(isinstance(cmd, Socks5Command)) | ||||
# Note: bitcoind's SOCKS5 implementation only sends atyp DOMAINNAME, | # Note: bitcoind's SOCKS5 implementation only sends atyp DOMAINNAME, | ||||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |