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
|
|
|
):
|
2023-03-30 10:31:09 +00:00
|
|
|
device.wipe(core_emulator.client)
|
2020-09-17 12:27:04 +00:00
|
|
|
debuglink.load_device(
|
2023-03-30 10:31:09 +00:00
|
|
|
core_emulator.client,
|
2020-09-17 12:27:04 +00:00
|
|
|
mnemonic=MNEMONIC12,
|
|
|
|
pin="",
|
|
|
|
passphrase_protection=False,
|
|
|
|
label="SAFETYLEVEL",
|
|
|
|
)
|
|
|
|
|
2023-03-30 10:31:09 +00:00
|
|
|
device.apply_settings(core_emulator.client, safety_checks=set_level)
|
|
|
|
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
|