""" The Node page's Peers tab: one row per live session, from the loopback API. `_get_remote_ip` moved out of `webrtc_server.py` and the endpoint's import, inside the function, went on naming the old place. Nothing imports a function body until it runs, so the tab answered 500 and nothing else noticed. """ from types import SimpleNamespace from fastapi.testclient import TestClient from meshbay_node.ui.app import create_ui_app def test_the_peers_tab_lists_a_live_session(): session = SimpleNamespace( _user_id="u-bob", _group_id="g" * 32, _username="bob", # No address learnt at the handshake: the endpoint asks the ICE # transport, which is the line that broke. _remote_ip="", _pc=SimpleNamespace(sctp=None, connectionState="connected")) state = {"status": "running", "webrtc": SimpleNamespace(_sessions={"p1": session})} resp = TestClient(create_ui_app(state)).get("/api/peers") assert resp.status_code == 200, resp.text assert resp.json() == {"peers": [{ "peer_id": "p1", "user_id": "u-bob", "username": "bob", "group_id": "g" * 32, "group_name": "", "remote_ip": "", "state": "connected"}]}