mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-11-04 03:52:34 +00:00
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.
20 lines
590 B
Python
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
|