fix integration tests

This commit is contained in:
Jack Robison 2019-12-01 17:21:42 -05:00
parent a3fe127a92
commit c894ade25e
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 6 additions and 0 deletions

View file

@ -24,8 +24,11 @@ def make_kademlia_peer(node_id: typing.Optional[bytes], address: typing.Optional
carrier_grade_NAT_subnet = ipaddress.ip_network('100.64.0.0/10') carrier_grade_NAT_subnet = ipaddress.ip_network('100.64.0.0/10')
ip4_to_6_relay_subnet = ipaddress.ip_network('192.88.99.0/24') ip4_to_6_relay_subnet = ipaddress.ip_network('192.88.99.0/24')
ALLOW_LOCALHOST = False
def is_valid_public_ipv4(address, allow_localhost: bool = False): def is_valid_public_ipv4(address, allow_localhost: bool = False):
allow_localhost = bool(allow_localhost or ALLOW_LOCALHOST)
try: try:
parsed_ip = ipaddress.ip_address(address) parsed_ip = ipaddress.ip_address(address)
if parsed_ip.is_loopback and allow_localhost: if parsed_ip.is_loopback and allow_localhost:

View file

@ -3,6 +3,7 @@ from binascii import hexlify
from lbry.dht import constants from lbry.dht import constants
from lbry.dht.node import Node from lbry.dht.node import Node
from lbry.dht import peer as dht_peer
from lbry.dht.peer import PeerManager, make_kademlia_peer from lbry.dht.peer import PeerManager, make_kademlia_peer
from torba.testcase import AsyncioTestCase from torba.testcase import AsyncioTestCase
@ -10,6 +11,8 @@ from torba.testcase import AsyncioTestCase
class DHTIntegrationTest(AsyncioTestCase): class DHTIntegrationTest(AsyncioTestCase):
async def asyncSetUp(self): async def asyncSetUp(self):
dht_peer.ALLOW_LOCALHOST = True
self.addCleanup(setattr, dht_peer, 'ALLOW_LOCALHOST', False)
import logging import logging
logging.getLogger('asyncio').setLevel(logging.ERROR) logging.getLogger('asyncio').setLevel(logging.ERROR)
logging.getLogger('lbry.dht').setLevel(logging.WARN) logging.getLogger('lbry.dht').setLevel(logging.WARN)