From 564cd654967dfa062e682324cb24289799b99bbc Mon Sep 17 00:00:00 2001 From: Jack Kingsman Date: Sun, 8 Mar 2026 00:04:11 -0800 Subject: [PATCH] Update tests with new out_path_hash_mode field and surface error on path hash mode set failure --- app/routers/radio.py | 7 ++++++- frontend/src/test/integration.test.ts | 1 + frontend/src/test/newMessageModal.test.tsx | 1 + frontend/src/test/pathUtils.test.ts | 1 + frontend/src/test/repeaterDashboard.test.tsx | 1 + frontend/src/test/searchView.test.tsx | 1 + frontend/src/test/sidebar.test.tsx | 1 + frontend/src/test/urlHash.test.ts | 3 +++ .../src/test/useContactsAndChannels.test.ts | 1 + frontend/src/test/useUnreadCounts.test.ts | 1 + frontend/src/types.ts | 1 + tests/e2e/helpers/api.ts | 1 + tests/test_radio_router.py | 21 +++++++++++++++++++ 13 files changed, 40 insertions(+), 1 deletion(-) diff --git a/app/routers/radio.py b/app/routers/radio.py index c68f65d..56b052a 100644 --- a/app/routers/radio.py +++ b/app/routers/radio.py @@ -123,7 +123,12 @@ async def update_radio_config(update: RadioConfigUpdate) -> RadioConfigResponse: status_code=400, detail="Firmware does not support path hash mode setting" ) logger.info("Setting path hash mode to %d", update.path_hash_mode) - await mc.commands.set_path_hash_mode(update.path_hash_mode) + result = await mc.commands.set_path_hash_mode(update.path_hash_mode) + if result is not None and result.type == EventType.ERROR: + raise HTTPException( + status_code=500, + detail=f"Failed to set path hash mode: {result.payload}", + ) radio_manager.path_hash_mode = update.path_hash_mode # Sync time with system clock diff --git a/frontend/src/test/integration.test.ts b/frontend/src/test/integration.test.ts index d537595..5b4fea6 100644 --- a/frontend/src/test/integration.test.ts +++ b/frontend/src/test/integration.test.ts @@ -288,6 +288,7 @@ function makeContact(overrides: Partial = {}): Contact { last_read_at: null, first_seen: null, ...overrides, + out_path_hash_mode: overrides.out_path_hash_mode ?? 0, }; } diff --git a/frontend/src/test/newMessageModal.test.tsx b/frontend/src/test/newMessageModal.test.tsx index 1b3eb18..02ac8d3 100644 --- a/frontend/src/test/newMessageModal.test.tsx +++ b/frontend/src/test/newMessageModal.test.tsx @@ -24,6 +24,7 @@ const mockContact: Contact = { flags: 0, last_path: null, last_path_len: -1, + out_path_hash_mode: 0, last_advert: null, lat: null, lon: null, diff --git a/frontend/src/test/pathUtils.test.ts b/frontend/src/test/pathUtils.test.ts index 5ff5110..1003978 100644 --- a/frontend/src/test/pathUtils.test.ts +++ b/frontend/src/test/pathUtils.test.ts @@ -29,6 +29,7 @@ function createContact(overrides: Partial = {}): Contact { last_read_at: null, first_seen: null, ...overrides, + out_path_hash_mode: overrides.out_path_hash_mode ?? 0, }; } diff --git a/frontend/src/test/repeaterDashboard.test.tsx b/frontend/src/test/repeaterDashboard.test.tsx index c45e643..5ebbb88 100644 --- a/frontend/src/test/repeaterDashboard.test.tsx +++ b/frontend/src/test/repeaterDashboard.test.tsx @@ -80,6 +80,7 @@ const contacts: Contact[] = [ flags: 0, last_path: null, last_path_len: -1, + out_path_hash_mode: 0, last_advert: null, lat: null, lon: null, diff --git a/frontend/src/test/searchView.test.tsx b/frontend/src/test/searchView.test.tsx index d5eb73c..d270a03 100644 --- a/frontend/src/test/searchView.test.tsx +++ b/frontend/src/test/searchView.test.tsx @@ -228,6 +228,7 @@ describe('SearchView', () => { flags: 0, last_path: null, last_path_len: -1, + out_path_hash_mode: 0, last_advert: null, lat: null, lon: null, diff --git a/frontend/src/test/sidebar.test.tsx b/frontend/src/test/sidebar.test.tsx index a123688..75b19f9 100644 --- a/frontend/src/test/sidebar.test.tsx +++ b/frontend/src/test/sidebar.test.tsx @@ -23,6 +23,7 @@ function makeContact(public_key: string, name: string, type = 1): Contact { flags: 0, last_path: null, last_path_len: -1, + out_path_hash_mode: 0, last_advert: null, lat: null, lon: null, diff --git a/frontend/src/test/urlHash.test.ts b/frontend/src/test/urlHash.test.ts index 8d15043..bb291b4 100644 --- a/frontend/src/test/urlHash.test.ts +++ b/frontend/src/test/urlHash.test.ts @@ -196,6 +196,7 @@ describe('resolveContactFromHashToken', () => { flags: 0, last_path: null, last_path_len: -1, + out_path_hash_mode: 0, last_advert: null, lat: null, lon: null, @@ -212,6 +213,7 @@ describe('resolveContactFromHashToken', () => { flags: 0, last_path: null, last_path_len: -1, + out_path_hash_mode: 0, last_advert: null, lat: null, lon: null, @@ -228,6 +230,7 @@ describe('resolveContactFromHashToken', () => { flags: 0, last_path: null, last_path_len: -1, + out_path_hash_mode: 0, last_advert: null, lat: null, lon: null, diff --git a/frontend/src/test/useContactsAndChannels.test.ts b/frontend/src/test/useContactsAndChannels.test.ts index c5a2a09..37f50ee 100644 --- a/frontend/src/test/useContactsAndChannels.test.ts +++ b/frontend/src/test/useContactsAndChannels.test.ts @@ -49,6 +49,7 @@ function makeContact(suffix: string): Contact { flags: 0, last_path: null, last_path_len: -1, + out_path_hash_mode: 0, last_advert: null, lat: null, lon: null, diff --git a/frontend/src/test/useUnreadCounts.test.ts b/frontend/src/test/useUnreadCounts.test.ts index daa2c67..47bc492 100644 --- a/frontend/src/test/useUnreadCounts.test.ts +++ b/frontend/src/test/useUnreadCounts.test.ts @@ -45,6 +45,7 @@ function makeContact(pubkey: string): Contact { flags: 0, last_path: null, last_path_len: -1, + out_path_hash_mode: 0, last_advert: null, lat: null, lon: null, diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 36a5e95..f91cf20 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -66,6 +66,7 @@ export interface Contact { flags: number; last_path: string | null; last_path_len: number; + out_path_hash_mode: number; last_advert: number | null; lat: number | null; lon: number | null; diff --git a/tests/e2e/helpers/api.ts b/tests/e2e/helpers/api.ts index 2fd7963..c2fd999 100644 --- a/tests/e2e/helpers/api.ts +++ b/tests/e2e/helpers/api.ts @@ -90,6 +90,7 @@ export interface Contact { flags: number; last_path: string | null; last_path_len: number; + out_path_hash_mode: number; last_advert: number | null; lat: number | null; lon: number | null; diff --git a/tests/test_radio_router.py b/tests/test_radio_router.py index 0e4b0c0..095e3d6 100644 --- a/tests/test_radio_router.py +++ b/tests/test_radio_router.py @@ -161,6 +161,27 @@ class TestUpdateRadioConfig: assert exc.value.status_code == 400 + @pytest.mark.asyncio + async def test_propagates_radio_error_when_setting_path_hash_mode(self): + mc = _mock_meshcore_with_info() + mc.commands.set_path_hash_mode = AsyncMock( + return_value=_radio_result(EventType.ERROR, {"error": "nope"}) + ) + + with ( + patch("app.routers.radio.require_connected", return_value=mc), + patch.object(radio_manager, "_meshcore", mc), + patch.object(radio_manager, "path_hash_mode_supported", True), + patch.object(radio_manager, "path_hash_mode", 0), + ): + with pytest.raises(HTTPException) as exc: + await update_radio_config(RadioConfigUpdate(path_hash_mode=1)) + + assert exc.value.status_code == 500 + assert "Failed to set path hash mode" in str(exc.value.detail) + assert radio_manager.path_hash_mode == 0 + mc.commands.send_appstart.assert_not_awaited() + class TestPrivateKeyImport: @pytest.mark.asyncio