diff --git a/src/tests/core.py b/src/tests/core.py index 52cea234..4857951a 100644 --- a/src/tests/core.py +++ b/src/tests/core.py @@ -18,6 +18,7 @@ import unittest import protocol import state +import subprocess import helper_sent import helper_addressbook @@ -263,9 +264,22 @@ class TestCore(unittest.TestCase): def test_bootstrap_tor(self): """test bootstrapping with tor""" BMConfigParser().set('bitmessagesettings', 'socksproxytype', 'SOCKS5') + iptables_rule = [ + 'OUTPUT', '-p', 'udp', '--dport', '53', '-j', 'REJECT'] + try: + subprocess.call(['sudo', 'iptables', '-A'] + iptables_rule) + except OSError: + print('Failed to use iptables ):') + else: + with self.assertRaises(socket.gaierror): + socket.getaddrinfo('bootstrap8080.bitmessage.org', 8444) self._initiate_bootstrap() self._check_connection() self._check_knownnodes() + try: + subprocess.call(['sudo', 'iptables', '-D'] + iptables_rule) + except OSError: + pass @unittest.skipIf(tor_port_free, 'no running tor detected') def test_onionservicesonly(self):