From b88e57a7c8a39e601b6d64f58ee44a4c66e27536 Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Thu, 3 Feb 2022 13:16:26 +0100 Subject: [PATCH] tests: Fix device tests for path checks in GetAddress. --- .../reset_recovery/test_recovery_bip39_t1.py | 5 +++-- .../device_tests/reset_recovery/test_reset_bip39_t1.py | 5 +++-- tests/device_tests/test_bip32_speed.py | 10 +++++++++- tests/device_tests/test_debuglink.py | 3 ++- tests/device_tests/test_msg_change_wipe_code_t1.py | 3 ++- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/device_tests/reset_recovery/test_recovery_bip39_t1.py b/tests/device_tests/reset_recovery/test_recovery_bip39_t1.py index 1798bba39..c5aa1da76 100644 --- a/tests/device_tests/reset_recovery/test_recovery_bip39_t1.py +++ b/tests/device_tests/reset_recovery/test_recovery_bip39_t1.py @@ -18,6 +18,7 @@ import pytest from trezorlib import device, messages from trezorlib.debuglink import TrezorClientDebugLink as Client +from trezorlib.tools import parse_path from ...common import MNEMONIC12 @@ -84,7 +85,7 @@ def test_pin_passphrase(client: Client): assert client.features.passphrase_protection is True # Do passphrase-protected action, PassphraseRequest should be raised - resp = client.call_raw(messages.GetAddress()) + resp = client.call_raw(messages.GetAddress(address_n=parse_path("m/44'/0'/0'/0/0"))) assert isinstance(resp, messages.PassphraseRequest) client.call_raw(messages.Cancel()) @@ -135,7 +136,7 @@ def test_nopin_nopassphrase(client: Client): assert client.features.passphrase_protection is False # Do pin & passphrase-protected action, PassphraseRequest should NOT be raised - resp = client.call_raw(messages.GetAddress()) + resp = client.call_raw(messages.GetAddress(address_n=parse_path("m/44'/0'/0'/0/0"))) assert isinstance(resp, messages.Address) diff --git a/tests/device_tests/reset_recovery/test_reset_bip39_t1.py b/tests/device_tests/reset_recovery/test_reset_bip39_t1.py index 95269f2ff..929c0f5da 100644 --- a/tests/device_tests/reset_recovery/test_reset_bip39_t1.py +++ b/tests/device_tests/reset_recovery/test_reset_bip39_t1.py @@ -19,6 +19,7 @@ from mnemonic import Mnemonic from trezorlib import device, messages from trezorlib.debuglink import TrezorClientDebugLink as Client +from trezorlib.tools import parse_path from ...common import generate_entropy @@ -87,7 +88,7 @@ def reset_device(client: Client, strength): assert resp.passphrase_protection is False # Do pin & passphrase-protected action, PassphraseRequest should NOT be raised - resp = client.call_raw(messages.GetAddress()) + resp = client.call_raw(messages.GetAddress(address_n=parse_path("m/44'/0'/0'/0/0"))) assert isinstance(resp, messages.Address) @@ -186,7 +187,7 @@ def test_reset_device_256_pin(client: Client): assert resp.passphrase_protection is True # Do passphrase-protected action, PassphraseRequest should be raised - resp = client.call_raw(messages.GetAddress()) + resp = client.call_raw(messages.GetAddress(address_n=parse_path("m/44'/0'/0'/0/0"))) assert isinstance(resp, messages.PassphraseRequest) client.call_raw(messages.Cancel()) diff --git a/tests/device_tests/test_bip32_speed.py b/tests/device_tests/test_bip32_speed.py index f6c9376f0..6043e0be6 100644 --- a/tests/device_tests/test_bip32_speed.py +++ b/tests/device_tests/test_bip32_speed.py @@ -18,8 +18,9 @@ import time import pytest -from trezorlib import btc +from trezorlib import btc, device from trezorlib.debuglink import TrezorClientDebugLink as Client +from trezorlib.messages import SafetyCheckLevel from trezorlib.tools import H_ pytestmark = [ @@ -29,6 +30,8 @@ pytestmark = [ def test_public_ckd(client: Client): + # disable safety checks to access non-standard paths + device.apply_settings(client, safety_checks=SafetyCheckLevel.PromptTemporarily) btc.get_address(client, "Bitcoin", []) # to compute root node via BIP39 for depth in range(8): @@ -41,6 +44,8 @@ def test_public_ckd(client: Client): def test_private_ckd(client: Client): + # disable safety checks to access non-standard paths + device.apply_settings(client, safety_checks=SafetyCheckLevel.PromptTemporarily) btc.get_address(client, "Bitcoin", []) # to compute root node via BIP39 for depth in range(8): @@ -54,6 +59,9 @@ def test_private_ckd(client: Client): def test_cache(client: Client): + # disable safety checks to access non-standard paths + device.apply_settings(client, safety_checks=SafetyCheckLevel.PromptTemporarily) + start = time.time() for x in range(10): btc.get_address(client, "Bitcoin", [x, 2, 3, 4, 5, 6, 7, 8]) diff --git a/tests/device_tests/test_debuglink.py b/tests/device_tests/test_debuglink.py index bb1824eb7..d8ee68d7a 100644 --- a/tests/device_tests/test_debuglink.py +++ b/tests/device_tests/test_debuglink.py @@ -18,6 +18,7 @@ import pytest from trezorlib import debuglink, device, messages, misc from trezorlib.debuglink import TrezorClientDebugLink as Client +from trezorlib.tools import parse_path from trezorlib.transport import udp from ..common import MNEMONIC12 @@ -40,7 +41,7 @@ def test_mnemonic(client: Client): @pytest.mark.skip_t2 @pytest.mark.setup_client(mnemonic=MNEMONIC12, pin="1234", passphrase="") def test_pin(client: Client): - resp = client.call_raw(messages.GetAddress()) + resp = client.call_raw(messages.GetAddress(address_n=parse_path("m/44'/0'/0'/0/0"))) assert isinstance(resp, messages.PinMatrixRequest) state = client.debug.state() diff --git a/tests/device_tests/test_msg_change_wipe_code_t1.py b/tests/device_tests/test_msg_change_wipe_code_t1.py index 4d6b0a6c4..45e7ba167 100644 --- a/tests/device_tests/test_msg_change_wipe_code_t1.py +++ b/tests/device_tests/test_msg_change_wipe_code_t1.py @@ -19,6 +19,7 @@ import pytest from trezorlib import device, exceptions, messages from trezorlib.client import MAX_PIN_LENGTH from trezorlib.debuglink import TrezorClientDebugLink as Client +from trezorlib.tools import parse_path PinType = messages.PinMatrixRequestType @@ -177,7 +178,7 @@ def test_set_pin_to_wipe_code(client: Client): # Check that there is no PIN protection. client.init_device() assert client.features.pin_protection is False - resp = client.call_raw(messages.GetAddress()) + resp = client.call_raw(messages.GetAddress(address_n=parse_path("m/44'/0'/0'/0/0"))) assert isinstance(resp, messages.Address)