Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions test/test_meshcore_path_hashes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Unit tests for MeshCore path hash splitting (_path_hashes)."""

from src.meshcore.serializers import _path_hashes


def test_path_hashes_two_byte_default():
payload = {"path": "f3bcf1a2b3c4", "path_hash_size": 2}
assert _path_hashes(payload) == ["f3bc", "f1a2", "b3c4"]


def test_path_hashes_one_byte():
payload = {"path": "aabbcc", "path_hash_size": 1}
assert _path_hashes(payload) == ["aa", "bb", "cc"]


def test_path_hashes_three_byte():
payload = {"path": "aabbccddeeff", "path_hash_size": 3}
assert _path_hashes(payload) == ["aabbcc", "ddeeff"]


def test_path_hashes_missing_path_returns_none():
assert _path_hashes({"path_len": 2}) is None
assert _path_hashes({}) is None


def test_path_hashes_list_passthrough():
payload = {"path": ["aa", "bb"]}
assert _path_hashes(payload) == ["aa", "bb"]