1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-11 08:58:08 +00:00
trezor-firmware/tests/persistence_tests/test_safety_checks.py
2024-11-28 13:59:17 +01:00

40 lines
1.2 KiB
Python

import pytest
from trezorlib import debuglink, device
from trezorlib.messages import SafetyCheckLevel
from ..common import MNEMONIC12
from ..emulators import Emulator
from ..upgrade_tests import core_only
@core_only
@pytest.mark.parametrize(
"set_level,after_level",
[
(SafetyCheckLevel.Strict, SafetyCheckLevel.Strict),
(SafetyCheckLevel.PromptTemporarily, SafetyCheckLevel.Strict),
(SafetyCheckLevel.PromptAlways, SafetyCheckLevel.PromptAlways),
],
)
def test_safety_checks_level_after_reboot(
core_emulator: Emulator, set_level: SafetyCheckLevel, after_level: SafetyCheckLevel
):
device.wipe(core_emulator.client.get_management_session())
core_emulator.client = core_emulator.client.get_new_client()
debuglink.load_device(
core_emulator.client.get_management_session(),
mnemonic=MNEMONIC12,
pin="",
passphrase_protection=False,
label="SAFETYLEVEL",
)
device.apply_settings(core_emulator.client.get_session(), safety_checks=set_level)
core_emulator.client.refresh_features()
assert core_emulator.client.features.safety_checks == set_level
core_emulator.restart()
assert core_emulator.client.features.safety_checks == after_level