diff --git a/app/apps/impl/raspiblitz.py b/app/apps/impl/raspiblitz.py index f72fb07..f0e9136 100644 --- a/app/apps/impl/raspiblitz.py +++ b/app/apps/impl/raspiblitz.py @@ -565,14 +565,17 @@ async def _do_electrs_status_advanced() -> Result[AppStatus, Report]: if data.get("installed", "0") == "0": s.installed = False return Ok(s) + s.installed = True if data.get("configured", "0") == "0": s.configured = False return Ok(s) + s.configured = True if data.get("serviceRunning", "0") == "0": s.status = AppOnlineStatus.OFFLINE return Ok(s) + s.status = AppOnlineStatus.ONLINE if "initialSynced" not in data: return Err( diff --git a/tests/test_electrs_advanced_status.py b/tests/test_electrs_advanced_status.py new file mode 100644 index 0000000..f1fd3ec --- /dev/null +++ b/tests/test_electrs_advanced_status.py @@ -0,0 +1,59 @@ +""" +Regression test for raspiblitz-web#286. + +_do_electrs_status_advanced populated the detail fields on the happy path but +never set installed/configured/status, so a fully installed, configured and +running electrs was still reported as installed=false, configured=false, +status=offline (while paradoxically returning ports and sync details). +""" + +from app.api.models import ProcessResult +from app.apps.impl import raspiblitz as rb +from app.apps.models import AppOnlineStatus +from app.external.result_type.src.result.result import Ok + +_STATUS_OUT = "\n".join( + [ + "##### STATUS ELECTRS SERVICE", + "version='v0.10.6'", + "configured=1", + "installed=1", + "serviceRunning=1", + "localIP='192.168.1.5'", + "publicIP='1.2.3.4'", + "portTCP='50001'", + "portSSL='50002'", + "TORaddress='abc.onion'", + ] +) + +_SYNC_OUT = "\n".join( + [ + "serviceRunning=1", + "electrumResponding=1", + "blockheight='800000'", + "blockheightPercent='100'", + "initialSynced=1", + "infoSync=''", + ] +) + + +async def test_electrs_advanced_reports_installed_when_running(monkeypatch): + async def fake_exec(command, **kwargs): + out = _SYNC_OUT if "status-sync" in command else _STATUS_OUT + return Ok(ProcessResult(0, out, "")) + + monkeypatch.setattr(rb, "exec_bash_command", fake_exec) + + result = await rb._do_electrs_status_advanced() + + assert isinstance(result, Ok) + s = result.ok_value + # sanity: we reached the happy path (details populated) + assert s.http_port == "50001" + assert s.details["electrum_responding"] == "1" + # the actual bug: these were left at their False/offline defaults + assert s.installed is True + assert s.configured is True + assert s.status == AppOnlineStatus.ONLINE