Update factory reset to use integer for config reset

This commit is contained in:
Ben Meadors
2026-04-17 05:03:56 -05:00
parent cec79a7c1f
commit c5fc51ea37
2 changed files with 31 additions and 1 deletions

View File

@@ -731,7 +731,7 @@ class Node:
p.factory_reset_device = True
logger.info(f"Telling node to factory reset (full device reset)")
else:
p.factory_reset_config = True
p.factory_reset_config = 1
logger.info(f"Telling node to factory reset (config reset)")
# If sending to a remote node, wait for ACK/NAK

View File

@@ -262,6 +262,36 @@ def test_shutdown(caplog):
assert re.search(r"Telling node to shutdown", caplog.text, re.MULTILINE)
@pytest.mark.unit
def test_factoryReset_config_uses_int_field():
"""Test factoryReset(config) sets int32 protobuf field with an int value."""
iface = MagicMock(autospec=MeshInterface)
anode = Node(iface, 1234567890, noProto=True)
amesg = admin_pb2.AdminMessage()
with patch("meshtastic.admin_pb2.AdminMessage", return_value=amesg):
with patch.object(anode, "_sendAdmin") as mock_send_admin:
anode.factoryReset(full=False)
assert amesg.factory_reset_config == 1
mock_send_admin.assert_called_once_with(amesg, onResponse=anode.onAckNak)
@pytest.mark.unit
def test_factoryReset_full_sets_device_field():
"""Test factoryReset(full=True) sets the full-device reset protobuf field."""
iface = MagicMock(autospec=MeshInterface)
anode = Node(iface, 1234567890, noProto=True)
amesg = admin_pb2.AdminMessage()
with patch("meshtastic.admin_pb2.AdminMessage", return_value=amesg):
with patch.object(anode, "_sendAdmin") as mock_send_admin:
anode.factoryReset(full=True)
assert amesg.factory_reset_device is True
mock_send_admin.assert_called_once_with(amesg, onResponse=anode.onAckNak)
@pytest.mark.unit
def test_setURL_empty_url(capsys):
"""Test reboot"""