Avoid hard-coding ports where it is not relevant for Kademlia tests

This commit is contained in:
Alex Stokes
2019-11-05 17:08:18 -08:00
parent 5cb4479534
commit 94984be4df
4 changed files with 13 additions and 10 deletions

View File

@ -45,7 +45,10 @@ async def set_up_nodes_by_transport_and_disc_opt(transport_disc_opt_list):
return tuple(nodes_list)
async def set_up_routers(router_confs):
async def set_up_routers(router_confs=[0, 0]):
"""
The default ``router_confs`` selects two free ports local to this machine.
"""
bootstrap_node = KademliaServer()
await bootstrap_node.listen(router_confs[0])
@ -54,7 +57,7 @@ async def set_up_routers(router_confs):
node = KademliaServer()
await node.listen(port)
await node.bootstrap_node(("127.0.0.1", router_confs[0]))
await node.bootstrap_node(bootstrap_node.address)
routers.append(KadmeliaPeerRouter(node))
return routers