diff --git a/tests/device_tests/test_msg_cardano_sign_tx_slip39_basic.py b/tests/device_tests/test_msg_cardano_sign_tx_slip39_basic.py index 2caff27f00..be0beec2b5 100644 --- a/tests/device_tests/test_msg_cardano_sign_tx_slip39_basic.py +++ b/tests/device_tests/test_msg_cardano_sign_tx_slip39_basic.py @@ -42,7 +42,12 @@ VALID_VECTORS = [ # ttl 10, # input flow - [[InputAction.SWIPE, InputAction.YES], [InputAction.SWIPE, InputAction.YES]], + [ + [InputAction.YES], + [InputAction.YES], + [InputAction.SWIPE, InputAction.YES], + [InputAction.SWIPE, InputAction.YES], + ], # tx hash "73e09bdebf98a9e0f17f86a2d11e0f14f4f8dae77cdf26ff1678e821f20c8db6", # serialized tx @@ -64,6 +69,8 @@ VALID_VECTORS = [ 10, # input flow [ + [InputAction.YES], + [InputAction.YES], [InputAction.SWIPE, InputAction.YES], [InputAction.YES], [InputAction.SWIPE, InputAction.YES], @@ -89,6 +96,8 @@ VALID_VECTORS = [ 10, # input flow [ + [InputAction.YES], + [InputAction.YES], [InputAction.SWIPE, InputAction.YES], [InputAction.YES], [InputAction.SWIPE, InputAction.YES], @@ -127,7 +136,9 @@ def test_cardano_sign_tx( withdrawals = [] metadata = bytes() - expected_responses = [messages.PassphraseRequest()] + expected_responses = [ + messages.PassphraseRequest(), + ] expected_responses += [ messages.ButtonRequest(code=messages.ButtonRequestType.Other) for i in range(len(input_flow_sequences)) diff --git a/tests/device_tests/test_session_id_and_passphrase.py b/tests/device_tests/test_session_id_and_passphrase.py index 47380a9934..6aefa9ffda 100644 --- a/tests/device_tests/test_session_id_and_passphrase.py +++ b/tests/device_tests/test_session_id_and_passphrase.py @@ -18,7 +18,7 @@ import random import pytest -from trezorlib import messages +from trezorlib import exceptions, messages from trezorlib.messages import FailureType from trezorlib.tools import parse_path @@ -53,12 +53,21 @@ def _init_session(client, session_id=None): def _get_xpub(client, passphrase=None): """Get XPUB and check that the appropriate passphrase flow has happened.""" - response = client.call_raw(XPUB_REQUEST) if passphrase is not None: - assert isinstance(response, messages.PassphraseRequest) - response = client.call_raw(messages.PassphraseAck(passphrase=passphrase)) - assert isinstance(response, messages.PublicKey) - return response.xpub + expected_responses = [ + messages.PassphraseRequest(), + messages.ButtonRequest(), + messages.ButtonRequest(), + messages.PublicKey(), + ] + else: + expected_responses = [messages.PublicKey()] + + with client: + client.use_passphrase(passphrase or "") + client.set_expected_responses(expected_responses) + result = client.call(XPUB_REQUEST) + return result.xpub @pytest.mark.skip_ui @@ -239,7 +248,9 @@ def test_passphrase_on_device(client): # try to get xpub with passphrase on host: response = client.call_raw(XPUB_REQUEST) assert isinstance(response, messages.PassphraseRequest) - response = client.call_raw(messages.PassphraseAck(passphrase="A", on_device=False)) + # using `client.call` to auto-skip subsequent ButtonRequests for "show passphrase" + response = client.call(messages.PassphraseAck(passphrase="A", on_device=False)) + assert isinstance(response, messages.PublicKey) assert response.xpub == XPUB_PASSPHRASES["A"] @@ -255,6 +266,7 @@ def test_passphrase_on_device(client): response = client.call_raw(XPUB_REQUEST) assert isinstance(response, messages.PassphraseRequest) response = client.call_raw(messages.PassphraseAck(on_device=True)) + # no "show passphrase" here assert isinstance(response, messages.ButtonRequest) client.debug.input("A") response = client.call_raw(messages.ButtonAck()) @@ -352,12 +364,13 @@ def test_passphrase_length(client): _init_session(client) response = client.call_raw(XPUB_REQUEST) assert isinstance(response, messages.PassphraseRequest) - response = client.call_raw(messages.PassphraseAck(passphrase)) - if expected_result: + try: + response = client.call(messages.PassphraseAck(passphrase)) + assert expected_result is True, "Call should have failed" assert isinstance(response, messages.PublicKey) - else: - assert isinstance(response, messages.Failure) - assert response.code == FailureType.DataError + except exceptions.TrezorFailure as e: + assert expected_result is False, "Call should have succeeded" + assert e.code == FailureType.DataError # 50 is ok call(passphrase="A" * 50, expected_result=True) @@ -374,7 +387,7 @@ def _get_xpub_cardano(client, passphrase): response = client.call_raw(msg) if passphrase is not None: assert isinstance(response, messages.PassphraseRequest) - response = client.call_raw(messages.PassphraseAck(passphrase=passphrase)) + response = client.call(messages.PassphraseAck(passphrase=passphrase)) assert isinstance(response, messages.CardanoPublicKey) return response.xpub diff --git a/tests/ui_tests/fixtures.json b/tests/ui_tests/fixtures.json index 2f2a130f4a..5c6c0241e3 100644 --- a/tests/ui_tests/fixtures.json +++ b/tests/ui_tests/fixtures.json @@ -90,9 +90,9 @@ "test_msg_cardano_sign_transaction.py::test_cardano_sign_tx_validation[764824073-1-inputs6-outputs6-4": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586", "test_msg_cardano_sign_transaction.py::test_cardano_sign_tx_validation[764824073-1-inputs7-outputs7-4": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586", "test_msg_cardano_sign_transaction.py::test_cardano_sign_tx_validation[764824073-1-inputs9-outputs9-4": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586", -"test_msg_cardano_sign_tx_slip39_basic.py::test_cardano_sign_tx[42-0-inputs2-outputs2-42-10-input_flo": "d488a0f2c127a675a1c2e2d410b6c4f402cdb610e19886a8998aa5ad786a779e", -"test_msg_cardano_sign_tx_slip39_basic.py::test_cardano_sign_tx[764824073-1-inputs0-outputs0-42-10-in": "6aa71de5007b0faf1eea4b1cfda1da6a739f852c0d875a1e59d83c03178c2f98", -"test_msg_cardano_sign_tx_slip39_basic.py::test_cardano_sign_tx[764824073-1-inputs1-outputs1-42-10-in": "7abf2e87a9b1e50afdf3502ba9480b07a59d59ccccf24915b46fb81285ae3fa8", +"test_msg_cardano_sign_tx_slip39_basic.py::test_cardano_sign_tx[42-0-inputs2-outputs2-42-10-input_flo": "4597efa8c2d34df7ab70c626a244d14b783fa7be1f88f213c2f9a39d726976e2", +"test_msg_cardano_sign_tx_slip39_basic.py::test_cardano_sign_tx[764824073-1-inputs0-outputs0-42-10-in": "623341dfed3aaca40284ec5b444fc768edc5af9c706d8c4e4f7a5e1e90343652", +"test_msg_cardano_sign_tx_slip39_basic.py::test_cardano_sign_tx[764824073-1-inputs1-outputs1-42-10-in": "0f79d964628581aae91593f7a1e7bf9b4748b900d7973e1b48a78382cc8f6c4e", "test_msg_change_wipe_code_t2.py::test_set_pin_to_wipe_code": "9e11b251c03ef09127da79d92f8483c4db438c7303328774790d45e3f6fb8c96", "test_msg_change_wipe_code_t2.py::test_set_remove_wipe_code": "d280ed129a2ea4781af9e35542aa31ecf63da75fc6812ed3bd05107809f836a4", "test_msg_change_wipe_code_t2.py::test_set_wipe_code_mismatch": "32c808f00bada2059f933f3515337e494c837bdf65e4ea918b457d1c9f4cb42a", @@ -194,10 +194,10 @@ "test_msg_lisk_verifymessage.py-test_verify": "45df85077b20182803b5c4363386c555845e070f3a8a019add99e34dad510a07", "test_msg_lisk_verifymessage.py-test_verify_long": "d7d0ae3402b9ca6c7b0e61164fa483c4ba9549d306780c98ae15edd2dde51285", "test_msg_loaddevice.py-test_load_device_1": "1c6db0d592b1d22b3c9fce3ddab8a9fd138f11d83e5d4e64431a02bf4ffed605", -"test_msg_loaddevice.py-test_load_device_2": "06426c64d246068fe80fea79b0afd06d3eac4545fbd711279b816c0fdbf1b794", +"test_msg_loaddevice.py-test_load_device_2": "dc13c8486d8a59c5062e19139d8b3cea4ece1a3bc93592be7dc226f83ba54477", "test_msg_loaddevice.py-test_load_device_slip39_advanced": "1c6db0d592b1d22b3c9fce3ddab8a9fd138f11d83e5d4e64431a02bf4ffed605", "test_msg_loaddevice.py-test_load_device_slip39_basic": "1c6db0d592b1d22b3c9fce3ddab8a9fd138f11d83e5d4e64431a02bf4ffed605", -"test_msg_loaddevice.py-test_load_device_utf": "dfac758aefbebd2594455986f86bb2c3b91c2428e15de6ed00f82145c0b54089", +"test_msg_loaddevice.py-test_load_device_utf": "ad7c162c76a13a161166aba78c461ad5525a9a5da846e8d99854248d521e6979", "test_msg_monero_getaddress.py-test_monero_getaddress": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586", "test_msg_monero_getwatchkey.py-test_monero_getwatchkey": "d77fa4d4322e145c41f1ce07526ff59f8b58d8854aeffaa5266e14cd572350e7", "test_msg_nem_getaddress.py-test_nem_getaddress": "e726f99401a20eb74c33d755cecea2a3f69b7ae5b541302677ee05f80f5aef19", @@ -417,10 +417,10 @@ "test_multisig_change.py-test_multisig_mismatch_change": "7cb243b20be31a587dced4aaaf782a2d8487595369dde66aacb1b9a76e89c4fe", "test_multisig_change.py-test_multisig_mismatch_inputs": "64741bd84c5394e719125c1fbe8c34ef866ac63ca24ee1299e4268c59a199466", "test_op_return.py-test_opreturn": "87907ef9c2f4ce30ac95ad7d0cb3eac66762756e4ace52147bc589d64277f3b1", -"test_passphrase_slip39_advanced.py::test_128bit_passphrase": "3a92115b6bfb2d53f2445a67c9c5df6b6b5ff97769de98e3fac9e1bf424c5669", -"test_passphrase_slip39_advanced.py::test_256bit_passphrase": "3a92115b6bfb2d53f2445a67c9c5df6b6b5ff97769de98e3fac9e1bf424c5669", -"test_passphrase_slip39_basic.py::test_2of5_passphrase": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0", -"test_passphrase_slip39_basic.py::test_3of6_passphrase": "612dad8ab8762162a186ec9279d7de0bdfc589c52b4e4f4eba0545a00f21c3f0", +"test_passphrase_slip39_advanced.py::test_128bit_passphrase": "4d8c7eea0bd6786a070880d94fe288294e570b8d357dd9bc01865a8acc39d143", +"test_passphrase_slip39_advanced.py::test_256bit_passphrase": "4d8c7eea0bd6786a070880d94fe288294e570b8d357dd9bc01865a8acc39d143", +"test_passphrase_slip39_basic.py::test_2of5_passphrase": "54091a6faba4ecc4e40db591bb8861d00464de34b38a31925202f5bc44e4c41c", +"test_passphrase_slip39_basic.py::test_3of6_passphrase": "54091a6faba4ecc4e40db591bb8861d00464de34b38a31925202f5bc44e4c41c", "test_reset_backup.py::test_skip_backup_manual[0-backup_flow_bip39]": "9c5cded50e6ebe51dc6ecdaa6b793da9ec5527df582acbdc189494b809ee9f47", "test_reset_backup.py::test_skip_backup_manual[1-backup_flow_slip39_basic]": "bf9ea5281234d622b39f388715dad86e95f0a0e1efbd3d4d6b60478a79edcc23", "test_reset_backup.py::test_skip_backup_manual[2-backup_flow_slip39_advanced]": "e3fb56f53d04edde94aa11e5eac1e2dc732bddcd39def3981e03cffcbef1a96c", diff --git a/tests/upgrade_tests/test_passphrase_consistency.py b/tests/upgrade_tests/test_passphrase_consistency.py index d8c46c5f15..17b2eada4e 100644 --- a/tests/upgrade_tests/test_passphrase_consistency.py +++ b/tests/upgrade_tests/test_passphrase_consistency.py @@ -68,9 +68,20 @@ def test_passphrase_works(emulator): messages.Deprecated_PassphraseStateRequest(), messages.Address(), ] + elif ( + emulator.client.features.model == "T" and emulator.client.version < (2, 3, 3) + ) or ( + emulator.client.features.model == "1" and emulator.client.version < (1, 9, 3) + ): + expected_responses = [ + messages.PassphraseRequest(), + messages.Address(), + ] else: expected_responses = [ messages.PassphraseRequest(), + messages.ButtonRequest(), + messages.ButtonRequest(), messages.Address(), ] @@ -96,9 +107,22 @@ def test_init_device(emulator): messages.Features(), messages.Address(), ] + elif ( + emulator.client.features.model == "T" and emulator.client.version < (2, 3, 3) + ) or ( + emulator.client.features.model == "1" and emulator.client.version < (1, 9, 3) + ): + expected_responses = [ + messages.PassphraseRequest(), + messages.Address(), + messages.Features(), + messages.Address(), + ] else: expected_responses = [ messages.PassphraseRequest(), + messages.ButtonRequest(), + messages.ButtonRequest(), messages.Address(), messages.Features(), messages.Address(),