mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-29 16:51:30 +00:00
fix(core): keep value of experimental_features cached across workflow restarts
This commit is contained in:
parent
aaa3ce6117
commit
96fd347ca8
@ -20,6 +20,7 @@ APP_COMMON_AUTHORIZATION_DATA = 4
|
||||
# Keys that are valid across sessions
|
||||
APP_COMMON_SEED_WITHOUT_PASSPHRASE = 0 | _SESSIONLESS_FLAG
|
||||
APP_COMMON_SAFETY_CHECKS_TEMPORARY = 1 | _SESSIONLESS_FLAG
|
||||
STORAGE_DEVICE_EXPERIMENTAL_FEATURES = 2 | _SESSIONLESS_FLAG
|
||||
|
||||
|
||||
class InvalidSessionError(Exception):
|
||||
@ -77,6 +78,7 @@ class SessionlessCache(DataCache):
|
||||
self.fields = (
|
||||
64, # APP_COMMON_SEED_WITHOUT_PASSPHRASE
|
||||
1, # APP_COMMON_SAFETY_CHECKS_TEMPORARY
|
||||
1, # STORAGE_DEVICE_EXPERIMENTAL_FEATURES
|
||||
)
|
||||
super().__init__()
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
from micropython import const
|
||||
from ubinascii import hexlify
|
||||
|
||||
import storage.cache
|
||||
from storage import common
|
||||
|
||||
if False:
|
||||
@ -318,9 +319,19 @@ def set_safety_check_level(level: StorageSafetyCheckLevel) -> None:
|
||||
common.set_uint8(_NAMESPACE, _SAFETY_CHECK_LEVEL, level)
|
||||
|
||||
|
||||
@storage.cache.stored(storage.cache.STORAGE_DEVICE_EXPERIMENTAL_FEATURES)
|
||||
def _get_experimental_features() -> bytes:
|
||||
if common.get_bool(_NAMESPACE, _EXPERIMENTAL_FEATURES):
|
||||
return b"\x01"
|
||||
else:
|
||||
return b""
|
||||
|
||||
|
||||
def get_experimental_features() -> bool:
|
||||
return common.get_bool(_NAMESPACE, _EXPERIMENTAL_FEATURES)
|
||||
return bool(_get_experimental_features())
|
||||
|
||||
|
||||
def set_experimental_features(enabled: bool) -> None:
|
||||
cached_bytes = b"\x01" if enabled else b""
|
||||
storage.cache.set(storage.cache.STORAGE_DEVICE_EXPERIMENTAL_FEATURES, cached_bytes)
|
||||
common.set_true_or_delete(_NAMESPACE, _EXPERIMENTAL_FEATURES, enabled)
|
||||
|
@ -247,6 +247,21 @@ class TestMsgApplysettings:
|
||||
)
|
||||
experimental_call()
|
||||
|
||||
# relock and try again
|
||||
client.lock()
|
||||
with client:
|
||||
client.use_pin_sequence([PIN4])
|
||||
client.set_expected_responses(
|
||||
[
|
||||
messages.ButtonRequest,
|
||||
messages.ButtonRequest,
|
||||
messages.ButtonRequest,
|
||||
messages.Success,
|
||||
]
|
||||
)
|
||||
experimental_call()
|
||||
|
||||
# unset experimental features
|
||||
with client:
|
||||
client.set_expected_responses([messages.Success, messages.Features])
|
||||
device.apply_settings(client, experimental_features=False)
|
||||
|
Loading…
Reference in New Issue
Block a user