2020-09-17 12:27:04 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from trezorlib import debuglink, device
|
|
|
|
from trezorlib.messages import SafetyCheckLevel
|
|
|
|
|
|
|
|
from ..common import MNEMONIC12
|
2023-03-30 10:31:09 +00:00
|
|
|
from ..emulators import Emulator
|
2020-09-17 12:27:04 +00:00
|
|
|
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),
|
|
|
|
],
|
|
|
|
)
|
2022-01-28 20:04:50 +00:00
|
|
|
def test_safety_checks_level_after_reboot(
|
2023-03-30 10:31:09 +00:00
|
|
|
core_emulator: Emulator, set_level: SafetyCheckLevel, after_level: SafetyCheckLevel
|
2022-01-28 20:04:50 +00:00
|
|
|
):
|
2024-11-26 10:47:13 +00:00
|
|
|
device.wipe(core_emulator.client.get_management_session())
|
|
|
|
core_emulator.client = core_emulator.client.get_new_client()
|
2020-09-17 12:27:04 +00:00
|
|
|
debuglink.load_device(
|
2024-11-26 10:47:13 +00:00
|
|
|
core_emulator.client.get_management_session(),
|
2020-09-17 12:27:04 +00:00
|
|
|
mnemonic=MNEMONIC12,
|
|
|
|
pin="",
|
|
|
|
passphrase_protection=False,
|
|
|
|
label="SAFETYLEVEL",
|
|
|
|
)
|
|
|
|
|
2024-11-26 10:47:13 +00:00
|
|
|
device.apply_settings(core_emulator.client.get_session(), safety_checks=set_level)
|
|
|
|
core_emulator.client.refresh_features()
|
2023-03-30 10:31:09 +00:00
|
|
|
assert core_emulator.client.features.safety_checks == set_level
|
2020-09-17 12:27:04 +00:00
|
|
|
|
2023-03-30 10:31:09 +00:00
|
|
|
core_emulator.restart()
|
2020-09-17 12:27:04 +00:00
|
|
|
|
2023-03-30 10:31:09 +00:00
|
|
|
assert core_emulator.client.features.safety_checks == after_level
|