diff --git a/tests/device_tests/test_cancel.py b/tests/device_tests/test_cancel.py index 06cb39cde7..d111950632 100644 --- a/tests/device_tests/test_cancel.py +++ b/tests/device_tests/test_cancel.py @@ -58,6 +58,7 @@ def test_cancel_message_via_cancel(session: Session, message): ), ], ) +@pytest.mark.protocol("protocol_v1") def test_cancel_message_via_initialize(session: Session, message): resp = session.call_raw(message) assert isinstance(resp, m.ButtonRequest) diff --git a/tests/device_tests/test_debuglink.py b/tests/device_tests/test_debuglink.py index b844ac0371..64ebda86db 100644 --- a/tests/device_tests/test_debuglink.py +++ b/tests/device_tests/test_debuglink.py @@ -17,6 +17,7 @@ import pytest from trezorlib import debuglink, device, messages, misc +from trezorlib.client import ProtocolVersion from trezorlib.debuglink import SessionDebugWrapper as Session from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.tools import parse_path @@ -62,6 +63,8 @@ def test_pin(session: Session): @pytest.mark.models("core") def test_softlock_instability(session: Session): + if session.protocol_version == ProtocolVersion.PROTOCOL_V2: + raise Exception("THIS NEEDS TO BE CHANGED FOR THP") def load_device(): debuglink.load_device( diff --git a/tests/device_tests/test_msg_applysettings.py b/tests/device_tests/test_msg_applysettings.py index 5fc3684fbb..0c979bf5e6 100644 --- a/tests/device_tests/test_msg_applysettings.py +++ b/tests/device_tests/test_msg_applysettings.py @@ -19,6 +19,7 @@ from pathlib import Path import pytest from trezorlib import btc, device, exceptions, messages, misc, models +from trezorlib.client import ProtocolVersion from trezorlib.debuglink import SessionDebugWrapper as Session from trezorlib.tools import parse_path @@ -205,6 +206,10 @@ def test_apply_homescreen_toif(session: Session): @pytest.mark.models(skip=["legacy", "safe3"]) def test_apply_homescreen_jpeg(session: Session): + if session.protocol_version is ProtocolVersion.PROTOCOL_V2: + raise Exception( + "FAILS BECAUSE THE MESSAGE IS BIGGER THAN THE INTERNAL READ BUFFER" + ) with open(HERE / "test_bg.jpg", "rb") as f: img = f.read() # raise Exception("FAILS FOR SOME REASON ") diff --git a/tests/device_tests/test_protection_levels.py b/tests/device_tests/test_protection_levels.py index 648b000e0a..fb1aba8f42 100644 --- a/tests/device_tests/test_protection_levels.py +++ b/tests/device_tests/test_protection_levels.py @@ -62,6 +62,8 @@ def _assert_protection( session.client.refresh_features() assert session.client.features.pin_protection is pin assert session.client.features.passphrase_protection is passphrase + if session.protocol_version == ProtocolVersion.PROTOCOL_V2: + new_session = session.client.get_session() session.lock() # session.end() if session.protocol_version == ProtocolVersion.PROTOCOL_V1: @@ -69,6 +71,7 @@ def _assert_protection( return new_session +@pytest.mark.protocol("protocol_v1") def test_initialize(session: Session): with session: session.client.use_pin_sequence([PIN4]) diff --git a/tests/device_tests/test_session.py b/tests/device_tests/test_session.py index 19cbfb2d95..e1853dcd86 100644 --- a/tests/device_tests/test_session.py +++ b/tests/device_tests/test_session.py @@ -30,6 +30,16 @@ XPUB = "xpub6BiVtCpG9fQPxnPmHXG8PhtzQdWC2Su4qWu6XW9tpWFYhxydCLJGrWBJZ5H6qTAHdPQ7 PIN4 = "1234" +@pytest.mark.protocol("protocol_v2") +def test_thp_end_session(client: Client): + session = client.get_session() + + msg = session.call(messages.EndSession()) + assert isinstance(msg, messages.Success) + with pytest.raises(TrezorFailure, match="ThpUnallocatedSession"): + session.call(messages.GetFeatures()) + + @pytest.mark.setup_client(pin=PIN4, passphrase="") def test_clear_session(client: Client): is_t1 = client.model is models.T1B1 diff --git a/tests/device_tests/test_session_id_and_passphrase.py b/tests/device_tests/test_session_id_and_passphrase.py index f710e7162e..3d472e5630 100644 --- a/tests/device_tests/test_session_id_and_passphrase.py +++ b/tests/device_tests/test_session_id_and_passphrase.py @@ -72,6 +72,7 @@ def _get_xpub( @pytest.mark.setup_client(passphrase=True) +@pytest.mark.protocol("protocol_v1") def test_session_with_passphrase(client: Client): session = client.get_session(passphrase="A") @@ -102,6 +103,7 @@ def test_session_with_passphrase(client: Client): @pytest.mark.setup_client(passphrase=True) +@pytest.mark.protocol("protocol_v1") def test_multiple_sessions(client: Client): # start SESSIONS_STORED sessions session_ids = [] @@ -144,6 +146,7 @@ def test_multiple_sessions(client: Client): @pytest.mark.setup_client(passphrase=True) +@pytest.mark.protocol("protocol_v1") def test_multiple_passphrases(client: Client): # start a session session_a = client.get_session(passphrase="A") @@ -180,6 +183,7 @@ def test_multiple_passphrases(client: Client): @pytest.mark.slow @pytest.mark.setup_client(passphrase=True) +@pytest.mark.protocol("protocol_v1") def test_max_sessions_with_passphrases(client: Client): # for the following tests, we are using as many passphrases as there are available sessions assert len(XPUB_PASSPHRASES) == SESSIONS_STORED @@ -225,6 +229,7 @@ def test_max_sessions_with_passphrases(client: Client): ) # passphrase is prompted +@pytest.mark.protocol("protocol_v1") def test_session_enable_passphrase(client: Client): # Let's start the communication by calling Initialize. session = client.get_session(passphrase="") @@ -251,6 +256,7 @@ def test_session_enable_passphrase(client: Client): @pytest.mark.models("core") @pytest.mark.setup_client(passphrase=True) +@pytest.mark.protocol("protocol_v1") def test_passphrase_on_device(client: Client): # _init_session(client) session = client.get_session(passphrase="A") @@ -290,6 +296,7 @@ def test_passphrase_on_device(client: Client): @pytest.mark.models("core") @pytest.mark.setup_client(passphrase=True) +@pytest.mark.protocol("protocol_v1") def test_passphrase_always_on_device(client: Client): # Let's start the communication by calling Initialize. session = client.get_session() @@ -325,6 +332,7 @@ def test_passphrase_always_on_device(client: Client): @pytest.mark.models("legacy") @pytest.mark.setup_client(passphrase="") +@pytest.mark.protocol("protocol_v1") def test_passphrase_on_device_not_possible_on_t1(session: Session): # This setting makes no sense on T1. response = session.call_raw( @@ -342,6 +350,7 @@ def test_passphrase_on_device_not_possible_on_t1(session: Session): @pytest.mark.setup_client(passphrase=True) +@pytest.mark.protocol("protocol_v1") def test_passphrase_ack_mismatch(session: Session): response = session.call_raw(XPUB_REQUEST) assert isinstance(response, messages.PassphraseRequest) @@ -351,6 +360,7 @@ def test_passphrase_ack_mismatch(session: Session): @pytest.mark.setup_client(passphrase="") +@pytest.mark.protocol("protocol_v1") def test_passphrase_missing(session: Session): response = session.call_raw(XPUB_REQUEST) assert isinstance(response, messages.PassphraseRequest) @@ -368,6 +378,7 @@ def test_passphrase_missing(session: Session): @pytest.mark.setup_client(passphrase=True) +@pytest.mark.protocol("protocol_v1") def test_passphrase_length(client: Client): def call(passphrase: str, expected_result: bool): session = client.get_session(passphrase=passphrase) @@ -393,6 +404,7 @@ def test_passphrase_length(client: Client): @pytest.mark.models("core") @pytest.mark.setup_client(passphrase=True) +@pytest.mark.protocol("protocol_v1") def test_hide_passphrase_from_host(client: Client): # Without safety checks, turning it on fails session = client.get_seedless_session() @@ -488,6 +500,7 @@ def _get_xpub_cardano(session: Session, expected_passphrase_req: bool = False): @pytest.mark.models("core") @pytest.mark.altcoin @pytest.mark.setup_client(passphrase=True) +@pytest.mark.protocol("protocol_v1") def test_cardano_passphrase(client: Client): # Cardano has a separate derivation method that needs to access the plaintext # of the passphrase.