async def test_connecting_to_other_trio_endpoint(ipc_base_path): config = ConnectionConfig.from_name(generate_unique_name(), base_path=ipc_base_path) async with TrioEndpoint.serve(config): async with TrioEndpoint("client").run() as client: await client.connect_to_endpoints(config) assert client.is_connected_to(config.name)
async def test_trio_duplicate_endpoint_connection_is_error(ipc_base_path): config = ConnectionConfig.from_name(generate_unique_name(), base_path=ipc_base_path) async with TrioEndpoint.serve(config): async with TrioEndpoint("client").run() as client: await client.connect_to_endpoints(config) assert client.is_connected_to(config.name) with pytest.raises(ConnectionAttemptRejected): await client.connect_to_endpoints(config)
async def test_trio_server_endpoint_establishes_reverse_connection_to_client( ipc_base_path): unique_name = generate_unique_name() config = ConnectionConfig.from_name(f"server-{unique_name}", base_path=ipc_base_path) async with TrioEndpoint.serve(config) as server: async with TrioEndpoint(f"client-{unique_name}").run() as client: await client.connect_to_endpoints(config) assert client.is_connected_to(config.name) with trio.fail_after(2): await server.wait_until_connected_to(client.name)
async def endpoint_server(endpoint_server_config): async with TrioEndpoint.serve(endpoint_server_config) as endpoint: yield endpoint