tests: Fix device tests for path checks in GetAddress.

release/22.05
Andrew Kozlik 2 years ago committed by Martin Milata
parent abb5ab74e3
commit b88e57a7c8

@ -18,6 +18,7 @@ import pytest
from trezorlib import device, messages from trezorlib import device, messages
from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.tools import parse_path
from ...common import MNEMONIC12 from ...common import MNEMONIC12
@ -84,7 +85,7 @@ def test_pin_passphrase(client: Client):
assert client.features.passphrase_protection is True assert client.features.passphrase_protection is True
# Do passphrase-protected action, PassphraseRequest should be raised # 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) assert isinstance(resp, messages.PassphraseRequest)
client.call_raw(messages.Cancel()) client.call_raw(messages.Cancel())
@ -135,7 +136,7 @@ def test_nopin_nopassphrase(client: Client):
assert client.features.passphrase_protection is False assert client.features.passphrase_protection is False
# Do pin & passphrase-protected action, PassphraseRequest should NOT be raised # 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) assert isinstance(resp, messages.Address)

@ -19,6 +19,7 @@ from mnemonic import Mnemonic
from trezorlib import device, messages from trezorlib import device, messages
from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.tools import parse_path
from ...common import generate_entropy from ...common import generate_entropy
@ -87,7 +88,7 @@ def reset_device(client: Client, strength):
assert resp.passphrase_protection is False assert resp.passphrase_protection is False
# Do pin & passphrase-protected action, PassphraseRequest should NOT be raised # 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) assert isinstance(resp, messages.Address)
@ -186,7 +187,7 @@ def test_reset_device_256_pin(client: Client):
assert resp.passphrase_protection is True assert resp.passphrase_protection is True
# Do passphrase-protected action, PassphraseRequest should be raised # 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) assert isinstance(resp, messages.PassphraseRequest)
client.call_raw(messages.Cancel()) client.call_raw(messages.Cancel())

@ -18,8 +18,9 @@ import time
import pytest import pytest
from trezorlib import btc from trezorlib import btc, device
from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.messages import SafetyCheckLevel
from trezorlib.tools import H_ from trezorlib.tools import H_
pytestmark = [ pytestmark = [
@ -29,6 +30,8 @@ pytestmark = [
def test_public_ckd(client: Client): 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 btc.get_address(client, "Bitcoin", []) # to compute root node via BIP39
for depth in range(8): for depth in range(8):
@ -41,6 +44,8 @@ def test_public_ckd(client: Client):
def test_private_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 btc.get_address(client, "Bitcoin", []) # to compute root node via BIP39
for depth in range(8): for depth in range(8):
@ -54,6 +59,9 @@ def test_private_ckd(client: Client):
def test_cache(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() start = time.time()
for x in range(10): for x in range(10):
btc.get_address(client, "Bitcoin", [x, 2, 3, 4, 5, 6, 7, 8]) btc.get_address(client, "Bitcoin", [x, 2, 3, 4, 5, 6, 7, 8])

@ -18,6 +18,7 @@ import pytest
from trezorlib import debuglink, device, messages, misc from trezorlib import debuglink, device, messages, misc
from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.tools import parse_path
from trezorlib.transport import udp from trezorlib.transport import udp
from ..common import MNEMONIC12 from ..common import MNEMONIC12
@ -40,7 +41,7 @@ def test_mnemonic(client: Client):
@pytest.mark.skip_t2 @pytest.mark.skip_t2
@pytest.mark.setup_client(mnemonic=MNEMONIC12, pin="1234", passphrase="") @pytest.mark.setup_client(mnemonic=MNEMONIC12, pin="1234", passphrase="")
def test_pin(client: Client): 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) assert isinstance(resp, messages.PinMatrixRequest)
state = client.debug.state() state = client.debug.state()

@ -19,6 +19,7 @@ import pytest
from trezorlib import device, exceptions, messages from trezorlib import device, exceptions, messages
from trezorlib.client import MAX_PIN_LENGTH from trezorlib.client import MAX_PIN_LENGTH
from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.tools import parse_path
PinType = messages.PinMatrixRequestType PinType = messages.PinMatrixRequestType
@ -177,7 +178,7 @@ def test_set_pin_to_wipe_code(client: Client):
# Check that there is no PIN protection. # Check that there is no PIN protection.
client.init_device() client.init_device()
assert client.features.pin_protection is False 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) assert isinstance(resp, messages.Address)

Loading…
Cancel
Save