test descriptions
This commit is contained in:
@@ -14,6 +14,7 @@ from unittest.mock import MagicMock, patch
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_load_or_create_identity_generates_peer_id(tmp_path):
|
||||
"Load or create identity generates peer id\n\nTags: gossip, network, relay"
|
||||
from meshnet_p2p.identity import load_or_create_identity
|
||||
|
||||
identity = load_or_create_identity(tmp_path / "identity.json")
|
||||
@@ -23,6 +24,7 @@ def test_load_or_create_identity_generates_peer_id(tmp_path):
|
||||
|
||||
|
||||
def test_identity_is_stable_across_loads(tmp_path):
|
||||
"Identity is stable across loads\n\nTags: gossip, network, relay"
|
||||
from meshnet_p2p.identity import load_or_create_identity
|
||||
|
||||
path = tmp_path / "identity.json"
|
||||
@@ -33,6 +35,7 @@ def test_identity_is_stable_across_loads(tmp_path):
|
||||
|
||||
|
||||
def test_identity_different_for_different_paths(tmp_path):
|
||||
"Identity different for different paths\n\nTags: gossip, network, relay"
|
||||
from meshnet_p2p.identity import load_or_create_identity
|
||||
|
||||
a = load_or_create_identity(tmp_path / "a.json")
|
||||
@@ -42,6 +45,7 @@ def test_identity_different_for_different_paths(tmp_path):
|
||||
|
||||
|
||||
def test_relay_peer_id_includes_node_name_for_shared_wallet():
|
||||
"Relay peer id includes node name for shared wallet\n\nTags: gossip, network, relay, security, wallet"
|
||||
from meshnet_node.relay_bridge import peer_id_from_wallet
|
||||
|
||||
wallet = "5gMLrmyBYTpkFjmyc4eGwcaWhYquyWgCBFFEqHzR5Qur"
|
||||
@@ -51,6 +55,7 @@ def test_relay_peer_id_includes_node_name_for_shared_wallet():
|
||||
|
||||
|
||||
def test_relay_peer_id_falls_back_to_endpoint_port_integer():
|
||||
"Relay peer id falls back to endpoint port integer\n\nTags: gossip, network, relay"
|
||||
from meshnet_node.relay_bridge import peer_id_from_wallet
|
||||
|
||||
wallet = "5gMLrmyBYTpkFjmyc4eGwcaWhYquyWgCBFFEqHzR5Qur"
|
||||
@@ -68,6 +73,7 @@ def test_relay_peer_id_falls_back_to_endpoint_port_integer():
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_generate_self_signed_cert_creates_files(tmp_path):
|
||||
"Generate self signed cert creates files\n\nTags: gossip, network, relay"
|
||||
from meshnet_p2p.tls import generate_self_signed_cert
|
||||
|
||||
cert_p, key_p = generate_self_signed_cert(
|
||||
@@ -82,6 +88,7 @@ def test_generate_self_signed_cert_creates_files(tmp_path):
|
||||
|
||||
|
||||
def test_generate_self_signed_cert_is_idempotent(tmp_path):
|
||||
"Generate self signed cert is idempotent\n\nTags: gossip, network, relay"
|
||||
from meshnet_p2p.tls import generate_self_signed_cert
|
||||
|
||||
args = dict(cert_path=tmp_path / "cert.pem", key_path=tmp_path / "key.pem", common_name="test")
|
||||
@@ -94,6 +101,7 @@ def test_generate_self_signed_cert_is_idempotent(tmp_path):
|
||||
|
||||
|
||||
def test_cert_fingerprint_returns_sha256_prefix(tmp_path):
|
||||
"Cert fingerprint returns sha256 prefix\n\nTags: gossip, network, relay"
|
||||
from meshnet_p2p.tls import generate_self_signed_cert, cert_fingerprint
|
||||
|
||||
cert_p, key_p = generate_self_signed_cert(
|
||||
@@ -107,6 +115,7 @@ def test_cert_fingerprint_returns_sha256_prefix(tmp_path):
|
||||
|
||||
|
||||
def test_make_server_ssl_context_loads_cert(tmp_path):
|
||||
"Make server ssl context loads cert\n\nTags: gossip, network, relay"
|
||||
import ssl
|
||||
from meshnet_p2p.tls import generate_self_signed_cert, make_server_ssl_context
|
||||
|
||||
@@ -124,6 +133,7 @@ def test_make_server_ssl_context_loads_cert(tmp_path):
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_peer_registry_register_and_list():
|
||||
"Peer registry register and list\n\nTags: gossip, network, relay"
|
||||
from meshnet_relay.peer_registry import PeerRegistry
|
||||
|
||||
reg = PeerRegistry()
|
||||
@@ -137,6 +147,7 @@ def test_peer_registry_register_and_list():
|
||||
|
||||
|
||||
def test_peer_registry_all_except_excludes_sender():
|
||||
"Peer registry all except excludes sender\n\nTags: gossip, network, relay"
|
||||
from meshnet_relay.peer_registry import PeerRegistry
|
||||
|
||||
reg = PeerRegistry()
|
||||
@@ -150,6 +161,7 @@ def test_peer_registry_all_except_excludes_sender():
|
||||
|
||||
|
||||
def test_peer_registry_unregister_removes_peer():
|
||||
"Peer registry unregister removes peer\n\nTags: gossip, network, relay"
|
||||
from meshnet_relay.peer_registry import PeerRegistry
|
||||
|
||||
reg = PeerRegistry()
|
||||
@@ -171,7 +183,8 @@ def _start_relay(host="127.0.0.1", port=0):
|
||||
|
||||
|
||||
def test_gossip_fanout_through_relay():
|
||||
"""Node B publishes node-join; node A receives it within 2 seconds."""
|
||||
"Node B publishes node-join; node A receives it within 2 seconds.\n\nTags: gossip, network, relay"
|
||||
|
||||
from meshnet_p2p.gossip import GossipClient, TOPIC_NODE_JOIN
|
||||
|
||||
relay, port = _start_relay()
|
||||
@@ -208,7 +221,8 @@ def test_gossip_fanout_through_relay():
|
||||
|
||||
|
||||
def test_gossip_dedup_prevents_processing_duplicate_message_ids():
|
||||
"""A message with a duplicate msg_id is only processed once."""
|
||||
"A message with a duplicate msg_id is only processed once.\n\nTags: gossip, network, relay"
|
||||
|
||||
from meshnet_p2p.gossip import GossipClient, TOPIC_NODE_JOIN
|
||||
|
||||
relay, port = _start_relay()
|
||||
@@ -241,7 +255,8 @@ def test_gossip_dedup_prevents_processing_duplicate_message_ids():
|
||||
|
||||
|
||||
def test_relay_server_peer_list_grows_on_connect():
|
||||
"""Relay registry grows when clients connect."""
|
||||
"Relay registry grows when clients connect.\n\nTags: gossip, network, relay"
|
||||
|
||||
from meshnet_p2p.gossip import GossipClient
|
||||
|
||||
relay, port = _start_relay()
|
||||
@@ -260,7 +275,8 @@ def test_relay_server_peer_list_grows_on_connect():
|
||||
|
||||
|
||||
def test_relay_circuit_relay_proxies_message():
|
||||
"""A node behind NAT (client_a) receives a message via circuit relay from client_b."""
|
||||
"A node behind NAT (client_a) receives a message via circuit relay from client_b.\n\nTags: gossip, network, relay"
|
||||
|
||||
import websockets.sync.client # type: ignore[import]
|
||||
from meshnet_relay.server import RelayServer
|
||||
|
||||
@@ -318,7 +334,8 @@ def test_relay_circuit_relay_proxies_message():
|
||||
|
||||
|
||||
def test_relay_rpc_round_trips_http_request_to_peer():
|
||||
"""Relay /rpc/<peer> sends one HTTP-shaped request to a connected peer."""
|
||||
"Relay /rpc/<peer> sends one HTTP-shaped request to a connected peer.\n\nTags: gossip, network, relay"
|
||||
|
||||
import websockets.sync.client as wsc # type: ignore[import]
|
||||
from meshnet_relay.server import RelayServer
|
||||
|
||||
@@ -373,7 +390,8 @@ def test_relay_rpc_round_trips_http_request_to_peer():
|
||||
|
||||
|
||||
def test_relay_rpc_reuses_connection_for_sequential_requests(monkeypatch):
|
||||
"""One route session should not repeat the WebSocket handshake per token."""
|
||||
"One route session should not repeat the WebSocket handshake per token.\n\nTags: gossip, network, relay"
|
||||
|
||||
import websockets.sync.client as wsc # type: ignore[import]
|
||||
from meshnet_node.relay_bridge import decode_binary_frame, encode_binary_frame
|
||||
from meshnet_node.torch_server import _RelayHopClient
|
||||
@@ -437,7 +455,8 @@ def test_relay_rpc_reuses_connection_for_sequential_requests(monkeypatch):
|
||||
|
||||
|
||||
def test_binary_relay_frame_codecs_interoperate():
|
||||
"""Node and relay ship the same binary frame format as separate copies."""
|
||||
"Node and relay ship the same binary frame format as separate copies.\n\nTags: gossip, network, relay"
|
||||
|
||||
import os
|
||||
|
||||
from meshnet_node import relay_bridge
|
||||
@@ -460,7 +479,8 @@ def test_binary_relay_frame_codecs_interoperate():
|
||||
|
||||
|
||||
def test_activation_compression_round_trips_and_skips_small_bodies():
|
||||
"""Pipeline hops zstd-compress large activations; tiny decode bodies pass raw."""
|
||||
"Pipeline hops zstd-compress large activations; tiny decode bodies pass raw.\n\nTags: gossip, network, relay"
|
||||
|
||||
import os
|
||||
|
||||
from meshnet_node.server import _decompress_body
|
||||
@@ -477,13 +497,8 @@ def test_activation_compression_round_trips_and_skips_small_bodies():
|
||||
|
||||
|
||||
def test_relay_rpc_carries_activation_sized_frames():
|
||||
"""A >1 MiB activation body must survive the full relay round trip.
|
||||
"A >1 MiB activation body must survive the full relay round trip.\n\nTags: gossip, network, relay"
|
||||
|
||||
Regression: the websockets library caps frames at 1 MiB by default, so
|
||||
prefill activations forwarded via /rpc/<peer> died with close code 1009
|
||||
at every hop (requester → relay, relay → bridge, bridge → relay → requester).
|
||||
The body now travels as binary frames — raw bytes, no base64.
|
||||
"""
|
||||
import http.server
|
||||
import os
|
||||
|
||||
@@ -540,7 +555,8 @@ def test_relay_rpc_carries_activation_sized_frames():
|
||||
|
||||
|
||||
def test_node_relay_bridge_reconnects_after_failed_connection(monkeypatch):
|
||||
"""Node-side relay bridge keeps retrying its outbound WebSocket connection."""
|
||||
"Node-side relay bridge keeps retrying its outbound WebSocket connection.\n\nTags: gossip, network, relay"
|
||||
|
||||
import websockets.sync.client as wsc # type: ignore[import]
|
||||
from meshnet_node.relay_bridge import RelayHttpBridge
|
||||
|
||||
@@ -624,6 +640,7 @@ def _start_tracker_and_register(extra_fields: dict) -> dict:
|
||||
|
||||
|
||||
def test_tracker_derives_relay_url_from_public_self_url():
|
||||
"Tracker derives relay url from public self url\n\nTags: gossip, network, relay"
|
||||
from meshnet_tracker.server import TrackerServer, derive_relay_url_from_public_tracker_url
|
||||
|
||||
assert derive_relay_url_from_public_tracker_url("https://ai.neuron.d-popov.com") == (
|
||||
@@ -647,6 +664,7 @@ def test_tracker_derives_relay_url_from_public_self_url():
|
||||
|
||||
|
||||
def test_tracker_accepts_relay_addr_in_registration():
|
||||
"Tracker accepts relay addr in registration\n\nTags: gossip, network, relay"
|
||||
resp = _start_tracker_and_register({
|
||||
"relay_addr": "ws://relay.meshnet.ai:8765/relay/abc123",
|
||||
"cert_fingerprint": "sha256:deadbeef",
|
||||
@@ -656,12 +674,14 @@ def test_tracker_accepts_relay_addr_in_registration():
|
||||
|
||||
|
||||
def test_tracker_accepts_registration_without_gossip_fields():
|
||||
"""Existing registrations without P2P fields still work."""
|
||||
"Existing registrations without P2P fields still work.\n\nTags: gossip, network, relay"
|
||||
|
||||
resp = _start_tracker_and_register({})
|
||||
assert "node_id" in resp
|
||||
|
||||
|
||||
def test_tracker_network_map_exposes_relay_and_registered_peer():
|
||||
"Tracker network map exposes relay and registered peer\n\nTags: gossip, network, relay"
|
||||
import json as _json
|
||||
import urllib.request
|
||||
|
||||
@@ -698,6 +718,7 @@ def test_tracker_network_map_exposes_relay_and_registered_peer():
|
||||
|
||||
|
||||
def test_tracker_can_embed_relay_server_and_advertise_it():
|
||||
"Tracker can embed relay server and advertise it\n\nTags: gossip, network, relay"
|
||||
import json as _json
|
||||
import urllib.request
|
||||
|
||||
@@ -737,6 +758,7 @@ def test_tracker_can_embed_relay_server_and_advertise_it():
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_mdns_discovery_is_available_flag():
|
||||
"Mdns discovery is available flag\n\nTags: gossip, network, relay"
|
||||
from meshnet_p2p.mdns import MdnsDiscovery
|
||||
|
||||
disc = MdnsDiscovery(peer_id="test", port=8001)
|
||||
@@ -745,6 +767,7 @@ def test_mdns_discovery_is_available_flag():
|
||||
|
||||
|
||||
def test_mdns_start_and_stop_without_zeroconf(monkeypatch):
|
||||
"Mdns start and stop without zeroconf\n\nTags: gossip, network, relay"
|
||||
from meshnet_p2p import mdns as mdns_mod
|
||||
monkeypatch.setattr(mdns_mod, "_HAS_ZEROCONF", False)
|
||||
from meshnet_p2p.mdns import MdnsDiscovery
|
||||
@@ -804,7 +827,8 @@ def _run_streaming_peer(port: int, peer_id: str, ready: threading.Event):
|
||||
|
||||
|
||||
def test_relay_rpc_forwards_streamed_frames_in_order():
|
||||
"""A streamed response traverses the relay as multiple frames ending with done."""
|
||||
"A streamed response traverses the relay as multiple frames ending with done.\n\nTags: gossip, network, relay, streaming"
|
||||
|
||||
import websockets.sync.client as wsc # type: ignore[import]
|
||||
from meshnet_relay.server import RelayServer
|
||||
|
||||
@@ -842,7 +866,8 @@ def test_relay_rpc_forwards_streamed_frames_in_order():
|
||||
|
||||
|
||||
def test_tracker_relay_http_request_collapses_streamed_frames():
|
||||
"""Buffered wrapper joins chunk frames into one response body."""
|
||||
"Buffered wrapper joins chunk frames into one response body.\n\nTags: gossip, network, relay, streaming"
|
||||
|
||||
from meshnet_relay.server import RelayServer
|
||||
from meshnet_tracker.server import _relay_http_request
|
||||
|
||||
@@ -871,6 +896,7 @@ def test_tracker_relay_http_request_collapses_streamed_frames():
|
||||
|
||||
|
||||
def test_stream_line_tokens_accounting():
|
||||
"Stream line tokens accounting\n\nTags: gossip, network, relay, streaming"
|
||||
from meshnet_tracker.server import _stream_line_tokens
|
||||
|
||||
assert _stream_line_tokens(b": comment") == (0, None)
|
||||
@@ -885,7 +911,8 @@ def test_stream_line_tokens_accounting():
|
||||
|
||||
|
||||
def test_relay_bridge_streams_sse_as_chunk_frames():
|
||||
"""Bridge forwards a local SSE response as header + chunk frames + done."""
|
||||
"Bridge forwards a local SSE response as header + chunk frames + done.\n\nTags: gossip, network, relay, streaming"
|
||||
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
from meshnet_node.relay_bridge import RelayHttpBridge
|
||||
|
||||
@@ -931,6 +958,7 @@ def test_relay_bridge_streams_sse_as_chunk_frames():
|
||||
|
||||
|
||||
def test_relay_bridge_non_stream_response_stays_single_frame():
|
||||
"Relay bridge non stream response stays single frame\n\nTags: gossip, network, relay, streaming"
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
from meshnet_node.relay_bridge import RelayHttpBridge
|
||||
|
||||
@@ -973,7 +1001,8 @@ def test_relay_bridge_non_stream_response_stays_single_frame():
|
||||
|
||||
|
||||
def test_relay_bridge_serves_concurrent_requests():
|
||||
"""US-037: a slow relayed request must not block a fast one."""
|
||||
"US-037: a slow relayed request must not block a fast one.\n\nTags: gossip, network, relay"
|
||||
|
||||
import websockets.sync.client as wsc # type: ignore[import]
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
from meshnet_node.relay_bridge import RelayHttpBridge
|
||||
|
||||
Reference in New Issue
Block a user