From a63bf72d08ae04b6222d1655c9d0f64b86d409f9 Mon Sep 17 00:00:00 2001 From: grdddj Date: Sun, 13 Nov 2022 11:49:57 +0100 Subject: [PATCH] WIP - fix device tests --- core/src/trezor/ui/layouts/tr/__init__.py | 9 ++-- .../test_recovery_bip39_dryrun.py | 8 +++- .../reset_recovery/test_recovery_bip39_t2.py | 24 ++++++++-- .../reset_recovery/test_reset_backup.py | 6 ++- .../reset_recovery/test_reset_bip39_t2.py | 12 +++-- .../test_reset_recovery_bip39.py | 3 +- tests/device_tests/test_autolock.py | 10 +++- tests/device_tests/test_msg_applysettings.py | 11 ++++- tests/device_tests/test_msg_backup_device.py | 3 +- .../test_msg_change_wipe_code_t2.py | 24 +++++++--- tests/device_tests/test_msg_changepin_t2.py | 48 ++++++++++++++++--- tests/device_tests/test_pin.py | 30 ++++++++++-- tests/device_tests/test_protection_levels.py | 43 +++++++++-------- tests/device_tests/test_session.py | 1 + 14 files changed, 177 insertions(+), 55 deletions(-) diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index 1c2d23cd95..68271c55de 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -590,6 +590,7 @@ def _show_xpub(xpub: str, title: str, cancel: str) -> ui.Layout: trezorui2.confirm_text( title=title.upper(), data=xpub, + description="", # verb_cancel=cancel, ) ) @@ -1254,8 +1255,6 @@ async def request_pin_on_device( allow_cancel: bool, shuffle: bool = False, ) -> str: - await button_request(ctx, "pin_device", code=ButtonRequestType.PinEntry) - if attempts_remaining is None: subprompt = "" elif attempts_remaining == 1: @@ -1266,15 +1265,17 @@ async def request_pin_on_device( if attempts_remaining is not None: await confirm_action( ctx, - "pin_device", + "pin_device_info", "PIN entry", action=prompt, description=subprompt, verb="BEGIN", verb_cancel=None, - br_code=ButtonRequestType.PinEntry, + br_code=ButtonRequestType.Other, # cannot use BRT.PinEntry, as debuglink would be sending PIN to this screen ) + await button_request(ctx, "pin_device", code=ButtonRequestType.PinEntry) + dialog = RustLayout( trezorui2.request_pin( prompt=prompt, diff --git a/tests/device_tests/reset_recovery/test_recovery_bip39_dryrun.py b/tests/device_tests/reset_recovery/test_recovery_bip39_dryrun.py index a5cf4b7ab6..03fbe1291e 100644 --- a/tests/device_tests/reset_recovery/test_recovery_bip39_dryrun.py +++ b/tests/device_tests/reset_recovery/test_recovery_bip39_dryrun.py @@ -92,7 +92,8 @@ def do_recover_r(client: Client, mnemonic: List[str], **kwargs: Any): layout = client.debug.wait_layout def input_flow(): - pytest.fail("Freezes") + if client.features.model == "R": + pytest.skip("Freezes") yield assert "check the recovery seed" in layout().text client.debug.press_right() @@ -222,6 +223,11 @@ def test_invalid_seed_core(client: Client): assert "Enter recovery seed" in layout().text client.debug.press_right() + yield + layout = client.debug.wait_layout() + assert "WORD ENTERING" in layout.text + client.debug.press_right() + yield for _ in range(12): yield diff --git a/tests/device_tests/reset_recovery/test_recovery_bip39_t2.py b/tests/device_tests/reset_recovery/test_recovery_bip39_t2.py index 45faa5215f..522055b557 100644 --- a/tests/device_tests/reset_recovery/test_recovery_bip39_t2.py +++ b/tests/device_tests/reset_recovery/test_recovery_bip39_t2.py @@ -65,15 +65,21 @@ def test_tt_pin_passphrase(client: Client): def input_flow_tr(): yield - assert "Do you really want to recover a wallet?" in layout().text + assert "By continuing you agree" in layout().text + client.debug.press_right() + assert "trezor.io/tos" in layout().text client.debug.press_yes() yield - assert "PIN" in layout().text + assert "ENTER" in layout().text client.debug.input("654") yield - assert "PIN" in layout().text + assert "re-enter to confirm" in layout().text + client.debug.press_right() + + yield + assert "ENTER" in layout().text client.debug.input("654") yield @@ -89,6 +95,10 @@ def test_tt_pin_passphrase(client: Client): assert "Enter recovery seed" in layout().text client.debug.press_yes() + yield + assert "WORD ENTERING" in layout().text + client.debug.press_right() + yield for word in mnemonic: yield @@ -154,7 +164,9 @@ def test_tt_nopin_nopassphrase(client: Client): def input_flow_tr(): yield - assert "Do you really want to recover a wallet?" in layout().text + assert "By continuing you agree" in layout().text + client.debug.press_right() + assert "trezor.io/tos" in layout().text client.debug.press_yes() yield @@ -170,6 +182,10 @@ def test_tt_nopin_nopassphrase(client: Client): assert "Enter recovery seed" in layout().text client.debug.press_yes() + yield + assert "WORD ENTERING" in layout().text + client.debug.press_right() + yield for word in mnemonic: yield diff --git a/tests/device_tests/reset_recovery/test_reset_backup.py b/tests/device_tests/reset_recovery/test_reset_backup.py index d642f6c76c..7a24e5d26f 100644 --- a/tests/device_tests/reset_recovery/test_reset_backup.py +++ b/tests/device_tests/reset_recovery/test_reset_backup.py @@ -200,7 +200,8 @@ 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): - pytest.fail("Freezes") + if client.features.model == "R": + pytest.skip("Freezes") os_urandom = mock.Mock(return_value=EXTERNAL_ENTROPY) with mock.patch("os.urandom", os_urandom), client: device.reset( @@ -236,7 +237,8 @@ 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, backup_flow): - pytest.fail("Freezes") + if client.features.model == "R": + pytest.skip("Freezes") def reset_skip_input_flow(): yield # Confirm Recovery 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 110824aef5..fab9aea213 100644 --- a/tests/device_tests/reset_recovery/test_reset_bip39_t2.py +++ b/tests/device_tests/reset_recovery/test_reset_bip39_t2.py @@ -118,19 +118,22 @@ def reset_device(client: Client, strength): @pytest.mark.setup_client(uninitialized=True) def test_reset_device(client: Client): - pytest.fail("Freezes") + if client.features.model == "R": + pytest.skip("Freezes") reset_device(client, 128) # 12 words @pytest.mark.setup_client(uninitialized=True) def test_reset_device_192(client: Client): - pytest.fail("Freezes") + if client.features.model == "R": + pytest.skip("Freezes") reset_device(client, 192) # 18 words @pytest.mark.setup_client(uninitialized=True) def test_reset_device_pin(client: Client): - pytest.fail("Freezes") + if client.features.model == "R": + pytest.skip("Freezes") mnemonic = None strength = 256 # 24 words @@ -234,7 +237,8 @@ def test_reset_device_pin(client: Client): @pytest.mark.setup_client(uninitialized=True) def test_reset_failed_check(client: Client): - pytest.fail("Freezes") + if client.features.model == "R": + pytest.skip("Freezes") mnemonic = None strength = 256 # 24 words 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 f51b567523..5d522c2980 100644 --- a/tests/device_tests/reset_recovery/test_reset_recovery_bip39.py +++ b/tests/device_tests/reset_recovery/test_reset_recovery_bip39.py @@ -35,7 +35,8 @@ from ...common import ( @pytest.mark.skip_t1 @pytest.mark.setup_client(uninitialized=True) def test_reset_recovery(client: Client): - pytest.fail("Freezes") + if client.features.model == "R": + pytest.skip("Freezes") mnemonic = reset(client) address_before = btc.get_address(client, "Bitcoin", parse_path("m/44h/0h/0h/0/0")) diff --git a/tests/device_tests/test_autolock.py b/tests/device_tests/test_autolock.py index 9b37b74c3f..1a4c7a741c 100644 --- a/tests/device_tests/test_autolock.py +++ b/tests/device_tests/test_autolock.py @@ -44,6 +44,7 @@ def set_autolock_delay(client: Client, delay): [ pin_request(client), messages.ButtonRequest, + (client.features.model == "R", messages.ButtonRequest), messages.Success, messages.Features, ] @@ -63,7 +64,13 @@ def test_apply_auto_lock_delay(client: Client): time.sleep(10.5) # sleep more than auto-lock delay with client: client.use_pin_sequence([PIN4]) - client.set_expected_responses([pin_request(client), messages.Address]) + client.set_expected_responses( + [ + pin_request(client), + (client.features.model == "R", messages.ButtonRequest), + messages.Address, + ] + ) get_test_address(client) @@ -102,6 +109,7 @@ def test_apply_auto_lock_delay_out_of_range(client: Client, seconds): client.set_expected_responses( [ pin_request(client), + (client.features.model == "R", messages.ButtonRequest), messages.Failure(code=messages.FailureType.ProcessError), ] ) diff --git a/tests/device_tests/test_msg_applysettings.py b/tests/device_tests/test_msg_applysettings.py index 1c4e544b1b..fea8ceeb20 100644 --- a/tests/device_tests/test_msg_applysettings.py +++ b/tests/device_tests/test_msg_applysettings.py @@ -26,6 +26,10 @@ EXPECTED_RESPONSES_NOPIN = [ messages.Features, ] EXPECTED_RESPONSES_PIN_T1 = [messages.PinMatrixRequest()] + EXPECTED_RESPONSES_NOPIN +EXPECTED_RESPONSES_PIN_TR = [ + messages.ButtonRequest(), + messages.ButtonRequest(), +] + EXPECTED_RESPONSES_NOPIN EXPECTED_RESPONSES_PIN_TT = [messages.ButtonRequest()] + EXPECTED_RESPONSES_NOPIN PIN4 = "1234" @@ -37,6 +41,8 @@ def _set_expected_responses(client: Client): client.use_pin_sequence([PIN4]) if client.features.model == "1": client.set_expected_responses(EXPECTED_RESPONSES_PIN_T1) + elif client.features.model == "R": + client.set_expected_responses(EXPECTED_RESPONSES_PIN_TR) else: client.set_expected_responses(EXPECTED_RESPONSES_PIN_TT) @@ -386,7 +392,10 @@ def test_experimental_features(client: Client): client.lock() with client: client.use_pin_sequence([PIN4]) - client.set_expected_responses([messages.ButtonRequest, messages.Nonce]) + tr = client.features.model == "R" + client.set_expected_responses( + [messages.ButtonRequest, (tr, messages.ButtonRequest), messages.Nonce] + ) experimental_call() diff --git a/tests/device_tests/test_msg_backup_device.py b/tests/device_tests/test_msg_backup_device.py index 0a7eabf16b..b9a0f387e9 100644 --- a/tests/device_tests/test_msg_backup_device.py +++ b/tests/device_tests/test_msg_backup_device.py @@ -42,7 +42,8 @@ def click_info_button(debug): @pytest.mark.skip_t1 # TODO we want this for t1 too @pytest.mark.setup_client(needs_backup=True, mnemonic=MNEMONIC12) def test_backup_bip39(client: Client): - pytest.fail("Freezes") + if client.features.model == "R": + pytest.skip("Freezes") assert client.features.needs_backup is True mnemonic = None diff --git a/tests/device_tests/test_msg_change_wipe_code_t2.py b/tests/device_tests/test_msg_change_wipe_code_t2.py index fe7e092c44..7ec3ba6fe8 100644 --- a/tests/device_tests/test_msg_change_wipe_code_t2.py +++ b/tests/device_tests/test_msg_change_wipe_code_t2.py @@ -33,11 +33,13 @@ def _check_wipe_code(client: Client, pin: str, wipe_code: str): client.init_device() assert client.features.wipe_code_protection is True + tr = client.features.model == "R" + # Try to change the PIN to the current wipe code value. The operation should fail. with client, pytest.raises(TrezorFailure): client.use_pin_sequence([pin, wipe_code, wipe_code]) client.set_expected_responses( - [messages.ButtonRequest()] * 5 + [messages.ButtonRequest()] * (7 if tr else 5) + [messages.Failure(code=messages.FailureType.PinInvalid)] ) device.change_pin(client) @@ -56,12 +58,15 @@ def test_set_remove_wipe_code(client: Client): # Test set wipe code. assert client.features.wipe_code_protection is None + tr = client.features.model == "R" + _ensure_unlocked(client, PIN4) assert client.features.wipe_code_protection is False with client: client.set_expected_responses( - [messages.ButtonRequest()] * 5 + [messages.Success, messages.Features] + [messages.ButtonRequest()] * (6 if tr else 5) + + [messages.Success, messages.Features] ) client.use_pin_sequence([PIN4, WIPE_CODE_MAX, WIPE_CODE_MAX]) device.change_wipe_code(client) @@ -73,7 +78,8 @@ def test_set_remove_wipe_code(client: Client): # Test change wipe code. with client: client.set_expected_responses( - [messages.ButtonRequest()] * 5 + [messages.Success, messages.Features] + [messages.ButtonRequest()] * (6 if tr else 5) + + [messages.Success, messages.Features] ) client.use_pin_sequence([PIN4, WIPE_CODE6, WIPE_CODE6]) device.change_wipe_code(client) @@ -85,7 +91,8 @@ def test_set_remove_wipe_code(client: Client): # Test remove wipe code. with client: client.set_expected_responses( - [messages.ButtonRequest()] * 3 + [messages.Success, messages.Features] + [messages.ButtonRequest()] * (4 if tr else 3) + + [messages.Success, messages.Features] ) client.use_pin_sequence([PIN4]) device.change_wipe_code(client, remove=True) @@ -125,9 +132,12 @@ def test_set_wipe_code_mismatch(client: Client): def test_set_wipe_code_to_pin(client: Client): _ensure_unlocked(client, PIN4) + tr = client.features.model == "R" + with client: client.set_expected_responses( - [messages.ButtonRequest()] * 6 + [messages.Success, messages.Features] + [messages.ButtonRequest()] * (7 if tr else 6) + + [messages.Success, messages.Features] ) client.use_pin_sequence([PIN4, PIN4, WIPE_CODE4, WIPE_CODE4]) device.change_wipe_code(client) @@ -138,6 +148,8 @@ def test_set_wipe_code_to_pin(client: Client): def test_set_pin_to_wipe_code(client: Client): + tr = client.features.model == "R" + # Set wipe code. with client: client.set_expected_responses( @@ -149,7 +161,7 @@ def test_set_pin_to_wipe_code(client: Client): # Try to set the PIN to the current wipe code value. with client, pytest.raises(TrezorFailure): client.set_expected_responses( - [messages.ButtonRequest()] * 4 + [messages.ButtonRequest()] * (6 if tr else 4) + [messages.Failure(code=messages.FailureType.PinInvalid)] ) client.use_pin_sequence([WIPE_CODE4, WIPE_CODE4]) diff --git a/tests/device_tests/test_msg_changepin_t2.py b/tests/device_tests/test_msg_changepin_t2.py index 053519c198..ee9b3c6a3a 100644 --- a/tests/device_tests/test_msg_changepin_t2.py +++ b/tests/device_tests/test_msg_changepin_t2.py @@ -33,9 +33,13 @@ def _check_pin(client: Client, pin): assert client.features.pin_protection is True assert client.features.unlocked is False + tr = client.features.model == "R" + with client: client.use_pin_sequence([pin]) - client.set_expected_responses([messages.ButtonRequest, messages.Address]) + client.set_expected_responses( + [messages.ButtonRequest, (tr, messages.ButtonRequest), messages.Address] + ) btc.get_address(client, "Testnet", PASSPHRASE_TEST_PATH) @@ -51,6 +55,8 @@ def _check_no_pin(client: Client): def test_set_pin(client: Client): assert client.features.pin_protection is False + tr = client.features.model == "R" + # Check that there's no PIN protection _check_no_pin(client) @@ -58,7 +64,8 @@ def test_set_pin(client: Client): with client: client.use_pin_sequence([PIN_MAX, PIN_MAX]) client.set_expected_responses( - [messages.ButtonRequest] * 4 + [messages.Success, messages.Features] + [messages.ButtonRequest] * (6 if tr else 4) + + [messages.Success, messages.Features] ) device.change_pin(client) @@ -71,6 +78,8 @@ def test_set_pin(client: Client): def test_change_pin(client: Client): assert client.features.pin_protection is True + tr = client.features.model == "R" + # Check current PIN value _check_pin(client, PIN4) @@ -78,7 +87,8 @@ def test_change_pin(client: Client): with client: client.use_pin_sequence([PIN4, PIN_MAX, PIN_MAX]) client.set_expected_responses( - [messages.ButtonRequest] * 5 + [messages.Success, messages.Features] + [messages.ButtonRequest] * (7 if tr else 5) + + [messages.Success, messages.Features] ) device.change_pin(client) @@ -93,6 +103,8 @@ def test_change_pin(client: Client): def test_remove_pin(client: Client): assert client.features.pin_protection is True + tr = client.features.model == "R" + # Check current PIN value _check_pin(client, PIN4) @@ -100,7 +112,8 @@ def test_remove_pin(client: Client): with client: client.use_pin_sequence([PIN4]) client.set_expected_responses( - [messages.ButtonRequest] * 3 + [messages.Success, messages.Features] + [messages.ButtonRequest] * (4 if tr else 3) + + [messages.Success, messages.Features] ) device.change_pin(client, remove=True) @@ -145,11 +158,13 @@ def test_set_failed(client: Client): def test_change_failed(client: Client): assert client.features.pin_protection is True + tr = client.features.model == "R" + # Check current PIN value _check_pin(client, PIN4) # Let's set new PIN - def input_flow(): + def input_flow_tt(): yield # do you want to change pin? client.debug.press_yes() yield # enter current pin @@ -163,9 +178,28 @@ def test_change_failed(client: Client): yield # enter current pin again client.cancel() + # Let's set new PIN + def input_flow_tr(): + yield # do you want to change pin? + client.debug.press_yes() + yield # Enter old PIN? + client.debug.press_yes() + yield # enter current pin + client.debug.input(PIN4) + yield # enter new pin + client.debug.input("457891") + yield # enter new pin again (but different) + client.debug.input("381847") + + # failed retry + yield # enter current pin again + client.cancel() + with client, pytest.raises(Cancelled): - client.set_expected_responses([messages.ButtonRequest] * 5 + [messages.Failure]) - client.set_input_flow(input_flow) + client.set_expected_responses( + [messages.ButtonRequest] * (6 if tr else 5) + [messages.Failure] + ) + client.set_input_flow(input_flow_tr if tr else input_flow_tt) device.change_pin(client) diff --git a/tests/device_tests/test_pin.py b/tests/device_tests/test_pin.py index abe4d99ce5..e32c4a4001 100644 --- a/tests/device_tests/test_pin.py +++ b/tests/device_tests/test_pin.py @@ -42,17 +42,21 @@ def test_correct_pin(client: Client): client.use_pin_sequence([PIN4]) # Expected responses differ between T1 and TT is_t1 = client.features.model == "1" + is_tr = client.features.model == "R" client.set_expected_responses( [ (is_t1, messages.PinMatrixRequest), ( - not is_t1, + is_tr, + messages.ButtonRequest(code=messages.ButtonRequestType.Other), + ), + ( + not is_t1 or is_tr, messages.ButtonRequest(code=messages.ButtonRequestType.PinEntry), ), messages.Address, ] ) - # client.set_expected_responses([messages.ButtonRequest, messages.Address]) get_test_address(client) @@ -68,10 +72,13 @@ def test_incorrect_pin_t1(client: Client): def test_incorrect_pin_t2(client: Client): with client: # After first incorrect attempt, TT will not raise an error, but instead ask for another attempt + is_tr = client.features.model == "R" client.use_pin_sequence([BAD_PIN, PIN4]) client.set_expected_responses( [ + (is_tr, messages.ButtonRequest(code=messages.ButtonRequestType.Other)), messages.ButtonRequest(code=messages.ButtonRequestType.PinEntry), + (is_tr, messages.ButtonRequest(code=messages.ButtonRequestType.Other)), messages.ButtonRequest(code=messages.ButtonRequestType.PinEntry), messages.Address, ] @@ -99,7 +106,7 @@ def test_exponential_backoff_t1(client: Client): @pytest.mark.skip_t1 def test_exponential_backoff_t2(client: Client): - def input_flow(): + def input_flow_tt(): """Inputting some bad PINs and finally the correct one""" yield # PIN entry for attempt in range(3): @@ -109,6 +116,21 @@ def test_exponential_backoff_t2(client: Client): _check_backoff_time(attempt, start) client.debug.input(PIN4) + def input_flow_tr(): + """Inputting some bad PINs and finally the correct one""" + yield # Enter your PIN + client.debug.press_yes() + yield # PIN entry + for attempt in range(3): + start = time.time() + client.debug.input(BAD_PIN) + yield # PIN entry + client.debug.press_yes() + yield # Wrong PIN, enter again + _check_backoff_time(attempt, start) + client.debug.input(PIN4) + with client: - client.set_input_flow(input_flow) + tr = client.features.model == "R" + client.set_input_flow(input_flow_tr if tr else input_flow_tt) get_test_address(client) diff --git a/tests/device_tests/test_protection_levels.py b/tests/device_tests/test_protection_levels.py index 9db9f60669..89bc943121 100644 --- a/tests/device_tests/test_protection_levels.py +++ b/tests/device_tests/test_protection_levels.py @@ -44,12 +44,17 @@ PIN4 = "1234" pytestmark = pytest.mark.setup_client(pin=PIN4, passphrase=True) -def _pin_request(client: Client): - """Get appropriate PIN request for each model""" +def _pin_requests(client: Client) -> list: + """Get appropriate PIN requests for each model""" if client.features.model == "1": - return messages.PinMatrixRequest + return [messages.PinMatrixRequest] + elif client.features.model == "R": + return [ + messages.ButtonRequest(code=B.Other), + messages.ButtonRequest(code=B.PinEntry), + ] else: - return messages.ButtonRequest(code=B.PinEntry) + return [messages.ButtonRequest(code=B.PinEntry)] def _assert_protection( @@ -103,7 +108,7 @@ def test_apply_settings(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - _pin_request(client), + *_pin_requests(client), messages.ButtonRequest, messages.Success, messages.Features, @@ -121,9 +126,9 @@ def test_change_pin_t1(client: Client): client.set_expected_responses( [ messages.ButtonRequest, - _pin_request(client), - _pin_request(client), - _pin_request(client), + *_pin_requests(client), + *_pin_requests(client), + *_pin_requests(client), messages.Success, messages.Features, ] @@ -138,11 +143,11 @@ def test_change_pin_t2(client: Client): client.use_pin_sequence([PIN4, PIN4, PIN4, PIN4]) client.set_expected_responses( [ - _pin_request(client), + *_pin_requests(client), messages.ButtonRequest, - _pin_request(client), - _pin_request(client), - _pin_request(client), + *_pin_requests(client), + messages.ButtonRequest(code=B.PinEntry), + *_pin_requests(client), messages.ButtonRequest, messages.Success, messages.Features, @@ -165,7 +170,7 @@ def test_get_entropy(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - _pin_request(client), + *_pin_requests(client), messages.ButtonRequest(code=B.ProtectCall), messages.Entropy, ] @@ -179,7 +184,7 @@ def test_get_public_key(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - _pin_request(client), + *_pin_requests(client), messages.PassphraseRequest, messages.PublicKey, ] @@ -193,7 +198,7 @@ def test_get_address(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - _pin_request(client), + *_pin_requests(client), messages.PassphraseRequest, messages.Address, ] @@ -288,7 +293,7 @@ def test_sign_message(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - _pin_request(client), + *_pin_requests(client), messages.PassphraseRequest, messages.ButtonRequest, messages.ButtonRequest, @@ -331,7 +336,7 @@ def test_verify_message_t2(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - _pin_request(client), + *_pin_requests(client), messages.ButtonRequest, messages.ButtonRequest, messages.ButtonRequest, @@ -371,7 +376,7 @@ def test_signtx(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - _pin_request(client), + *_pin_requests(client), messages.PassphraseRequest, request_input(0), request_output(0), @@ -407,7 +412,7 @@ def test_unlocked(client: Client): _assert_protection(client, passphrase=False) with client: client.use_pin_sequence([PIN4]) - client.set_expected_responses([_pin_request(client), messages.Address]) + client.set_expected_responses([*_pin_requests(client), messages.Address]) get_test_address(client) client.init_device() diff --git a/tests/device_tests/test_session.py b/tests/device_tests/test_session.py index 03c91332e3..265ff85c4b 100644 --- a/tests/device_tests/test_session.py +++ b/tests/device_tests/test_session.py @@ -35,6 +35,7 @@ def test_clear_session(client: Client): is_trezor1 = client.features.model == "1" init_responses = [ messages.PinMatrixRequest if is_trezor1 else messages.ButtonRequest, + (client.features.model == "R", messages.ButtonRequest), messages.PassphraseRequest, ]