diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index 70146d4c57..4264d71378 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -1316,7 +1316,7 @@ async def confirm_pin_action( br_type: str, title: str, action: str | None, - description: str | None, + description: str | None = "Do you really want to", br_code: ButtonRequestType = ButtonRequestType.Other, ) -> None: return await confirm_action( 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 03fbe1291e..d1f3611aee 100644 --- a/tests/device_tests/reset_recovery/test_recovery_bip39_dryrun.py +++ b/tests/device_tests/reset_recovery/test_recovery_bip39_dryrun.py @@ -226,7 +226,7 @@ def test_invalid_seed_core(client: Client): yield layout = client.debug.wait_layout() assert "WORD ENTERING" in layout.text - client.debug.press_right() + client.debug.press_yes() yield for _ in range(12): diff --git a/tests/device_tests/test_autolock.py b/tests/device_tests/test_autolock.py index 1a4c7a741c..9b37b74c3f 100644 --- a/tests/device_tests/test_autolock.py +++ b/tests/device_tests/test_autolock.py @@ -44,7 +44,6 @@ def set_autolock_delay(client: Client, delay): [ pin_request(client), messages.ButtonRequest, - (client.features.model == "R", messages.ButtonRequest), messages.Success, messages.Features, ] @@ -64,13 +63,7 @@ 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), - (client.features.model == "R", messages.ButtonRequest), - messages.Address, - ] - ) + client.set_expected_responses([pin_request(client), messages.Address]) get_test_address(client) @@ -109,7 +102,6 @@ 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 fea8ceeb20..1c4e544b1b 100644 --- a/tests/device_tests/test_msg_applysettings.py +++ b/tests/device_tests/test_msg_applysettings.py @@ -26,10 +26,6 @@ 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" @@ -41,8 +37,6 @@ 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) @@ -392,10 +386,7 @@ def test_experimental_features(client: Client): client.lock() with client: client.use_pin_sequence([PIN4]) - tr = client.features.model == "R" - client.set_expected_responses( - [messages.ButtonRequest, (tr, messages.ButtonRequest), messages.Nonce] - ) + client.set_expected_responses([messages.ButtonRequest, messages.Nonce]) experimental_call() 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 7ec3ba6fe8..8b9f46ac62 100644 --- a/tests/device_tests/test_msg_change_wipe_code_t2.py +++ b/tests/device_tests/test_msg_change_wipe_code_t2.py @@ -33,13 +33,11 @@ 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()] * (7 if tr else 5) + [messages.ButtonRequest()] * 6 + [messages.Failure(code=messages.FailureType.PinInvalid)] ) device.change_pin(client) @@ -58,15 +56,12 @@ 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()] * (6 if tr else 5) - + [messages.Success, messages.Features] + [messages.ButtonRequest()] * 6 + [messages.Success, messages.Features] ) client.use_pin_sequence([PIN4, WIPE_CODE_MAX, WIPE_CODE_MAX]) device.change_wipe_code(client) @@ -78,8 +73,7 @@ def test_set_remove_wipe_code(client: Client): # Test change wipe code. with client: client.set_expected_responses( - [messages.ButtonRequest()] * (6 if tr else 5) - + [messages.Success, messages.Features] + [messages.ButtonRequest()] * 5 + [messages.Success, messages.Features] ) client.use_pin_sequence([PIN4, WIPE_CODE6, WIPE_CODE6]) device.change_wipe_code(client) @@ -91,8 +85,7 @@ def test_set_remove_wipe_code(client: Client): # Test remove wipe code. with client: client.set_expected_responses( - [messages.ButtonRequest()] * (4 if tr else 3) - + [messages.Success, messages.Features] + [messages.ButtonRequest()] * 3 + [messages.Success, messages.Features] ) client.use_pin_sequence([PIN4]) device.change_wipe_code(client, remove=True) @@ -132,12 +125,9 @@ 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()] * (7 if tr else 6) - + [messages.Success, messages.Features] + [messages.ButtonRequest()] * 7 + [messages.Success, messages.Features] ) client.use_pin_sequence([PIN4, PIN4, WIPE_CODE4, WIPE_CODE4]) device.change_wipe_code(client) @@ -148,12 +138,10 @@ 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( - [messages.ButtonRequest()] * 4 + [messages.Success, messages.Features] + [messages.ButtonRequest()] * 5 + [messages.Success, messages.Features] ) client.use_pin_sequence([WIPE_CODE4, WIPE_CODE4]) device.change_wipe_code(client) @@ -161,7 +149,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()] * (6 if tr else 4) + [messages.ButtonRequest()] * 6 + [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 ee9b3c6a3a..cf520d149d 100644 --- a/tests/device_tests/test_msg_changepin_t2.py +++ b/tests/device_tests/test_msg_changepin_t2.py @@ -33,13 +33,9 @@ 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, (tr, messages.ButtonRequest), messages.Address] - ) + client.set_expected_responses([messages.ButtonRequest, messages.Address]) btc.get_address(client, "Testnet", PASSPHRASE_TEST_PATH) @@ -55,8 +51,6 @@ 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) @@ -64,8 +58,7 @@ def test_set_pin(client: Client): with client: client.use_pin_sequence([PIN_MAX, PIN_MAX]) client.set_expected_responses( - [messages.ButtonRequest] * (6 if tr else 4) - + [messages.Success, messages.Features] + [messages.ButtonRequest] * 6 + [messages.Success, messages.Features] ) device.change_pin(client) @@ -78,8 +71,6 @@ 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) @@ -87,8 +78,7 @@ def test_change_pin(client: Client): with client: client.use_pin_sequence([PIN4, PIN_MAX, PIN_MAX]) client.set_expected_responses( - [messages.ButtonRequest] * (7 if tr else 5) - + [messages.Success, messages.Features] + [messages.ButtonRequest] * 6 + [messages.Success, messages.Features] ) device.change_pin(client) @@ -103,8 +93,6 @@ 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) @@ -112,8 +100,7 @@ def test_remove_pin(client: Client): with client: client.use_pin_sequence([PIN4]) client.set_expected_responses( - [messages.ButtonRequest] * (4 if tr else 3) - + [messages.Success, messages.Features] + [messages.ButtonRequest] * 3 + [messages.Success, messages.Features] ) device.change_pin(client, remove=True) @@ -158,13 +145,11 @@ 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_tt(): + def input_flow(): yield # do you want to change pin? client.debug.press_yes() yield # enter current pin @@ -178,28 +163,9 @@ 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] * (6 if tr else 5) + [messages.Failure] - ) - client.set_input_flow(input_flow_tr if tr else input_flow_tt) + client.set_expected_responses([messages.ButtonRequest] * 5 + [messages.Failure]) + client.set_input_flow(input_flow) device.change_pin(client) diff --git a/tests/device_tests/test_pin.py b/tests/device_tests/test_pin.py index e32c4a4001..abe4d99ce5 100644 --- a/tests/device_tests/test_pin.py +++ b/tests/device_tests/test_pin.py @@ -42,21 +42,17 @@ 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), ( - is_tr, - messages.ButtonRequest(code=messages.ButtonRequestType.Other), - ), - ( - not is_t1 or is_tr, + not is_t1, messages.ButtonRequest(code=messages.ButtonRequestType.PinEntry), ), messages.Address, ] ) + # client.set_expected_responses([messages.ButtonRequest, messages.Address]) get_test_address(client) @@ -72,13 +68,10 @@ 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, ] @@ -106,7 +99,7 @@ def test_exponential_backoff_t1(client: Client): @pytest.mark.skip_t1 def test_exponential_backoff_t2(client: Client): - def input_flow_tt(): + def input_flow(): """Inputting some bad PINs and finally the correct one""" yield # PIN entry for attempt in range(3): @@ -116,21 +109,6 @@ 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: - tr = client.features.model == "R" - client.set_input_flow(input_flow_tr if tr else input_flow_tt) + client.set_input_flow(input_flow) get_test_address(client) diff --git a/tests/device_tests/test_protection_levels.py b/tests/device_tests/test_protection_levels.py index 89bc943121..c38d15281d 100644 --- a/tests/device_tests/test_protection_levels.py +++ b/tests/device_tests/test_protection_levels.py @@ -44,17 +44,12 @@ PIN4 = "1234" pytestmark = pytest.mark.setup_client(pin=PIN4, passphrase=True) -def _pin_requests(client: Client) -> list: - """Get appropriate PIN requests for each model""" +def _pin_request(client: Client): + """Get appropriate PIN request for each model""" if client.features.model == "1": - return [messages.PinMatrixRequest] - elif client.features.model == "R": - return [ - messages.ButtonRequest(code=B.Other), - messages.ButtonRequest(code=B.PinEntry), - ] + return messages.PinMatrixRequest else: - return [messages.ButtonRequest(code=B.PinEntry)] + return messages.ButtonRequest(code=B.PinEntry) def _assert_protection( @@ -108,7 +103,7 @@ def test_apply_settings(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - *_pin_requests(client), + _pin_request(client), messages.ButtonRequest, messages.Success, messages.Features, @@ -126,9 +121,9 @@ def test_change_pin_t1(client: Client): client.set_expected_responses( [ messages.ButtonRequest, - *_pin_requests(client), - *_pin_requests(client), - *_pin_requests(client), + _pin_request(client), + _pin_request(client), + _pin_request(client), messages.Success, messages.Features, ] @@ -143,11 +138,12 @@ def test_change_pin_t2(client: Client): client.use_pin_sequence([PIN4, PIN4, PIN4, PIN4]) client.set_expected_responses( [ - *_pin_requests(client), + _pin_request(client), messages.ButtonRequest, - *_pin_requests(client), - messages.ButtonRequest(code=B.PinEntry), - *_pin_requests(client), + _pin_request(client), + _pin_request(client), + messages.ButtonRequest, + _pin_request(client), messages.ButtonRequest, messages.Success, messages.Features, @@ -170,7 +166,7 @@ def test_get_entropy(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - *_pin_requests(client), + _pin_request(client), messages.ButtonRequest(code=B.ProtectCall), messages.Entropy, ] @@ -184,7 +180,7 @@ def test_get_public_key(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - *_pin_requests(client), + _pin_request(client), messages.PassphraseRequest, messages.PublicKey, ] @@ -198,7 +194,7 @@ def test_get_address(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - *_pin_requests(client), + _pin_request(client), messages.PassphraseRequest, messages.Address, ] @@ -293,7 +289,7 @@ def test_sign_message(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - *_pin_requests(client), + _pin_request(client), messages.PassphraseRequest, messages.ButtonRequest, messages.ButtonRequest, @@ -336,7 +332,7 @@ def test_verify_message_t2(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - *_pin_requests(client), + _pin_request(client), messages.ButtonRequest, messages.ButtonRequest, messages.ButtonRequest, @@ -376,7 +372,7 @@ def test_signtx(client: Client): client.use_pin_sequence([PIN4]) client.set_expected_responses( [ - *_pin_requests(client), + _pin_request(client), messages.PassphraseRequest, request_input(0), request_output(0), @@ -412,7 +408,7 @@ def test_unlocked(client: Client): _assert_protection(client, passphrase=False) with client: client.use_pin_sequence([PIN4]) - client.set_expected_responses([*_pin_requests(client), messages.Address]) + client.set_expected_responses([_pin_request(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 265ff85c4b..03c91332e3 100644 --- a/tests/device_tests/test_session.py +++ b/tests/device_tests/test_session.py @@ -35,7 +35,6 @@ 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, ]