diff --git a/tests/click_tests/test_autolock.py b/tests/click_tests/test_autolock.py index 4cc7740895..599c0df6ad 100644 --- a/tests/click_tests/test_autolock.py +++ b/tests/click_tests/test_autolock.py @@ -73,7 +73,7 @@ def set_autolock_delay(device_handler: "BackgroundDeviceHandler", delay_ms: int) if debug.layout_type is LayoutType.Quicksilver: layout = tap_to_confirm(debug) assert layout.main_component() == "Homescreen" - assert device_handler.result() == "Settings applied" + device_handler.result() @pytest.mark.setup_client(pin=PIN4) diff --git a/tests/click_tests/test_backup_slip39_custom.py b/tests/click_tests/test_backup_slip39_custom.py index 8318ab5f4b..bc05170dc0 100644 --- a/tests/click_tests/test_backup_slip39_custom.py +++ b/tests/click_tests/test_backup_slip39_custom.py @@ -22,7 +22,7 @@ from trezorlib import device, messages from trezorlib.debuglink import LayoutType from .. import translations as TR -from ..common import EXTERNAL_ENTROPY, WITH_MOCK_URANDOM, generate_entropy +from ..common import EXTERNAL_ENTROPY, MOCK_GET_ENTROPY, generate_entropy from . import reset if TYPE_CHECKING: @@ -41,7 +41,6 @@ pytestmark = pytest.mark.models("core") ], ) @pytest.mark.setup_client(uninitialized=True) -@WITH_MOCK_URANDOM def test_backup_slip39_custom( device_handler: "BackgroundDeviceHandler", group_threshold: int, @@ -54,10 +53,13 @@ def test_backup_slip39_custom( assert features.initialized is False device_handler.run( - device.reset, + device.setup, strength=128, backup_type=messages.BackupType.Slip39_Basic, pin_protection=False, + passphrase_protection=False, + entropy_check_count=0, + _get_entropy=MOCK_GET_ENTROPY, ) # confirm new wallet @@ -66,7 +68,8 @@ def test_backup_slip39_custom( # cancel back up reset.cancel_backup(debug, confirm=True) - assert device_handler.result() == "Initialized" + # retrieve the result to check that it's not a TrezorFailure exception + device_handler.result() device_handler.run( device.backup, @@ -116,7 +119,9 @@ def test_backup_slip39_custom( # validate that all combinations will result in the correct master secret reset.validate_mnemonics(all_words[:share_threshold], secret) - assert device_handler.result() == "Seed successfully backed up" + # retrieve the result to check that it's not a TrezorFailure exception + device_handler.result() + features = device_handler.features() assert features.initialized is True assert features.backup_availability == messages.BackupAvailability.NotAvailable diff --git a/tests/click_tests/test_recovery.py b/tests/click_tests/test_recovery.py index 8770649296..7161e774dd 100644 --- a/tests/click_tests/test_recovery.py +++ b/tests/click_tests/test_recovery.py @@ -44,7 +44,8 @@ def prepare_recovery_and_evaluate( yield debug - assert isinstance(device_handler.result(), messages.Success) + device_handler.result() + features = device_handler.features() assert features.initialized is True assert features.recovery_status == messages.RecoveryStatus.Nothing diff --git a/tests/click_tests/test_repeated_backup.py b/tests/click_tests/test_repeated_backup.py index d61d97962d..e0d62b53d2 100644 --- a/tests/click_tests/test_repeated_backup.py +++ b/tests/click_tests/test_repeated_backup.py @@ -21,7 +21,7 @@ import pytest from trezorlib import device, messages from .. import buttons -from ..common import WITH_MOCK_URANDOM +from ..common import MOCK_GET_ENTROPY from . import recovery, reset from .common import go_next @@ -33,7 +33,6 @@ pytestmark = pytest.mark.models("core") @pytest.mark.setup_client(uninitialized=True) -@WITH_MOCK_URANDOM def test_repeated_backup( device_handler: "BackgroundDeviceHandler", ): @@ -43,10 +42,13 @@ def test_repeated_backup( assert features.initialized is False device_handler.run( - device.reset, + device.setup, strength=128, backup_type=messages.BackupType.Slip39_Basic, pin_protection=False, + passphrase_protection=False, + entropy_check_count=0, + _get_entropy=MOCK_GET_ENTROPY, ) # confirm new wallet @@ -84,8 +86,9 @@ def test_repeated_backup( # Your backup is done go_next(debug) + # retrieve the result to check that it does not raise a failure + device_handler.result() # great ... device is initialized, backup done, and we are not in recovery mode! - assert device_handler.result() == "Initialized" features = device_handler.features() assert features.backup_type is messages.BackupType.Slip39_Basic_Extendable assert features.initialized is True @@ -109,8 +112,8 @@ def test_repeated_backup( "recovery__unlock_repeated_backup", ) - # backup is enabled - assert device_handler.result().message == "Backup unlocked" + # check non-exception result + device_handler.result() # we are now in recovery mode features = device_handler.features() @@ -178,7 +181,8 @@ def test_repeated_backup( "recovery__unlock_repeated_backup", ) - assert device_handler.result().message == "Backup unlocked" + # check non-exception result + device_handler.result() # we are now in recovery mode again! features = device_handler.features() diff --git a/tests/click_tests/test_reset_bip39.py b/tests/click_tests/test_reset_bip39.py index 907246fb51..d405f51441 100644 --- a/tests/click_tests/test_reset_bip39.py +++ b/tests/click_tests/test_reset_bip39.py @@ -21,7 +21,7 @@ import pytest from trezorlib import device, messages from .. import translations as TR -from ..common import WITH_MOCK_URANDOM +from ..common import MOCK_GET_ENTROPY from . import reset from .common import go_next @@ -33,7 +33,6 @@ pytestmark = pytest.mark.models("core") @pytest.mark.setup_client(uninitialized=True) -@WITH_MOCK_URANDOM def test_reset_bip39(device_handler: "BackgroundDeviceHandler"): features = device_handler.features() debug = device_handler.debuglink() @@ -41,10 +40,13 @@ def test_reset_bip39(device_handler: "BackgroundDeviceHandler"): assert features.initialized is False device_handler.run( - device.reset, + device.setup, strength=128, backup_type=messages.BackupType.Bip39, pin_protection=False, + passphrase_protection=False, + entropy_check_count=0, + _get_entropy=MOCK_GET_ENTROPY, ) # confirm new wallet @@ -82,7 +84,9 @@ def test_reset_bip39(device_handler: "BackgroundDeviceHandler"): # TODO: some validation of the generated secret? - assert device_handler.result() == "Initialized" + # retrieve the result to check that it's not a TrezorFailure exception + device_handler.result() + features = device_handler.features() assert features.initialized is True assert features.backup_availability == messages.BackupAvailability.NotAvailable diff --git a/tests/click_tests/test_reset_slip39_advanced.py b/tests/click_tests/test_reset_slip39_advanced.py index d975212425..0b43095ad1 100644 --- a/tests/click_tests/test_reset_slip39_advanced.py +++ b/tests/click_tests/test_reset_slip39_advanced.py @@ -21,7 +21,7 @@ import pytest from trezorlib import device, messages from .. import buttons -from ..common import EXTERNAL_ENTROPY, WITH_MOCK_URANDOM, generate_entropy +from ..common import EXTERNAL_ENTROPY, MOCK_GET_ENTROPY, generate_entropy from . import reset if TYPE_CHECKING: @@ -39,7 +39,6 @@ pytestmark = pytest.mark.models("core") pytest.param(16, 16, 16, 16, id="16of16", marks=pytest.mark.slow), ], ) -@WITH_MOCK_URANDOM def test_reset_slip39_advanced( device_handler: "BackgroundDeviceHandler", group_count: int, @@ -53,9 +52,12 @@ def test_reset_slip39_advanced( assert features.initialized is False device_handler.run( - device.reset, + device.setup, backup_type=messages.BackupType.Slip39_Advanced, pin_protection=False, + passphrase_protection=False, + entropy_check_count=0, + _get_entropy=MOCK_GET_ENTROPY, ) # confirm new wallet @@ -162,7 +164,8 @@ def test_reset_slip39_advanced( # validate that all combinations will result in the correct master secret reset.validate_mnemonics(all_words, secret) - assert device_handler.result() == "Initialized" + # retrieve the result to check that it's not a TrezorFailure exception + device_handler.result() features = device_handler.features() assert features.initialized is True diff --git a/tests/click_tests/test_reset_slip39_basic.py b/tests/click_tests/test_reset_slip39_basic.py index f8c6592f6d..d18bf7a4fb 100644 --- a/tests/click_tests/test_reset_slip39_basic.py +++ b/tests/click_tests/test_reset_slip39_basic.py @@ -21,7 +21,7 @@ import pytest from trezorlib import device, messages from .. import buttons -from ..common import EXTERNAL_ENTROPY, WITH_MOCK_URANDOM, generate_entropy +from ..common import EXTERNAL_ENTROPY, MOCK_GET_ENTROPY, generate_entropy from . import reset if TYPE_CHECKING: @@ -39,7 +39,6 @@ pytestmark = pytest.mark.models("core") ], ) @pytest.mark.setup_client(uninitialized=True) -@WITH_MOCK_URANDOM def test_reset_slip39_basic( device_handler: "BackgroundDeviceHandler", num_of_shares: int, threshold: int ): @@ -49,10 +48,13 @@ def test_reset_slip39_basic( assert features.initialized is False device_handler.run( - device.reset, + device.setup, strength=128, backup_type=messages.BackupType.Slip39_Basic, pin_protection=False, + passphrase_protection=False, + entropy_check_count=0, + _get_entropy=MOCK_GET_ENTROPY, ) # confirm new wallet @@ -137,7 +139,9 @@ def test_reset_slip39_basic( # validate that all combinations will result in the correct master secret reset.validate_mnemonics(all_words, secret) - assert device_handler.result() == "Initialized" + # retrieve the result to check that it's not a TrezorFailure exception + device_handler.result() + features = device_handler.features() assert features.initialized is True assert features.backup_availability == messages.BackupAvailability.NotAvailable diff --git a/tests/common.py b/tests/common.py index 7d5f6fb069..51b404cb48 100644 --- a/tests/common.py +++ b/tests/common.py @@ -83,8 +83,7 @@ COMMON_FIXTURES_DIR = ( ) # So that all the random things are consistent -MOCK_OS_URANDOM = mock.Mock(return_value=EXTERNAL_ENTROPY) -WITH_MOCK_URANDOM = mock.patch("os.urandom", MOCK_OS_URANDOM) +MOCK_GET_ENTROPY = mock.Mock(return_value=EXTERNAL_ENTROPY) def parametrize_using_common_fixtures(*paths: str) -> "MarkDecorator": diff --git a/tests/device_handler.py b/tests/device_handler.py index 45ec1df9f7..74eb77a5a5 100644 --- a/tests/device_handler.py +++ b/tests/device_handler.py @@ -1,18 +1,22 @@ from __future__ import annotations +import typing as t from concurrent.futures import ThreadPoolExecutor -from typing import TYPE_CHECKING, Any, Callable + +import typing_extensions as tx from trezorlib.client import PASSPHRASE_ON_DEVICE from trezorlib.messages import DebugWaitType from trezorlib.transport import udp -if TYPE_CHECKING: +if t.TYPE_CHECKING: from trezorlib._internal.emulator import Emulator from trezorlib.debuglink import DebugLink from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.messages import Features + P = tx.ParamSpec("P") + udp.SOCKET_TIMEOUT = 0.1 @@ -48,7 +52,12 @@ class BackgroundDeviceHandler: self.client.watch_layout(True) self.client.debug.input_wait_type = DebugWaitType.CURRENT_LAYOUT - def run(self, function: Callable[..., Any], *args: Any, **kwargs: Any) -> None: + def run( + self, + function: t.Callable[tx.Concatenate["Client", P], t.Any], + *args: P.args, + **kwargs: P.kwargs, + ) -> None: """Runs some function that interacts with a device. Makes sure the UI is updated before returning. @@ -79,7 +88,7 @@ class BackgroundDeviceHandler: emulator.restart() self._configure_client(emulator.client) # type: ignore [client cannot be None] - def result(self, timeout: float | None = None) -> Any: + def result(self, timeout: float | None = None) -> t.Any: if self.task is None: raise RuntimeError("No task running") try: diff --git a/tests/device_tests/bitcoin/test_authorize_coinjoin.py b/tests/device_tests/bitcoin/test_authorize_coinjoin.py index b149ff53d1..f1cc7af0bd 100644 --- a/tests/device_tests/bitcoin/test_authorize_coinjoin.py +++ b/tests/device_tests/bitcoin/test_authorize_coinjoin.py @@ -457,7 +457,7 @@ def test_sign_tx_spend(client: Client): client.set_expected_responses( [ messages.ButtonRequest(code=B.Other), - messages.UnlockedPathRequest(), + messages.UnlockedPathRequest, request_input(0), request_output(0), request_output(1), @@ -531,7 +531,7 @@ def test_sign_tx_migration(client: Client): client.set_expected_responses( [ messages.ButtonRequest(code=B.Other), - messages.UnlockedPathRequest(), + messages.UnlockedPathRequest, request_input(0), request_input(1), request_output(0), diff --git a/tests/device_tests/reset_recovery/test_recovery_slip39_advanced.py b/tests/device_tests/reset_recovery/test_recovery_slip39_advanced.py index fa18111735..ad6f51ed43 100644 --- a/tests/device_tests/reset_recovery/test_recovery_slip39_advanced.py +++ b/tests/device_tests/reset_recovery/test_recovery_slip39_advanced.py @@ -51,15 +51,13 @@ def _test_secret( with client: IF = InputFlowSlip39AdvancedRecovery(client, shares, click_info=click_info) client.set_input_flow(IF.get()) - ret = device.recover( + device.recover( client, pin_protection=False, passphrase_protection=False, label="label", ) - # Workflow succesfully ended - assert ret == messages.Success(message="Device recovered") assert client.features.initialized is True assert client.features.pin_protection is False assert client.features.passphrase_protection is False diff --git a/tests/device_tests/reset_recovery/test_recovery_slip39_advanced_dryrun.py b/tests/device_tests/reset_recovery/test_recovery_slip39_advanced_dryrun.py index 73e18a8686..5230983497 100644 --- a/tests/device_tests/reset_recovery/test_recovery_slip39_advanced_dryrun.py +++ b/tests/device_tests/reset_recovery/test_recovery_slip39_advanced_dryrun.py @@ -45,7 +45,7 @@ def test_2of3_dryrun(client: Client): client, EXTRA_GROUP_SHARE + MNEMONIC_SLIP39_ADVANCED_20 ) client.set_input_flow(IF.get()) - ret = device.recover( + device.recover( client, passphrase_protection=False, pin_protection=False, @@ -53,11 +53,6 @@ def test_2of3_dryrun(client: Client): type=messages.RecoveryType.DryRun, ) - # Dry run was successful - assert ret == messages.Success( - message="The seed is valid and matches the one in the device" - ) - @pytest.mark.setup_client(mnemonic=MNEMONIC_SLIP39_ADVANCED_20) def test_2of3_invalid_seed_dryrun(client: Client): diff --git a/tests/device_tests/reset_recovery/test_recovery_slip39_basic.py b/tests/device_tests/reset_recovery/test_recovery_slip39_basic.py index 3f7ed75e73..9c84af7118 100644 --- a/tests/device_tests/reset_recovery/test_recovery_slip39_basic.py +++ b/tests/device_tests/reset_recovery/test_recovery_slip39_basic.py @@ -75,10 +75,9 @@ def test_secret( with client: IF = InputFlowSlip39BasicRecovery(client, shares) client.set_input_flow(IF.get()) - ret = device.recover(client, pin_protection=False, label="label") + device.recover(client, pin_protection=False, label="label") # Workflow successfully ended - assert ret == messages.Success(message="Device recovered") assert client.features.pin_protection is False assert client.features.passphrase_protection is False assert client.features.backup_type is backup_type @@ -94,7 +93,7 @@ def test_recover_with_pin_passphrase(client: Client): client, MNEMONIC_SLIP39_BASIC_20_3of6, pin="654" ) client.set_input_flow(IF.get()) - ret = device.recover( + device.recover( client, pin_protection=True, passphrase_protection=True, @@ -102,7 +101,6 @@ def test_recover_with_pin_passphrase(client: Client): ) # Workflow successfully ended - assert ret == messages.Success(message="Device recovered") assert client.features.pin_protection is True assert client.features.passphrase_protection is True assert client.features.backup_type is messages.BackupType.Slip39_Basic @@ -194,7 +192,7 @@ def test_1of1(client: Client): with client: IF = InputFlowSlip39BasicRecovery(client, MNEMONIC_SLIP39_BASIC_20_1of1) client.set_input_flow(IF.get()) - ret = device.recover( + device.recover( client, pin_protection=False, passphrase_protection=False, @@ -202,7 +200,6 @@ def test_1of1(client: Client): ) # Workflow successfully ended - assert ret == messages.Success(message="Device recovered") assert client.features.initialized is True assert client.features.pin_protection is False assert client.features.passphrase_protection is False diff --git a/tests/device_tests/reset_recovery/test_recovery_slip39_basic_dryrun.py b/tests/device_tests/reset_recovery/test_recovery_slip39_basic_dryrun.py index 4c9ddf8036..8d5d57f9a1 100644 --- a/tests/device_tests/reset_recovery/test_recovery_slip39_basic_dryrun.py +++ b/tests/device_tests/reset_recovery/test_recovery_slip39_basic_dryrun.py @@ -41,7 +41,7 @@ def test_2of3_dryrun(client: Client): with client: IF = InputFlowSlip39BasicRecoveryDryRun(client, SHARES_20_2of3[1:3]) client.set_input_flow(IF.get()) - ret = device.recover( + device.recover( client, passphrase_protection=False, pin_protection=False, @@ -49,11 +49,6 @@ def test_2of3_dryrun(client: Client): type=messages.RecoveryType.DryRun, ) - # Dry run was successful - assert ret == messages.Success( - message="The seed is valid and matches the one in the device" - ) - @pytest.mark.setup_client(mnemonic=SHARES_20_2of3[0:2]) def test_2of3_invalid_seed_dryrun(client: Client): diff --git a/tests/device_tests/reset_recovery/test_reset_backup.py b/tests/device_tests/reset_recovery/test_reset_backup.py index 148087d4f4..db7e3c8845 100644 --- a/tests/device_tests/reset_recovery/test_reset_backup.py +++ b/tests/device_tests/reset_recovery/test_reset_backup.py @@ -22,7 +22,7 @@ from trezorlib import device from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.messages import BackupAvailability, BackupType -from ...common import WITH_MOCK_URANDOM +from ...common import MOCK_GET_ENTROPY from ...input_flows import ( InputFlowBip39Backup, InputFlowResetSkipBackup, @@ -75,13 +75,15 @@ VECTORS = [ @pytest.mark.parametrize("backup_type, backup_flow", VECTORS) @pytest.mark.setup_client(uninitialized=True) def test_skip_backup_msg(client: Client, backup_type, backup_flow): - with WITH_MOCK_URANDOM, client: - device.reset( + with client: + device.setup( client, skip_backup=True, passphrase_protection=False, pin_protection=False, backup_type=backup_type, + entropy_check_count=0, + _get_entropy=MOCK_GET_ENTROPY, ) assert client.features.initialized is True @@ -108,14 +110,16 @@ def test_skip_backup_msg(client: Client, backup_type, backup_flow): @pytest.mark.parametrize("backup_type, backup_flow", VECTORS) @pytest.mark.setup_client(uninitialized=True) def test_skip_backup_manual(client: Client, backup_type: BackupType, backup_flow): - with WITH_MOCK_URANDOM, client: + with client: IF = InputFlowResetSkipBackup(client) client.set_input_flow(IF.get()) - device.reset( + device.setup( client, pin_protection=False, passphrase_protection=False, backup_type=backup_type, + entropy_check_count=0, + _get_entropy=MOCK_GET_ENTROPY, ) assert client.features.initialized is True diff --git a/tests/device_tests/reset_recovery/test_reset_bip39_t1.py b/tests/device_tests/reset_recovery/test_reset_bip39_t1.py index 689b81b0d6..0c96ee4f5c 100644 --- a/tests/device_tests/reset_recovery/test_reset_bip39_t1.py +++ b/tests/device_tests/reset_recovery/test_reset_bip39_t1.py @@ -209,7 +209,7 @@ def test_failed_pin(client: Client): def test_already_initialized(client: Client): with pytest.raises(Exception): - device.reset( + device.setup( client, strength=128, passphrase_protection=True, diff --git a/tests/device_tests/reset_recovery/test_reset_bip39_t2.py b/tests/device_tests/reset_recovery/test_reset_bip39_t2.py index 56f3f8f12b..a1eb1856aa 100644 --- a/tests/device_tests/reset_recovery/test_reset_bip39_t2.py +++ b/tests/device_tests/reset_recovery/test_reset_bip39_t2.py @@ -23,7 +23,7 @@ from trezorlib.debuglink import LayoutType from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.exceptions import TrezorFailure -from ...common import EXTERNAL_ENTROPY, MNEMONIC12, WITH_MOCK_URANDOM, generate_entropy +from ...common import EXTERNAL_ENTROPY, MNEMONIC12, MOCK_GET_ENTROPY, generate_entropy from ...input_flows import ( InputFlowBip39ResetBackup, InputFlowBip39ResetFailedCheck, @@ -34,21 +34,25 @@ pytestmark = pytest.mark.models("core") def reset_device(client: Client, strength: int): - with WITH_MOCK_URANDOM, client: + with client: IF = InputFlowBip39ResetBackup(client) client.set_input_flow(IF.get()) # No PIN, no passphrase, don't display random - device.reset( + device.setup( client, strength=strength, passphrase_protection=False, pin_protection=False, label="test", + entropy_check_count=0, + backup_type=messages.BackupType.Bip39, + _get_entropy=MOCK_GET_ENTROPY, ) # generate mnemonic locally internal_entropy = client.debug.state().reset_entropy + assert internal_entropy is not None entropy = generate_entropy(strength, internal_entropy, EXTERNAL_ENTROPY) expected_mnemonic = Mnemonic("english").to_mnemonic(entropy) @@ -56,12 +60,13 @@ def reset_device(client: Client, strength: int): assert IF.mnemonic == expected_mnemonic # Check if device is properly initialized - resp = client.call_raw(messages.Initialize()) - assert resp.initialized is True - assert resp.backup_availability == messages.BackupAvailability.NotAvailable - assert resp.pin_protection is False - assert resp.passphrase_protection is False - assert resp.backup_type is messages.BackupType.Bip39 + assert client.features.initialized is True + assert ( + client.features.backup_availability == messages.BackupAvailability.NotAvailable + ) + assert client.features.pin_protection is False + assert client.features.passphrase_protection is False + assert client.features.backup_type is messages.BackupType.Bip39 # backup attempt fails because backup was done in reset with pytest.raises(TrezorFailure, match="ProcessError: Seed already backed up"): @@ -82,21 +87,25 @@ def test_reset_device_192(client: Client): def test_reset_device_pin(client: Client): strength = 256 # 24 words - with WITH_MOCK_URANDOM, client: + with client: IF = InputFlowBip39ResetPIN(client) client.set_input_flow(IF.get()) # PIN, passphrase, display random - device.reset( + device.setup( client, strength=strength, passphrase_protection=True, pin_protection=True, label="test", + entropy_check_count=0, + backup_type=messages.BackupType.Bip39, + _get_entropy=MOCK_GET_ENTROPY, ) # generate mnemonic locally internal_entropy = client.debug.state().reset_entropy + assert internal_entropy is not None entropy = generate_entropy(strength, internal_entropy, EXTERNAL_ENTROPY) expected_mnemonic = Mnemonic("english").to_mnemonic(entropy) @@ -104,33 +113,37 @@ def test_reset_device_pin(client: Client): assert IF.mnemonic == expected_mnemonic # Check if device is properly initialized - resp = client.call_raw(messages.Initialize()) - assert resp.initialized is True - assert resp.backup_availability == messages.BackupAvailability.NotAvailable - assert resp.pin_protection is True - assert resp.passphrase_protection is True + assert client.features.initialized is True + assert ( + client.features.backup_availability == messages.BackupAvailability.NotAvailable + ) + assert client.features.pin_protection is True + assert client.features.passphrase_protection is True @pytest.mark.setup_client(uninitialized=True) def test_reset_entropy_check(client: Client): strength = 128 # 12 words - with WITH_MOCK_URANDOM, client: + with client: IF = InputFlowBip39ResetBackup(client) client.set_input_flow(IF.get()) # No PIN, no passphrase - _, path_xpubs = device.reset_entropy_check( + path_xpubs = device.setup( client, strength=strength, passphrase_protection=False, pin_protection=False, label="test", entropy_check_count=2, + backup_type=messages.BackupType.Bip39, + _get_entropy=MOCK_GET_ENTROPY, ) # Generate the mnemonic locally. internal_entropy = client.debug.state().reset_entropy + assert internal_entropy is not None entropy = generate_entropy(strength, internal_entropy, EXTERNAL_ENTROPY) expected_mnemonic = Mnemonic("english").to_mnemonic(entropy) @@ -138,12 +151,13 @@ def test_reset_entropy_check(client: Client): assert IF.mnemonic == expected_mnemonic # Check that the device is properly initialized. - resp = client.call_raw(messages.Initialize()) - assert resp.initialized is True - assert resp.backup_availability == messages.BackupAvailability.NotAvailable - assert resp.pin_protection is False - assert resp.passphrase_protection is False - assert resp.backup_type is messages.BackupType.Bip39 + assert client.features.initialized is True + assert ( + client.features.backup_availability == messages.BackupAvailability.NotAvailable + ) + assert client.features.pin_protection is False + assert client.features.passphrase_protection is False + assert client.features.backup_type is messages.BackupType.Bip39 # Check that the XPUBs are the same as those from the entropy check. for path, xpub in path_xpubs: @@ -155,21 +169,25 @@ def test_reset_entropy_check(client: Client): def test_reset_failed_check(client: Client): strength = 256 # 24 words - with WITH_MOCK_URANDOM, client: + with client: IF = InputFlowBip39ResetFailedCheck(client) client.set_input_flow(IF.get()) # PIN, passphrase, display random - device.reset( + device.setup( client, strength=strength, passphrase_protection=False, pin_protection=False, label="test", + entropy_check_count=0, + backup_type=messages.BackupType.Bip39, + _get_entropy=MOCK_GET_ENTROPY, ) # generate mnemonic locally internal_entropy = client.debug.state().reset_entropy + assert internal_entropy is not None entropy = generate_entropy(strength, internal_entropy, EXTERNAL_ENTROPY) expected_mnemonic = Mnemonic("english").to_mnemonic(entropy) @@ -177,12 +195,13 @@ def test_reset_failed_check(client: Client): assert IF.mnemonic == expected_mnemonic # Check if device is properly initialized - resp = client.call_raw(messages.Initialize()) - assert resp.initialized is True - assert resp.backup_availability == messages.BackupAvailability.NotAvailable - assert resp.pin_protection is False - assert resp.passphrase_protection is False - assert resp.backup_type is messages.BackupType.Bip39 + assert client.features.initialized is True + assert ( + client.features.backup_availability == messages.BackupAvailability.NotAvailable + ) + assert client.features.pin_protection is False + assert client.features.passphrase_protection is False + assert client.features.backup_type is messages.BackupType.Bip39 @pytest.mark.setup_client(uninitialized=True) @@ -223,7 +242,7 @@ def test_failed_pin(client: Client): @pytest.mark.setup_client(mnemonic=MNEMONIC12) def test_already_initialized(client: Client): with pytest.raises(Exception): - device.reset( + device.setup( client, strength=128, passphrase_protection=True, diff --git a/tests/device_tests/reset_recovery/test_reset_recovery_bip39.py b/tests/device_tests/reset_recovery/test_reset_recovery_bip39.py index 89c327fb8f..ac24ccbcfa 100644 --- a/tests/device_tests/reset_recovery/test_reset_recovery_bip39.py +++ b/tests/device_tests/reset_recovery/test_reset_recovery_bip39.py @@ -21,7 +21,7 @@ from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.messages import BackupType from trezorlib.tools import parse_path -from ...common import WITH_MOCK_URANDOM +from ...common import MOCK_GET_ENTROPY from ...input_flows import InputFlowBip39Recovery, InputFlowBip39ResetBackup from ...translations import set_language @@ -41,18 +41,20 @@ def test_reset_recovery(client: Client): def reset(client: Client, strength: int = 128, skip_backup: bool = False) -> str: - with WITH_MOCK_URANDOM, client: + with client: IF = InputFlowBip39ResetBackup(client) client.set_input_flow(IF.get()) # No PIN, no passphrase, don't display random - device.reset( + device.setup( client, strength=strength, passphrase_protection=False, pin_protection=False, label="test", backup_type=BackupType.Bip39, + entropy_check_count=0, + _get_entropy=MOCK_GET_ENTROPY, ) # Check if device is properly initialized @@ -73,9 +75,7 @@ def recover(client: Client, mnemonic: str): IF = InputFlowBip39Recovery(client, words) client.set_input_flow(IF.get()) client.watch_layout() - ret = device.recover(client, pin_protection=False, label="label") + device.recover(client, pin_protection=False, label="label") - # Workflow successfully ended - assert ret == messages.Success(message="Device recovered") assert client.features.pin_protection is False assert client.features.passphrase_protection is False diff --git a/tests/device_tests/reset_recovery/test_reset_recovery_slip39_advanced.py b/tests/device_tests/reset_recovery/test_reset_recovery_slip39_advanced.py index 8b42940d75..ffa9e73f77 100644 --- a/tests/device_tests/reset_recovery/test_reset_recovery_slip39_advanced.py +++ b/tests/device_tests/reset_recovery/test_reset_recovery_slip39_advanced.py @@ -21,7 +21,7 @@ from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.messages import BackupType from trezorlib.tools import parse_path -from ...common import WITH_MOCK_URANDOM +from ...common import MOCK_GET_ENTROPY from ...input_flows import ( InputFlowSlip39AdvancedRecovery, InputFlowSlip39AdvancedResetRecovery, @@ -62,18 +62,20 @@ def test_reset_recovery(client: Client): def reset(client: Client, strength: int = 128) -> list[str]: - with WITH_MOCK_URANDOM, client: + with client: IF = InputFlowSlip39AdvancedResetRecovery(client, False) client.set_input_flow(IF.get()) # No PIN, no passphrase, don't display random - device.reset( + device.setup( client, strength=strength, passphrase_protection=False, pin_protection=False, label="test", backup_type=BackupType.Slip39_Advanced, + entropy_check_count=0, + _get_entropy=MOCK_GET_ENTROPY, ) # Check if device is properly initialized @@ -92,10 +94,8 @@ def recover(client: Client, shares: list[str]): with client: IF = InputFlowSlip39AdvancedRecovery(client, shares, False) client.set_input_flow(IF.get()) - ret = device.recover(client, pin_protection=False, label="label") + device.recover(client, pin_protection=False, label="label") - # Workflow successfully ended - assert ret == messages.Success(message="Device recovered") assert client.features.pin_protection is False assert client.features.passphrase_protection is False assert client.features.backup_type is BackupType.Slip39_Advanced_Extendable diff --git a/tests/device_tests/reset_recovery/test_reset_recovery_slip39_basic.py b/tests/device_tests/reset_recovery/test_reset_recovery_slip39_basic.py index 6b72246a10..44baf4cff3 100644 --- a/tests/device_tests/reset_recovery/test_reset_recovery_slip39_basic.py +++ b/tests/device_tests/reset_recovery/test_reset_recovery_slip39_basic.py @@ -15,6 +15,7 @@ # If not, see . import itertools +import typing as t import pytest @@ -23,7 +24,7 @@ from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.messages import BackupType from trezorlib.tools import parse_path -from ...common import WITH_MOCK_URANDOM +from ...common import MOCK_GET_ENTROPY from ...input_flows import ( InputFlowSlip39BasicRecovery, InputFlowSlip39BasicResetRecovery, @@ -33,7 +34,6 @@ from ...translations import set_language @pytest.mark.models("core") @pytest.mark.setup_client(uninitialized=True) -@WITH_MOCK_URANDOM def test_reset_recovery(client: Client): mnemonics = reset(client) address_before = btc.get_address(client, "Bitcoin", parse_path("m/44h/0h/0h/0/0")) @@ -56,13 +56,15 @@ def reset(client: Client, strength: int = 128) -> list[str]: client.set_input_flow(IF.get()) # No PIN, no passphrase, don't display random - device.reset( + device.setup( client, strength=strength, passphrase_protection=False, pin_protection=False, label="test", backup_type=BackupType.Slip39_Basic, + entropy_check_count=0, + _get_entropy=MOCK_GET_ENTROPY, ) # Check if device is properly initialized @@ -77,14 +79,12 @@ def reset(client: Client, strength: int = 128) -> list[str]: return IF.mnemonics -def recover(client: Client, shares: list[str]): +def recover(client: Client, shares: t.Sequence[str]): with client: IF = InputFlowSlip39BasicRecovery(client, shares) client.set_input_flow(IF.get()) - ret = device.recover(client, pin_protection=False, label="label") + device.recover(client, pin_protection=False, label="label") - # Workflow successfully ended - assert ret == messages.Success(message="Device recovered") assert client.features.pin_protection is False assert client.features.passphrase_protection is False assert client.features.backup_type is BackupType.Slip39_Basic_Extendable diff --git a/tests/device_tests/reset_recovery/test_reset_slip39_advanced.py b/tests/device_tests/reset_recovery/test_reset_slip39_advanced.py index 6aa9d2bf3d..840841d734 100644 --- a/tests/device_tests/reset_recovery/test_reset_slip39_advanced.py +++ b/tests/device_tests/reset_recovery/test_reset_slip39_advanced.py @@ -22,7 +22,7 @@ from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.exceptions import TrezorFailure from trezorlib.messages import BackupAvailability, BackupType -from ...common import EXTERNAL_ENTROPY, WITH_MOCK_URANDOM, generate_entropy +from ...common import EXTERNAL_ENTROPY, MOCK_GET_ENTROPY, generate_entropy from ...input_flows import InputFlowSlip39AdvancedResetRecovery pytestmark = pytest.mark.models("core") @@ -34,22 +34,25 @@ def test_reset_device_slip39_advanced(client: Client): strength = 128 member_threshold = 3 - with WITH_MOCK_URANDOM, client: + with client: IF = InputFlowSlip39AdvancedResetRecovery(client, False) client.set_input_flow(IF.get()) # No PIN, no passphrase, don't display random - device.reset( + device.setup( client, strength=strength, passphrase_protection=False, pin_protection=False, label="test", backup_type=BackupType.Slip39_Advanced, + entropy_check_count=0, + _get_entropy=MOCK_GET_ENTROPY, ) # generate secret locally internal_entropy = client.debug.state().reset_entropy + assert internal_entropy is not None secret = generate_entropy(strength, internal_entropy, EXTERNAL_ENTROPY) # validate that all combinations will result in the correct master secret @@ -68,7 +71,7 @@ def test_reset_device_slip39_advanced(client: Client): def validate_mnemonics( - mnemonics: list[list[str]], threshold: int, expected_ems: bytes + mnemonics: list[str], threshold: int, expected_ems: bytes ) -> None: # 3of5 shares 3of5 groups # TODO: test all possible group+share combinations? diff --git a/tests/device_tests/reset_recovery/test_reset_slip39_basic.py b/tests/device_tests/reset_recovery/test_reset_slip39_basic.py index b0d39f9eb1..b284012cbe 100644 --- a/tests/device_tests/reset_recovery/test_reset_slip39_basic.py +++ b/tests/device_tests/reset_recovery/test_reset_slip39_basic.py @@ -25,7 +25,7 @@ from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.exceptions import TrezorFailure from trezorlib.messages import BackupAvailability, BackupType -from ...common import EXTERNAL_ENTROPY, WITH_MOCK_URANDOM, generate_entropy +from ...common import EXTERNAL_ENTROPY, MOCK_GET_ENTROPY, generate_entropy from ...input_flows import InputFlowSlip39BasicResetRecovery pytestmark = pytest.mark.models("core") @@ -34,22 +34,25 @@ pytestmark = pytest.mark.models("core") def reset_device(client: Client, strength: int): member_threshold = 3 - with WITH_MOCK_URANDOM, client: + with client: IF = InputFlowSlip39BasicResetRecovery(client) client.set_input_flow(IF.get()) # No PIN, no passphrase, don't display random - device.reset( + device.setup( client, strength=strength, passphrase_protection=False, pin_protection=False, label="test", backup_type=BackupType.Slip39_Basic, + entropy_check_count=0, + _get_entropy=MOCK_GET_ENTROPY, ) # generate secret locally internal_entropy = client.debug.state().reset_entropy + assert internal_entropy is not None secret = generate_entropy(strength, internal_entropy, EXTERNAL_ENTROPY) # validate that all combinations will result in the correct master secret @@ -83,12 +86,12 @@ def test_reset_entropy_check(client: Client): strength = 128 # 20 words - with WITH_MOCK_URANDOM, client: + with client: IF = InputFlowSlip39BasicResetRecovery(client) client.set_input_flow(IF.get()) # No PIN, no passphrase. - _, path_xpubs = device.reset_entropy_check( + path_xpubs = device.setup( client, strength=strength, passphrase_protection=False, @@ -96,10 +99,12 @@ def test_reset_entropy_check(client: Client): label="test", backup_type=BackupType.Slip39_Basic, entropy_check_count=3, + _get_entropy=MOCK_GET_ENTROPY, ) # Generate the master secret locally. internal_entropy = client.debug.state().reset_entropy + assert internal_entropy is not None secret = generate_entropy(strength, internal_entropy, EXTERNAL_ENTROPY) # Check that all combinations will result in the correct master secret. diff --git a/tests/device_tests/solana/test_address.py b/tests/device_tests/solana/test_address.py index dca1126c05..b3af4ea8ed 100644 --- a/tests/device_tests/solana/test_address.py +++ b/tests/device_tests/solana/test_address.py @@ -37,4 +37,4 @@ def test_solana_get_address(client: Client, parameters, result): client, address_n=parse_path(parameters["path"]), show_display=True ) - assert actual_result.address == result["expected_address"] + assert actual_result == result["expected_address"] diff --git a/tests/device_tests/solana/test_public_key.py b/tests/device_tests/solana/test_public_key.py index 864852b116..e12c345fc3 100644 --- a/tests/device_tests/solana/test_public_key.py +++ b/tests/device_tests/solana/test_public_key.py @@ -37,4 +37,4 @@ def test_solana_get_public_key(client: Client, parameters, result): client, address_n=parse_path(parameters["path"]), show_display=True ) - assert actual_result.public_key.hex() == result["expected_public_key"] + assert actual_result.hex() == result["expected_public_key"] diff --git a/tests/device_tests/solana/test_sign_tx.py b/tests/device_tests/solana/test_sign_tx.py index 241a3d3b34..de7ec34462 100644 --- a/tests/device_tests/solana/test_sign_tx.py +++ b/tests/device_tests/solana/test_sign_tx.py @@ -70,7 +70,7 @@ def test_solana_sign_tx(client: Client, parameters, result): ), ) - assert actual_result.signature == bytes.fromhex(result["expected_signature"]) + assert actual_result == bytes.fromhex(result["expected_signature"]) def _serialize_tx(tx_construct): diff --git a/tests/device_tests/test_msg_applysettings.py b/tests/device_tests/test_msg_applysettings.py index 65ea935748..9e3161bb8b 100644 --- a/tests/device_tests/test_msg_applysettings.py +++ b/tests/device_tests/test_msg_applysettings.py @@ -426,11 +426,4 @@ def test_label_too_long(client: Client): @pytest.mark.models(skip=["legacy", "safe3"]) @pytest.mark.setup_client(pin=None) def test_set_brightness(client: Client): - with client: - assert ( - device.set_brightness( - client, - None, - ) - == "Settings applied" - ) + device.set_brightness(client, None) diff --git a/tests/device_tests/test_msg_wipedevice.py b/tests/device_tests/test_msg_wipedevice.py index d94f392f1b..6009dd624d 100644 --- a/tests/device_tests/test_msg_wipedevice.py +++ b/tests/device_tests/test_msg_wipedevice.py @@ -54,7 +54,14 @@ def test_autolock_not_retained(client: Client): with client: client.use_pin_sequence([PIN4, PIN4]) - device.reset(client, skip_backup=True, pin_protection=True) + device.setup( + client, + skip_backup=True, + pin_protection=True, + passphrase_protection=False, + entropy_check_count=0, + backup_type=messages.BackupType.Bip39, + ) time.sleep(10.5) with client: diff --git a/tests/device_tests/test_protection_levels.py b/tests/device_tests/test_protection_levels.py index 9176df3051..b05a5b02c2 100644 --- a/tests/device_tests/test_protection_levels.py +++ b/tests/device_tests/test_protection_levels.py @@ -22,7 +22,7 @@ from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.exceptions import TrezorFailure from trezorlib.tools import parse_path -from ..common import MNEMONIC12, WITH_MOCK_URANDOM, get_test_address, is_core +from ..common import MNEMONIC12, MOCK_GET_ENTROPY, get_test_address, is_core from ..tx_cache import TxCache from .bitcoin.signtx import ( request_finished, @@ -214,24 +214,26 @@ def test_wipe_device(client: Client): def test_reset_device(client: Client): assert client.features.pin_protection is False assert client.features.passphrase_protection is False - with WITH_MOCK_URANDOM, client: + with client: client.set_expected_responses( [messages.ButtonRequest] + [messages.EntropyRequest] + [messages.ButtonRequest] * 24 + [messages.Success, messages.Features] ) - device.reset( + device.setup( client, strength=128, passphrase_protection=True, pin_protection=False, label="label", + entropy_check_count=0, + _get_entropy=MOCK_GET_ENTROPY, ) with pytest.raises(TrezorFailure): # This must fail, because device is already initialized - # Using direct call because `device.reset` has its own check + # Using direct call because `device.setup` has its own check client.call( messages.ResetDevice( strength=128, diff --git a/tests/device_tests/test_repeated_backup.py b/tests/device_tests/test_repeated_backup.py index 3bf2d42510..9fc25ad202 100644 --- a/tests/device_tests/test_repeated_backup.py +++ b/tests/device_tests/test_repeated_backup.py @@ -25,7 +25,6 @@ from .. import translations as TR from ..common import ( MNEMONIC_SLIP39_SINGLE_EXT_20, TEST_ADDRESS_N, - WITH_MOCK_URANDOM, MNEMONIC_SLIP39_BASIC_20_3of6, ) from ..input_flows import InputFlowSlip39BasicBackup, InputFlowSlip39BasicRecoveryDryRun @@ -34,7 +33,6 @@ pytestmark = pytest.mark.models("core") @pytest.mark.setup_client(needs_backup=True, mnemonic=MNEMONIC_SLIP39_BASIC_20_3of6) -@WITH_MOCK_URANDOM def test_repeated_backup(client: Client): assert client.features.backup_availability == messages.BackupAvailability.Required assert client.features.recovery_status == messages.RecoveryStatus.Nothing @@ -63,8 +61,7 @@ def test_repeated_backup(client: Client): client, mnemonics[:3], unlock_repeated_backup=True ) client.set_input_flow(IF.get()) - ret = device.recover(client, type=messages.RecoveryType.UnlockRepeatedBackup) - assert ret == messages.Success(message="Backup unlocked") + device.recover(client, type=messages.RecoveryType.UnlockRepeatedBackup) assert ( client.features.backup_availability == messages.BackupAvailability.Available ) @@ -86,7 +83,6 @@ def test_repeated_backup(client: Client): @pytest.mark.setup_client(mnemonic=MNEMONIC_SLIP39_SINGLE_EXT_20) -@WITH_MOCK_URANDOM def test_repeated_backup_upgrade_single(client: Client): assert ( client.features.backup_availability == messages.BackupAvailability.NotAvailable @@ -100,8 +96,7 @@ def test_repeated_backup_upgrade_single(client: Client): client, MNEMONIC_SLIP39_SINGLE_EXT_20, unlock_repeated_backup=True ) client.set_input_flow(IF.get()) - ret = device.recover(client, type=messages.RecoveryType.UnlockRepeatedBackup) - assert ret == messages.Success(message="Backup unlocked") + device.recover(client, type=messages.RecoveryType.UnlockRepeatedBackup) assert ( client.features.backup_availability == messages.BackupAvailability.Available ) @@ -125,7 +120,6 @@ def test_repeated_backup_upgrade_single(client: Client): @pytest.mark.setup_client(needs_backup=True, mnemonic=MNEMONIC_SLIP39_BASIC_20_3of6) -@WITH_MOCK_URANDOM def test_repeated_backup_cancel(client: Client): assert client.features.backup_availability == messages.BackupAvailability.Required assert client.features.recovery_status == messages.RecoveryStatus.Nothing @@ -154,8 +148,7 @@ def test_repeated_backup_cancel(client: Client): client, mnemonics[:3], unlock_repeated_backup=True ) client.set_input_flow(IF.get()) - ret = device.recover(client, type=messages.RecoveryType.UnlockRepeatedBackup) - assert ret == messages.Success(message="Backup unlocked") + device.recover(client, type=messages.RecoveryType.UnlockRepeatedBackup) assert ( client.features.backup_availability == messages.BackupAvailability.Available ) @@ -181,7 +174,6 @@ def test_repeated_backup_cancel(client: Client): @pytest.mark.setup_client(needs_backup=True, mnemonic=MNEMONIC_SLIP39_BASIC_20_3of6) -@WITH_MOCK_URANDOM def test_repeated_backup_send_disallowed_message(client: Client): assert client.features.backup_availability == messages.BackupAvailability.Required assert client.features.recovery_status == messages.RecoveryStatus.Nothing @@ -210,8 +202,7 @@ def test_repeated_backup_send_disallowed_message(client: Client): client, mnemonics[:3], unlock_repeated_backup=True ) client.set_input_flow(IF.get()) - ret = device.recover(client, type=messages.RecoveryType.UnlockRepeatedBackup) - assert ret == messages.Success(message="Backup unlocked") + device.recover(client, type=messages.RecoveryType.UnlockRepeatedBackup) assert ( client.features.backup_availability == messages.BackupAvailability.Available ) diff --git a/tests/upgrade_tests/test_firmware_upgrades.py b/tests/upgrade_tests/test_firmware_upgrades.py index bafe67f511..5d8c877865 100644 --- a/tests/upgrade_tests/test_firmware_upgrades.py +++ b/tests/upgrade_tests/test_firmware_upgrades.py @@ -208,12 +208,14 @@ def test_upgrade_reset(gen: str, tag: str): assert not client.features.no_backup with EmulatorWrapper(gen, tag) as emu: - device.reset( + device.setup( emu.client, strength=STRENGTH, passphrase_protection=False, pin_protection=False, label=LABEL, + entropy_check_count=0, + backup_type=BackupType.Bip39, ) device_id = emu.client.features.device_id asserts(emu.client) @@ -238,13 +240,15 @@ def test_upgrade_reset_skip_backup(gen: str, tag: str): assert not client.features.no_backup with EmulatorWrapper(gen, tag) as emu: - device.reset( + device.setup( emu.client, strength=STRENGTH, passphrase_protection=False, pin_protection=False, label=LABEL, skip_backup=True, + entropy_check_count=0, + backup_type=BackupType.Bip39, ) device_id = emu.client.features.device_id asserts(emu.client) @@ -269,14 +273,17 @@ def test_upgrade_reset_no_backup(gen: str, tag: str): assert client.features.no_backup with EmulatorWrapper(gen, tag) as emu: - device.reset( + device.setup( emu.client, strength=STRENGTH, passphrase_protection=False, pin_protection=False, label=LABEL, no_backup=True, + entropy_check_count=0, + backup_type=BackupType.Bip39, ) + device_id = emu.client.features.device_id asserts(emu.client) address = btc.get_address(emu.client, "Bitcoin", PATH) @@ -344,11 +351,12 @@ def test_upgrade_shamir_recovery(gen: str, tag: Optional[str]): def test_upgrade_shamir_backup(gen: str, tag: Optional[str]): with EmulatorWrapper(gen, tag) as emu: # Generate a new encrypted master secret and record it. - device.reset( + device.setup( emu.client, pin_protection=False, skip_backup=True, backup_type=BackupType.Slip39_Basic, + entropy_check_count=0, ) device_id = emu.client.features.device_id backup_type = emu.client.features.backup_type @@ -414,8 +422,7 @@ def test_upgrade_u2f(gen: str, tag: str): label=LABEL, ) - success = fido.set_counter(emu.client, 10) - assert "U2F counter set" in success + fido.set_counter(emu.client, 10) counter = fido.get_next_counter(emu.client) assert counter == 11 diff --git a/tests/upgrade_tests/test_passphrase_consistency.py b/tests/upgrade_tests/test_passphrase_consistency.py index 67a4c406fb..a368c75bc5 100644 --- a/tests/upgrade_tests/test_passphrase_consistency.py +++ b/tests/upgrade_tests/test_passphrase_consistency.py @@ -46,10 +46,12 @@ mapping.DEFAULT_MAPPING.register(ApplySettingsCompat) def emulator(gen: str, tag: str) -> Iterator[Emulator]: with EmulatorWrapper(gen, tag) as emu: # set up a passphrase-protected device - device.reset( + device.setup( emu.client, pin_protection=False, skip_backup=True, + entropy_check_count=0, + backup_type=messages.BackupType.Bip39, ) resp = emu.client.call( ApplySettingsCompat(use_passphrase=True, passphrase_source=SOURCE_HOST)