tests: improve setup_client to handle passphrase better

pull/388/head
matejcik 5 years ago committed by matejcik
parent 8f0a29645c
commit 22bd94d9ea

@ -21,7 +21,8 @@ import pytest
from trezorlib import debuglink, log
from trezorlib.debuglink import TrezorClientDebugLink
from trezorlib.device import wipe as wipe_device
from trezorlib.device import apply_settings, wipe as wipe_device
from trezorlib.messages.PassphraseSourceType import HOST as PASSPHRASE_ON_HOST
from trezorlib.transport import enumerate_devices, get_transport
TREZOR_VERSION = None
@ -83,7 +84,9 @@ def setup_client(mnemonic=None, pin="", passphrase=False):
label="test",
language="english",
)
return function(client, *args, **kwargs)
if TREZOR_VERSION > 1 and passphrase:
apply_settings(client, passphrase_source=PASSPHRASE_ON_HOST)
return function(*args, client=client, **kwargs)
return wrapper

@ -16,9 +16,7 @@
import pytest
from trezorlib import device
from trezorlib.cardano import get_address
from trezorlib.messages.PassphraseSourceType import HOST as PASSPHRASE_ON_HOST
from trezorlib.tools import parse_path
from .conftest import setup_client
@ -53,7 +51,6 @@ SLIP39_MNEMONIC = [
def test_cardano_get_address(client, path, expected_address):
# enter passphrase
assert client.debug.read_passphrase_protection() is True
device.apply_settings(client, passphrase_source=PASSPHRASE_ON_HOST)
client.set_passphrase("TREZOR")
address = get_address(client, parse_path(path))

@ -16,9 +16,7 @@
import pytest
from trezorlib import device
from trezorlib.cardano import get_public_key
from trezorlib.messages.PassphraseSourceType import HOST as PASSPHRASE_ON_HOST
from trezorlib.tools import parse_path
from .conftest import setup_client
@ -59,7 +57,6 @@ SLIP39_MNEMONIC = [
def test_cardano_get_public_key(client, path, public_key, chain_code):
# enter passphrase
assert client.debug.read_passphrase_protection() is True
device.apply_settings(client, passphrase_source=PASSPHRASE_ON_HOST)
client.set_passphrase("TREZOR")
key = get_public_key(client, parse_path(path))

@ -16,8 +16,7 @@
import pytest
from trezorlib import cardano, device, messages
from trezorlib.messages.PassphraseSourceType import HOST as PASSPHRASE_ON_HOST
from trezorlib import cardano, messages
from .conftest import setup_client
@ -139,7 +138,6 @@ def test_cardano_sign_tx(
]
def input_flow():
client.set_passphrase("TREZOR")
yield
client.debug.swipe_down()
client.debug.press_yes()
@ -147,7 +145,7 @@ def test_cardano_sign_tx(
client.debug.swipe_down()
client.debug.press_yes()
device.apply_settings(client, passphrase_source=PASSPHRASE_ON_HOST)
client.set_passphrase("TREZOR")
with client:
client.set_expected_responses(expected_responses)
client.set_input_flow(input_flow)

Loading…
Cancel
Save