Skip to content

Commit

Permalink
Ensure repairs work when getTokenData is present but NV3 is not (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly authored Sep 7, 2023
1 parent 50636b7 commit b50af94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bellows/zigbee/repairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def fix_invalid_tclk_partner_ieee(ezsp: EZSP) -> bool:
t.NV3KeyId.NVM3KEY_STACK_TRUST_CENTER, 0
)
assert status == t.EmberStatus.SUCCESS
except (InvalidCommandError, AttributeError):
except (InvalidCommandError, AttributeError, AssertionError):
LOGGER.warning("NV3 interface not available in this firmware, please upgrade!")
return False

Expand Down
9 changes: 7 additions & 2 deletions tests/test_zigbee_repairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ async def test_fix_invalid_tclk(ezsp_tclk_f: EZSP, caplog) -> None:


@pytest.mark.parametrize("version", EZSP._BY_VERSION)
@pytest.mark.parametrize("has_library", [(True, False)])
async def test_fix_invalid_tclk_all_versions(
version: int, ezsp_tclk_f: EZSP, caplog
version: int, has_library: bool, ezsp_tclk_f: EZSP, caplog
) -> None:
"""Test that the TCLK is fixed (or not) on all versions."""

Expand All @@ -138,6 +139,10 @@ async def test_fix_invalid_tclk_all_versions(
]
)

if not has_library:
ezsp.setTokenData = AsyncMock(return_value=[t.EmberStatus.LIBRARY_NOT_LOADED])
ezsp.getTokenData = AsyncMock(return_value=[t.EmberStatus.LIBRARY_NOT_LOADED])

ezsp.getEui64 = ezsp_tclk_f.getEui64
ezsp.getCurrentSecurityState = ezsp_tclk_f.getCurrentSecurityState

Expand All @@ -153,7 +158,7 @@ async def test_fix_invalid_tclk_all_versions(

assert "Fixing invalid TCLK" in caplog.text

if fw_has_token_interface:
if fw_has_token_interface and has_library:
assert "NV3 interface not available in this firmware" not in caplog.text

assert ezsp.setTokenData.mock_calls == [
Expand Down

0 comments on commit b50af94

Please sign in to comment.