2022-10-25 10:46:37 +00:00
|
|
|
from typing import Iterator
|
|
|
|
|
2020-09-17 12:27:04 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from trezorlib import debuglink, device
|
|
|
|
from trezorlib.messages import SafetyCheckLevel
|
|
|
|
|
|
|
|
from ..common import MNEMONIC12
|
2022-01-28 20:04:50 +00:00
|
|
|
from ..emulators import Emulator, EmulatorWrapper
|
2020-09-17 12:27:04 +00:00
|
|
|
from ..upgrade_tests import core_only
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2022-10-25 10:46:37 +00:00
|
|
|
def emulator() -> Iterator[Emulator]:
|
2020-09-17 12:27:04 +00:00
|
|
|
with EmulatorWrapper("core") as emu:
|
|
|
|
yield emu
|
|
|
|
|
|
|
|
|
|
|
|
@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(
|
|
|
|
emulator: Emulator, set_level: SafetyCheckLevel, after_level: SafetyCheckLevel
|
|
|
|
):
|
2020-09-17 12:27:04 +00:00
|
|
|
device.wipe(emulator.client)
|
|
|
|
debuglink.load_device(
|
|
|
|
emulator.client,
|
|
|
|
mnemonic=MNEMONIC12,
|
|
|
|
pin="",
|
|
|
|
passphrase_protection=False,
|
|
|
|
label="SAFETYLEVEL",
|
|
|
|
)
|
|
|
|
|
|
|
|
device.apply_settings(emulator.client, safety_checks=set_level)
|
|
|
|
assert emulator.client.features.safety_checks == set_level
|
|
|
|
|
|
|
|
emulator.restart()
|
|
|
|
|
|
|
|
assert emulator.client.features.safety_checks == after_level
|