diff --git a/tests/device_tests/cardano/test_address_public_key.py b/tests/device_tests/cardano/test_address_public_key.py index 59d468eb1..ffb4d7092 100644 --- a/tests/device_tests/cardano/test_address_public_key.py +++ b/tests/device_tests/cardano/test_address_public_key.py @@ -22,6 +22,7 @@ from trezorlib.cardano import ( get_public_key, parse_optional_bytes, ) +from trezorlib.exceptions import TrezorFailure from trezorlib.messages import CardanoAddressType from trezorlib.tools import parse_path @@ -45,6 +46,8 @@ pytestmark = [ "cardano/get_reward_address.json", ) def test_cardano_get_address(client, parameters, result): + client.init_device(new_session=True, derive_cardano=True) + address = get_address( client, address_parameters=create_address_parameters( @@ -76,11 +79,24 @@ def test_cardano_get_address(client, parameters, result): @parametrize_using_common_fixtures( - "cardano/get_public_key.json", "cardano/get_public_key.slip39.json" + "cardano/get_public_key.json", + "cardano/get_public_key.slip39.json", ) def test_cardano_get_public_key(client, parameters, result): + client.init_device(new_session=True, derive_cardano=True) + key = get_public_key(client, parse_path(parameters["path"])) assert key.node.public_key.hex() == result["public_key"] assert key.node.chain_code.hex() == result["chain_code"] assert key.xpub == result["public_key"] + result["chain_code"] + + +def test_bad_session(client): + client.init_device(new_session=True) + with pytest.raises(TrezorFailure, match="not enabled"): + get_public_key(client, parse_path("m/1852'/1815'/0'")) + + client.init_device(new_session=True, derive_cardano=False) + with pytest.raises(TrezorFailure, match="not enabled"): + get_public_key(client, parse_path("m/1852'/1815'/0'")) diff --git a/tests/device_tests/cardano/test_get_native_script_hash.py b/tests/device_tests/cardano/test_get_native_script_hash.py index 7fdb537e0..28c451f03 100644 --- a/tests/device_tests/cardano/test_get_native_script_hash.py +++ b/tests/device_tests/cardano/test_get_native_script_hash.py @@ -32,6 +32,8 @@ pytestmark = [ "cardano/get_native_script_hash.json", ) def test_cardano_get_native_script_hash(client, parameters, result): + client.init_device(new_session=True, derive_cardano=True) + native_script_hash = get_native_script_hash( client, native_script=parse_native_script(parameters["native_script"]), diff --git a/tests/device_tests/cardano/test_sign_tx.py b/tests/device_tests/cardano/test_sign_tx.py index e73d4cde4..97e8e394d 100644 --- a/tests/device_tests/cardano/test_sign_tx.py +++ b/tests/device_tests/cardano/test_sign_tx.py @@ -35,6 +35,8 @@ pytestmark = [ "cardano/sign_tx.slip39.json", ) def test_cardano_sign_tx(client, parameters, result): + client.init_device(new_session=True, derive_cardano=True) + signing_mode = messages.CardanoTxSigningMode.__members__[parameters["signing_mode"]] inputs = [cardano.parse_input(i) for i in parameters["inputs"]] outputs = [cardano.parse_output(o) for o in parameters["outputs"]] @@ -80,6 +82,8 @@ def test_cardano_sign_tx(client, parameters, result): "cardano/sign_tx_stake_pool_registration.failed.json", ) def test_cardano_sign_tx_failed(client, parameters, result): + client.init_device(new_session=True, derive_cardano=True) + signing_mode = messages.CardanoTxSigningMode.__members__[parameters["signing_mode"]] inputs = [cardano.parse_input(i) for i in parameters["inputs"]] outputs = [cardano.parse_output(o) for o in parameters["outputs"]] diff --git a/tests/ui_tests/fixtures.json b/tests/ui_tests/fixtures.json index 381e44262..7902048e9 100644 --- a/tests/ui_tests/fixtures.json +++ b/tests/ui_tests/fixtures.json @@ -1,4 +1,5 @@ { +"cardano-test_address_public_key.py::test_bad_session": "c09de07fbbf1e047442180e2facb5482d06a1a428891b875b7dd93c9e4704ae1", "cardano-test_address_public_key.py::test_cardano_get_address[parameters0-result0]": "e3be7c64097574e795bad1852f3eb7b9d5c4577ed88a845329bacc7350338d74", "cardano-test_address_public_key.py::test_cardano_get_address[parameters1-result1]": "50b6d3e772e77d6f52c7883f89c3b5f196e43865982c6c5b5171a72546e68164", "cardano-test_address_public_key.py::test_cardano_get_address[parameters10-result10]": "31b0bb5d4ab8cbd5293cbdc8c44f722e5e39c1f633eaa1db2186cb138d88dd5c",