mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-07-06 09:52:06 +02:00
Fix visualizer coercion for multibyte hops
This commit is contained in:
@@ -326,6 +326,28 @@ class TestContactDetail:
|
||||
assert repeater["name"] == "Relay1"
|
||||
assert repeater["heard_count"] == 2
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_detail_nearest_repeaters_use_full_multibyte_next_hop(self, test_db, client):
|
||||
"""Nearest repeater resolution should distinguish multi-byte hops with the same first byte."""
|
||||
await _insert_contact(KEY_A, "Alice", type=1)
|
||||
repeater_1 = "bb11" + "aa" * 30
|
||||
repeater_2 = "bb22" + "cc" * 30
|
||||
await _insert_contact(repeater_1, "Relay11", type=2)
|
||||
await _insert_contact(repeater_2, "Relay22", type=2)
|
||||
|
||||
await ContactAdvertPathRepository.record_observation(KEY_A, "bb221122", 1000, hop_count=2)
|
||||
await ContactAdvertPathRepository.record_observation(KEY_A, "bb223344", 1010, hop_count=2)
|
||||
|
||||
response = await client.get(f"/api/contacts/{KEY_A}/detail")
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert len(data["nearest_repeaters"]) == 1
|
||||
repeater = data["nearest_repeaters"][0]
|
||||
assert repeater["public_key"] == repeater_2
|
||||
assert repeater["name"] == "Relay22"
|
||||
assert repeater["heard_count"] == 2
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_detail_advert_frequency_computed(self, test_db, client):
|
||||
"""Advert frequency is computed from path observations over time span."""
|
||||
|
||||
@@ -273,6 +273,19 @@ class TestContactAdvertPathRepository:
|
||||
assert paths[0].last_seen == 1010
|
||||
assert paths[0].heard_count == 2
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_record_observation_preserves_full_multibyte_next_hop(self, test_db):
|
||||
repeater_key = "ab" * 32
|
||||
await ContactRepository.upsert({"public_key": repeater_key, "name": "Rmulti", "type": 2})
|
||||
|
||||
await ContactAdvertPathRepository.record_observation(
|
||||
repeater_key, "aa11bb22", 1000, hop_count=2
|
||||
)
|
||||
|
||||
paths = await ContactAdvertPathRepository.get_recent_for_contact(repeater_key, limit=10)
|
||||
assert len(paths) == 1
|
||||
assert paths[0].next_hop == "aa11"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_prunes_to_most_recent_n_unique_paths(self, test_db):
|
||||
repeater_key = "bb" * 32
|
||||
|
||||
Reference in New Issue
Block a user