Add test for 'onionservicesonly' mode.

Credit to Dmitri Bogomolov in commit 557a8cc6d2bec881b8a3c531d3f725460ed515f5.
This commit is contained in:
George McCandless 2019-10-24 19:35:32 +00:00
parent b42f536d23
commit f871cd450c
No known key found for this signature in database
GPG Key ID: 62B9F5A4802A74BD

View File

@ -173,6 +173,22 @@ class TestCore(unittest.TestCase):
self.fail( self.fail(
'Failed to connect during %s sec' % (time.time() - _started)) 'Failed to connect during %s sec' % (time.time() - _started))
def test_onionservicesonly(self):
"""test onionservicesonly networking mode"""
BMConfigParser().set('bitmessagesettings', 'onionservicesonly', True)
self._initiate_bootstrap()
BMConfigParser().remove_option('bitmessagesettings', 'dontconnect')
for _ in range(360):
time.sleep(1)
for n, peer in enumerate(BMConnectionPool().outboundConnections):
if n > 2:
return
if not peer.host.endswith('.onion'):
self.fail(
'Found non onion hostname %s in outbound connections!'
% peer.host)
self.fail('Failed to connect to at least 3 nodes within 360 sec')
def test_bootstrap(self): def test_bootstrap(self):
"""test bootstrapping""" """test bootstrapping"""
self._initiate_bootstrap() self._initiate_bootstrap()