-cpu flag

This commit is contained in:
Dobromir Popov
2026-07-09 08:19:15 +03:00
parent 4ed585bf54
commit 9ec4ca9ce1
8 changed files with 121 additions and 11 deletions

View File

@@ -610,3 +610,44 @@ def test_default_cli_passes_advertise_host(monkeypatch):
assert captured["tracker_url"] == "http://192.168.0.179:8081"
assert captured["advertise_host"] == "192.168.0.42"
assert captured["debug"] is True
def test_default_cli_passes_force_cpu(monkeypatch):
"""`meshnet-node --cpu` forwards force_cpu into run_startup."""
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()
saved = {
"tracker_url": "http://localhost:8080",
"model_name": "stub-model",
"model_hf_repo": "",
"quantization": "auto",
"download_dir": "/tmp/models",
"wallet_path": "/tmp/wallet.json",
"port": 7000,
"host": "0.0.0.0",
}
monkeypatch.setattr(sys, "argv", ["meshnet-node", "--cpu"])
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["force_cpu"] is True