fix LAN discovery/connection
This commit is contained in:
@@ -354,3 +354,76 @@ def test_legacy_start_subcommand_accepted(monkeypatch):
|
||||
|
||||
# Exited (either 0 or via KeyboardInterrupt caught in _cmd_start)
|
||||
# The important thing is no unhandled exception from arg parsing
|
||||
|
||||
|
||||
def test_legacy_start_treats_repo_model_as_model_id(monkeypatch):
|
||||
"""`meshnet-node start --model org/repo` enters the HF model startup path."""
|
||||
from meshnet_node.cli import main
|
||||
|
||||
captured = {}
|
||||
|
||||
def fake_run_startup(*args, **kwargs):
|
||||
captured.update(kwargs)
|
||||
class _FakeNode:
|
||||
chat_completion_count = 0
|
||||
def stop(self): pass
|
||||
return _FakeNode()
|
||||
|
||||
monkeypatch.setattr(sys, "argv", [
|
||||
"meshnet-node", "start",
|
||||
"--tracker", "http://192.168.0.179:8081",
|
||||
"--model", "Qwen/Qwen2.5-0.5B-Instruct",
|
||||
"--port", "0",
|
||||
])
|
||||
|
||||
with patch("meshnet_node.startup.run_startup", side_effect=fake_run_startup):
|
||||
with patch("time.sleep", side_effect=KeyboardInterrupt):
|
||||
try:
|
||||
main()
|
||||
except SystemExit as exc:
|
||||
assert exc.code == 0
|
||||
|
||||
assert captured["model"] == "Qwen2.5-0.5B-Instruct"
|
||||
assert captured["model_id"] == "Qwen/Qwen2.5-0.5B-Instruct"
|
||||
|
||||
|
||||
def test_default_cli_passes_advertise_host(monkeypatch):
|
||||
"""The documented no-subcommand LAN flag reaches startup."""
|
||||
from meshnet_node.cli import main
|
||||
|
||||
saved = {
|
||||
"model_hf_repo": "Qwen/Qwen2.5-0.5B-Instruct",
|
||||
"model_name": "Qwen2.5-0.5B-Instruct",
|
||||
"quantization": "nf4",
|
||||
"tracker_url": "http://localhost:8080",
|
||||
"wallet_path": "",
|
||||
"download_dir": "",
|
||||
"port": 7000,
|
||||
"host": "0.0.0.0",
|
||||
}
|
||||
captured = {}
|
||||
|
||||
def fake_run_startup(*args, **kwargs):
|
||||
captured.update(kwargs)
|
||||
class _FakeNode:
|
||||
chat_completion_count = 0
|
||||
def stop(self): pass
|
||||
return _FakeNode()
|
||||
|
||||
monkeypatch.setattr(sys, "argv", [
|
||||
"meshnet-node",
|
||||
"--tracker", "http://192.168.0.179:8081",
|
||||
"--advertise-host", "192.168.0.42",
|
||||
"--no-tui",
|
||||
])
|
||||
|
||||
with patch("meshnet_node.config.load_config", return_value=saved):
|
||||
with patch("meshnet_node.startup.run_startup", side_effect=fake_run_startup):
|
||||
with patch("meshnet_node.dashboard.run_dashboard", side_effect=KeyboardInterrupt):
|
||||
try:
|
||||
main()
|
||||
except SystemExit as exc:
|
||||
assert exc.code == 0
|
||||
|
||||
assert captured["tracker_url"] == "http://192.168.0.179:8081"
|
||||
assert captured["advertise_host"] == "192.168.0.42"
|
||||
|
||||
Reference in New Issue
Block a user