WIP: Add support for tor using PySocks and optionally stem #2

Draft
lee.miller wants to merge 22 commits from lee.miller/MiNode:tor into v0.3
2 changed files with 24 additions and 0 deletions
Showing only changes of commit 103c7a6cfa - Show all commits

View File

@ -18,6 +18,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):
@ -185,3 +190,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