tests: drop all explicit conftest references

pull/543/head
matejcik 5 years ago
parent 56f5f73550
commit e3ceef2af6

@ -20,15 +20,15 @@ import pytest
from trezorlib import device, messages as proto
from .conftest import TREZOR_VERSION
EXPECTED_RESPONSES_NOPIN = [proto.ButtonRequest(), proto.Success(), proto.Features()]
EXPECTED_RESPONSES_PIN = [proto.PinMatrixRequest()] + EXPECTED_RESPONSES_NOPIN
if TREZOR_VERSION == 1:
EXPECTED_RESPONSES = EXPECTED_RESPONSES_PIN
else:
EXPECTED_RESPONSES = EXPECTED_RESPONSES_NOPIN
def _set_expected_responses(client):
if client.features.model == "1":
client.set_expected_responses(EXPECTED_RESPONSES_PIN)
else:
client.set_expected_responses(EXPECTED_RESPONSES_NOPIN)
@pytest.mark.setup_client(pin=True)
@ -37,7 +37,7 @@ class TestMsgApplysettings:
assert client.features.label == "test"
with client:
client.set_expected_responses(EXPECTED_RESPONSES)
_set_expected_responses(client)
device.apply_settings(client, label="new label")
assert client.features.label == "new label"
@ -47,7 +47,7 @@ class TestMsgApplysettings:
assert client.features.language == "english"
with client:
client.set_expected_responses(EXPECTED_RESPONSES)
_set_expected_responses(client)
device.apply_settings(client, language="nonexistent")
assert client.features.language == "english"
@ -57,7 +57,7 @@ class TestMsgApplysettings:
assert client.features.passphrase_protection is False
with client:
client.set_expected_responses(EXPECTED_RESPONSES)
_set_expected_responses(client)
device.apply_settings(client, use_passphrase=True)
assert client.features.passphrase_protection is True
@ -79,7 +79,7 @@ class TestMsgApplysettings:
img = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\x04\x80\x00\x00\x00\x00\x00\x00\x00\x00\x04\x88\x02\x00\x00\x00\x02\x91\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x90@\x00\x11@\x00\x00\x00\x00\x00\x00\x08\x00\x10\x92\x12\x04\x00\x00\x05\x12D\x00\x00\x00\x00\x00 \x00\x00\x08\x00Q\x00\x00\x02\xc0\x00\x00\x00\x00\x00\x00\x00\x10\x02 \x01\x04J\x00)$\x00\x00\x00\x00\x80\x00\x00\x00\x00\x08\x10\xa1\x00\x00\x02\x81 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\tP\x00\x00\x00\x00\x00\x00 \x00\x00\xa0\x00\xa0R \x12\x84\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x08\x00\tP\x00\x00\x00\x00 \x00\x04 \x00\x80\x02\x00@\x02T\xc2 \x00\x00\x00\x00\x00\x00\x00\x10@\x00)\t@\n\xa0\x80\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x80@\x14\xa9H\x04\x00\x00\x88@\x00\x00\x00\x00\x00\x02\x02$\x00\x15B@\x00\nP\x00\x00\x00\x00\x00\x80\x00\x00\x91\x01UP\x00\x00 \x02\x00\x00\x00\x00\x00\x00\x02\x08@ Z\xa5 \x00\x00\x80\x00\x00\x00\x00\x00\x00\x08\xa1%\x14*\xa0\x00\x00\x02\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xaa\x91 \x00\x05E\x80\x00\x00\x00\x00\x00\x02*T\x05-D\x00\x00\x05 @\x00\x00\x00\x00\x00%@\x80\x11V\xa0\x88\x00\x05@\xb0\x00\x00\x00\x00\x00\x818$\x04\xabD \x00\x06\xa1T\x00\x00\x00\x00\x02\x03\xb8\x01R\xd5\x01\x00\x00\x05AP\x00\x00\x00\x00\x08\xadT\x00\x05j\xa4@\x00\x87ah\x00\x00\x00\x00\x02\x8d\xb8\x08\x00.\x01\x00\x00\x02\xa5\xa8\x10\x00\x00\x00*\xc1\xec \n\xaa\x88 \x02@\xf6\xd0\x02\x00\x00\x00\x0bB\xb6\x14@U"\x80\x00\x01{`\x00\x00\x00\x00M\xa3\xf8 \x15*\x00\x00\x00\x10n\xc0\x04\x00\x00\x02\x06\xc2\xa8)\x00\x96\x84\x80\x00\x00\x1b\x00\x00\x80@\x10\x87\xa7\xf0\x84\x10\xaa\x10\x00\x00D\x00\x00\x02 \x00\x8a\x06\xfa\xe0P\n-\x02@\x00\x12\x00\x00\x00\x00\x10@\x83\xdf\xa0\x00\x08\xaa@\x00\x00\x01H\x00\x05H\x04\x12\x01\xf7\x81P\x02T\t\x00\x00\x00 \x00\x00\x84\x10\x00\x00z\x00@)* \x00\x00\x01\n\xa0\x02 \x05\n\x00\x00\x05\x10\x84\xa8\x84\x80\x00\x00@\x14\x00\x92\x10\x80\x00\x04\x11@\tT\x00\x00\x00\x00\n@\x00\x08\x84@$\x00H\x00\x12Q\x02\x00\x00\x00\x00\x90\x02A\x12\xa8\n\xaa\x92\x10\x04\xa8\x10@\x00\x00\x04\x04\x00\x04I\x00\x04\x14H\x80"R\x01\x00\x00\x00!@\x00\x00$\xa0EB\x80\x08\x95hH\x00\x00\x00\x84\x10 \x05Z\x00\x00(\x00\x02\x00\xa1\x01\x00\x00\x04\x00@\x82\x00\xadH*\x92P\x00\xaaP\x00\x00\x00\x00\x11\x02\x01*\xad\x01\x00\x01\x01"\x11D\x08\x00\x00\x10\x80 \x00\x81W\x80J\x94\x04\x08\xa5 !\x00\x00\x00\x02\x00B*\xae\xa1\x00\x80\x10\x01\x08\xa4\x00\x00\x00\x00\x00\x84\x00\t[@"HA\x04E\x00\x84\x00\x00\x00\x10\x00\x01J\xd5\x82\x90\x02\x00!\x02\xa2\x00\x00\x00\x00\x00\x00\x00\x05~\xa0\x00 \x10\n)\x00\x11\x00\x00\x00\x00\x00\x00!U\x80\xa8\x88\x82\x80\x01\x00\x00\x00\x00\x00\x00H@\x11\xaa\xc0\x82\x00 *\n\x00\x00\x00\x00\x00\x00\x00\x00\n\xabb@ \x04\x00! \x84\x00\x00\x00\x00\x02@\xa5\x15A$\x04\x81(\n\x00\x00\x00\x00\x00\x00 \x01\x10\x02\xe0\x91\x02\x00\x00\x04\x00\x00\x00\x00\x00\x00\x01 \xa9\tQH@\x91 P\x00\x00\x00\x00\x00\x00\x08\x00\x00\xa0T\xa5\x00@\x80\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\xa2\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00 T\xa0\t\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00@\x02\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00*\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x10\x00\x00\x10\x02\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00@\x04\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x08@\x10\x00\x00\x00\x00'
with client:
client.set_expected_responses(EXPECTED_RESPONSES)
_set_expected_responses(client)
device.apply_settings(client, homescreen=img)
@pytest.mark.skip_t2

@ -20,7 +20,6 @@ from trezorlib import btc, messages as proto
from trezorlib.tools import H_, CallException, btc_hash, parse_path
from .common import MNEMONIC12
from .conftest import TREZOR_VERSION
from .tx_cache import tx_cache
TXHASH_157041 = bytes.fromhex(
@ -96,7 +95,7 @@ def check_sign_tx(
for i, inp in enumerate(inputs):
expected_responses.append(tx_request(t.TXINPUT, request_index=i))
if unknown_path and TREZOR_VERSION != 1:
if unknown_path and client.features.model != "1":
expected_responses.append(btn(b.UnknownDerivationPath))
expected_responses.append(tx_request(t.TXMETA, tx_hash=inp.prev_hash))
@ -716,7 +715,7 @@ class TestMsgSigntx:
)
assert exc.value.args[0] == proto.FailureType.ProcessError
if TREZOR_VERSION == 1:
if client.features.model == "1":
assert exc.value.args[1].endswith("Failed to compile input")
else:
assert exc.value.args[1].endswith(

@ -19,7 +19,6 @@ import pytest
from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path
from .conftest import TREZOR_VERSION
from .tx_cache import tx_cache
# KMD has no usable backends, use cached TX only
@ -67,7 +66,7 @@ class TestMsgSigntxKomodo:
),
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
]
if TREZOR_VERSION != 1: # extra screen for lock_time
if client.features.model != "1": # extra screen for lock_time
er += [proto.ButtonRequest(code=proto.ButtonRequestType.SignTx)]
er += [
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
@ -144,7 +143,7 @@ class TestMsgSigntxKomodo:
),
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
]
if TREZOR_VERSION != 1: # extra screen for lock_time
if client.features.model != "1": # extra screen for lock_time
er += [proto.ButtonRequest(code=proto.ButtonRequestType.SignTx)]
er += [
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),

@ -19,7 +19,6 @@ import pytest
from trezorlib import btc, messages as proto
from trezorlib.tools import H_, CallException, parse_path
from .conftest import TREZOR_VERSION
from .tx_cache import tx_cache
TX_API = tx_cache("Testnet")
@ -415,7 +414,7 @@ class TestMsgSigntxSegwit:
with pytest.raises(CallException) as exc:
btc.sign_tx(client, "Testnet", [inp1], [out1, out2], prev_txes=TX_API)
assert exc.value.args[0] == proto.FailureType.ProcessError
if TREZOR_VERSION == 1:
if client.features.model == "1":
assert exc.value.args[1].endswith("Failed to compile input")
else:
assert exc.value.args[1].endswith(

@ -20,7 +20,6 @@ from trezorlib import messages as proto, stellar
from trezorlib.tools import CallException, parse_path
from .common import MNEMONIC12
from .conftest import TREZOR_VERSION
@pytest.mark.altcoin
@ -48,7 +47,7 @@ class TestMsgStellarGetAddress:
with pytest.raises(CallException) as exc:
stellar.get_address(client, parse_path("m/0/1"))
if TREZOR_VERSION == 1:
if client.features.model == "1":
assert exc.value.args[0] == proto.FailureType.ProcessError
assert exc.value.args[1].endswith("Failed to derive private key")
else:

@ -19,7 +19,6 @@ import pytest
from trezorlib import btc, messages as proto
from trezorlib.tools import CallException, parse_path
from .conftest import TREZOR_VERSION
from .tx_cache import tx_cache
TX_API = tx_cache("Bitcoin")
@ -172,7 +171,7 @@ class TestOpReturn:
with pytest.raises(CallException) as exc:
btc.sign_tx(client, "Bitcoin", [inp1], [out1], prev_txes=TX_API)
if TREZOR_VERSION == 1:
if client.features.model == "1":
assert exc.value.args[0] == proto.FailureType.ProcessError
assert exc.value.args[1].endswith("Failed to compile output")
else:

Loading…
Cancel
Save