started get new peers test

This commit is contained in:
Kevin F 2022-05-14 11:28:12 -05:00
parent 2be0175326
commit 12d4ed7638

View File

@ -36,7 +36,6 @@ TRANSPORT_SIZE_BYTES = 64
server_file = TEST_DIR + 'test_serv.sock'
class MockPeer:
def __init__(self):
self.transport_address = secrets.token_hex(16)
@ -49,6 +48,21 @@ class MockPeer:
return s
def _server():
fake_peer_addresses = [MockPeer().transport_address for i in range(10)]
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
s.bind(server_file)
s.listen(1)
conn, _ = s.accept()
with conn:
conn.recv(1)
for address in fake_peer_addresses:
conn.sendall(address.zfill(TRANSPORT_SIZE_BYTES).encode('utf-8'))
Thread(target=_server, daemon=True).start()
class OnionrGossipClientGetNewPeers(unittest.TestCase):