From a2b53e3c467fa96694a3253e19f48ec38600cceb Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Thu, 22 Feb 2024 13:46:07 +0100 Subject: [PATCH] feat(core): Add language_version_matches flag to Features [no changelog] --- core/src/apps/base.py | 15 +++++++++++++++ tests/device_tests/test_language.py | 3 +++ 2 files changed, 18 insertions(+) diff --git a/core/src/apps/base.py b/core/src/apps/base.py index 931427c99..27d0c16b7 100644 --- a/core/src/apps/base.py +++ b/core/src/apps/base.py @@ -43,6 +43,20 @@ def busy_expiry_ms() -> int: return expiry_ms if expiry_ms > 0 else 0 +def _language_version_matches() -> bool | None: + """ + Whether translation blob version matches firmware version. + Returns None if there is no blob. + """ + from trezor import translations + + header = translations.TranslationsHeader.load_from_flash() + if header is None: + return True + + return header.version == utils.VERSION + + def get_features() -> Features: import storage.recovery as storage_recovery from trezor import translations @@ -58,6 +72,7 @@ def get_features() -> Features: vendor="trezor.io", fw_vendor=utils.firmware_vendor(), language=translations.get_language(), + language_version_matches=_language_version_matches(), major_version=v_major, minor_version=v_minor, patch_version=v_patch, diff --git a/tests/device_tests/test_language.py b/tests/device_tests/test_language.py index 0532ad9fc..c0c9a12cf 100644 --- a/tests/device_tests/test_language.py +++ b/tests/device_tests/test_language.py @@ -177,15 +177,18 @@ def test_error_invalid_signature(client: Client): @pytest.mark.parametrize("lang", LANGUAGES) def test_full_language_change(client: Client, lang: str): assert client.features.language == "en-US" + assert client.features.language_version_matches is True # Setting selected language set_language(client, lang) assert client.features.language[:2] == lang + assert client.features.language_version_matches is True _check_ping_screen_texts(client, get_ping_title(lang), get_ping_button(lang)) # Setting the default language via empty data set_language(client, "en") assert client.features.language == "en-US" + assert client.features.language_version_matches is True _check_ping_screen_texts(client, get_ping_title("en"), get_ping_button("en"))