Files
meshcore-bot/tests/unit/test_split_path_hex.py
T
agessaman 3f6ff87991 refactor(message_handler): one split_path_hex for multi-byte path chunking
Five copies split a hex path into node IDs of N characters and fell back to one-byte nodes when the path did not divide evenly. They now call split_path_hex; the one caller that wanted uppercase nodes upper-cases the result. The observed-path parser that drops an incomplete trailing node instead of falling back keeps its own loop.
2026-10-01 01:48:55 -07:00

20 lines
590 B
Python

"""split_path_hex: the shared multi-byte path chunker with its legacy fallback."""
import pytest
from modules.message_handler import split_path_hex
@pytest.mark.parametrize(
("path_hex", "hex_chars", "expected"),
[
("A1B2C3", 2, ["a1", "b2", "c3"]),
("A1B2C3D4", 4, ["a1b2", "c3d4"]),
("A1B2C3", 4, ["a1", "b2", "c3"]), # does not divide: one-byte fallback
("A1B2C3D4E5F6", 6, ["a1b2c3", "d4e5f6"]),
("", 4, []),
],
)
def test_split_path_hex(path_hex, hex_chars, expected):
assert split_path_hex(path_hex, hex_chars) == expected