Add a simple blind test for process running with --socks-proxy
This commit is contained in:
parent
50206a844c
commit
c43124bfe5
|
@ -16,6 +16,11 @@ try:
|
|||
i2p_port_free = True
|
||||
except (OSError, socket.error):
|
||||
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):
|
||||
|
@ -154,3 +159,21 @@ class TestProcessI2P(TestProcess):
|
|||
class TestProcessNoI2P(TestProcessShutdown):
|
||||
"""Test minode process shutdown with --i2p and 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
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
coverage
|
||||
psutil
|
||||
PySocks
|
||||
|
|
Loading…
Reference in New Issue
Block a user