Add a simple blind test for process running with --socks-proxy

This commit is contained in:
Lee Miller 2023-04-13 21:00:31 +03:00
parent 6bd3190349
commit 4cc55e7242
Signed by: lee.miller
GPG Key ID: 4F97A5EA88F4AB63
2 changed files with 24 additions and 0 deletions

View File

@ -14,6 +14,11 @@ try:
i2p_port_free = True i2p_port_free = True
except (OSError, socket.error): except (OSError, socket.error):
i2p_port_free = False i2p_port_free = False
try:
socket.socket().bind(('127.0.0.1', 9050))
tor_port_free = True
except (OSError, socket.error):
tor_port_free = False
class TestProcessProto(unittest.TestCase): class TestProcessProto(unittest.TestCase):
@ -146,3 +151,21 @@ class TestProcessI2P(TestProcess):
class TestProcessNoI2P(TestProcessShutdown): class TestProcessNoI2P(TestProcessShutdown):
"""Test minode process shutdown with --i2p and no IP""" """Test minode process shutdown with --i2p and no IP"""
_process_cmd = ['minode', '--i2p', '--no-ip'] _process_cmd = ['minode', '--i2p', '--no-ip']
@unittest.skipIf(tor_port_free, 'No running tor detected')
class TestProcessTor(TestProcessProto):
"""A test case for minode process running with tor enabled"""
_process_cmd = ['minode', '--socks-proxy', '127.0.0.1:9050']
_wait_time = 60
def test_connections(self):
"""Check minode process connections"""
for _ in range(self._wait_time):
time.sleep(0.5)
connections = self.connections()
for c in connections:
self.assertEqual(c.raddr[0], '127.0.0.1')
self.assertEqual(c.raddr[1], 9050)
if len(connections) > self._connection_limit / 2:
break

View File

@ -1,2 +1,3 @@
coverage coverage
psutil psutil
PySocks