Skip to content

Commit ab14fb2

Browse files
committed
Initial implementation of simradio-based testing with a multi-node simulated mesh
1 parent 7a7353c commit ab14fb2

6 files changed

Lines changed: 773 additions & 136 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,26 @@ jobs:
7070
pip3 install poetry
7171
poetry install
7272
poetry run meshtastic --version
73+
74+
firmware:
75+
runs-on: ubuntu-latest
76+
steps:
77+
- uses: actions/checkout@v4
78+
- name: Install Python 3
79+
uses: actions/setup-python@v5
80+
with:
81+
python-version: "3.12"
82+
- name: Install meshtastic from local
83+
run: |
84+
python -m pip install --upgrade pip
85+
pip3 install poetry
86+
poetry install --all-extras --with dev
87+
poetry run meshtastic --version
88+
- name: Install meshtasticd (beta) from PPA
89+
run: |
90+
sudo add-apt-repository -y ppa:meshtastic/beta
91+
sudo apt-get update
92+
sudo apt-get install -y meshtasticd
93+
- name: Run firmware smoke tests
94+
run: poetry run pytest -m "smokevirt or smokemesh" -v
95+
timeout-minutes: 15

meshtastic/tests/conftest.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,56 @@
88
from meshtastic import mt_config
99

1010
from ..mesh_interface import MeshInterface
11+
from .firmware_harness import (
12+
CHAIN_TOPOLOGY,
13+
DEFAULT_BASE_PORT,
14+
SimMesh,
15+
find_meshtasticd,
16+
is_compatible_host,
17+
)
18+
19+
# Use a different base port for the single-node fixture so it doesn't
20+
# conflict with the multi-node mesh fixture (both are session-scoped).
21+
SINGLE_NODE_BASE_PORT = DEFAULT_BASE_PORT + 100
22+
23+
24+
def _skip_firmware_if_unavailable() -> None:
25+
"""Skip the test when meshtasticd can't run on this host."""
26+
if not is_compatible_host():
27+
pytest.skip("meshtasticd firmware tests require Linux")
28+
if find_meshtasticd() is None:
29+
pytest.skip(
30+
"meshtasticd not found — set MESHTASTICD_BIN or install it on PATH"
31+
)
32+
33+
34+
@pytest.fixture(scope="session")
35+
def firmware_node():
36+
"""A single meshtasticd sim node for smokevirt tests.
37+
38+
Yields the SimNode instance. The node is booted with a fresh erased
39+
config and listens on localhost at its TCP port.
40+
"""
41+
_skip_firmware_if_unavailable()
42+
mesh = SimMesh(n_nodes=1, base_port=SINGLE_NODE_BASE_PORT)
43+
mesh.start()
44+
yield mesh.get_node(0)
45+
mesh.stop()
46+
47+
48+
@pytest.fixture(scope="function")
49+
def firmware_mesh():
50+
"""A 3-node chain (A-B-C) meshtasticd sim mesh for smokemesh tests.
51+
52+
Yields the SimMesh instance. Nodes are connected and the SIMULATOR_APP
53+
packet bridge is running. Node DB convergence is awaited.
54+
"""
55+
_skip_firmware_if_unavailable()
56+
mesh = SimMesh(n_nodes=3, topology=CHAIN_TOPOLOGY)
57+
mesh.start()
58+
mesh.wait_for_convergence(timeout=30)
59+
yield mesh
60+
mesh.stop()
1161

1262

1363
@pytest.fixture

0 commit comments

Comments
 (0)