fix integration tests
This commit is contained in:
parent
a3fe127a92
commit
c894ade25e
2 changed files with 6 additions and 0 deletions
|
@ -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:
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue