tests: drop TrezorTest class

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

@ -16,10 +16,8 @@
from trezorlib import device, messages from trezorlib import device, messages
from .common import TrezorTest
class TestBasic:
class TestBasic(TrezorTest):
def test_features(self, client): def test_features(self, client):
f0 = client.features f0 = client.features
f1 = client.call(messages.Initialize()) f1 = client.call(messages.Initialize())

@ -21,11 +21,9 @@ import pytest
from trezorlib import btc from trezorlib import btc
from trezorlib.tools import H_ from trezorlib.tools import H_
from .common import TrezorTest
@pytest.mark.flaky(max_runs=5) @pytest.mark.flaky(max_runs=5)
class TestBip32Speed(TrezorTest): class TestBip32Speed:
def test_public_ckd(self, client): def test_public_ckd(self, client):
btc.get_address(client, "Bitcoin", []) # to compute root node via BIP39 btc.get_address(client, "Bitcoin", []) # to compute root node via BIP39

@ -21,11 +21,9 @@ import pytest
from trezorlib import cosi from trezorlib import cosi
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest
@pytest.mark.skip_t2 @pytest.mark.skip_t2
class TestCosi(TrezorTest): class TestCosi:
def test_cosi_commit(self, client): def test_cosi_commit(self, client):
digest = sha256(b"this is a message").digest() digest = sha256(b"this is a message").digest()

@ -18,11 +18,11 @@ import pytest
from trezorlib import debuglink, messages from trezorlib import debuglink, messages
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
@pytest.mark.skip_t2 @pytest.mark.skip_t2
class TestDebuglink(TrezorTest): class TestDebuglink:
def test_layout(self, client): def test_layout(self, client):
layout = client.debug.state().layout layout = client.debug.state().layout
assert len(layout) == 1024 assert len(layout) == 1024
@ -40,7 +40,7 @@ class TestDebuglink(TrezorTest):
label="test", label="test",
) )
mnemonic = client.debug.state().mnemonic_secret mnemonic = client.debug.state().mnemonic_secret
assert mnemonic == self.mnemonic12.encode() assert mnemonic == MNEMONIC12.encode()
@pytest.mark.setup_client(mnemonic=MNEMONIC12, pin="1234", passphrase=True) @pytest.mark.setup_client(mnemonic=MNEMONIC12, pin="1234", passphrase=True)
def test_pin(self, client): def test_pin(self, client):

@ -20,7 +20,6 @@ import pytest
from trezorlib import device, messages as proto from trezorlib import device, messages as proto
from .common import TrezorTest
from .conftest import TREZOR_VERSION from .conftest import TREZOR_VERSION
EXPECTED_RESPONSES_NOPIN = [proto.ButtonRequest(), proto.Success(), proto.Features()] EXPECTED_RESPONSES_NOPIN = [proto.ButtonRequest(), proto.Success(), proto.Features()]
@ -33,7 +32,7 @@ else:
@pytest.mark.setup_client(pin=True) @pytest.mark.setup_client(pin=True)
class TestMsgApplysettings(TrezorTest): class TestMsgApplysettings:
def test_apply_settings(self, client): def test_apply_settings(self, client):
assert client.features.label == "test" assert client.features.label == "test"

@ -18,11 +18,14 @@ import pytest
from trezorlib import messages as proto from trezorlib import messages as proto
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
PIN4 = "1234"
PIN6 = "789456"
@pytest.mark.skip_t2 @pytest.mark.skip_t2
class TestMsgChangepin(TrezorTest): class TestMsgChangepin:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_set_pin(self, client): def test_set_pin(self, client):
features = client.call_raw(proto.Initialize()) features = client.call_raw(proto.Initialize())
@ -42,12 +45,12 @@ class TestMsgChangepin(TrezorTest):
# Send the PIN for first time # Send the PIN for first time
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
pin_encoded = client.debug.encode_pin(self.pin6) pin_encoded = client.debug.encode_pin(PIN6)
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
# Send the PIN for second time # Send the PIN for second time
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
pin_encoded = client.debug.encode_pin(self.pin6) pin_encoded = client.debug.encode_pin(PIN6)
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
# Now we're done # Now we're done
@ -58,7 +61,7 @@ class TestMsgChangepin(TrezorTest):
assert features.pin_protection is True assert features.pin_protection is True
# Check that the PIN is correct # Check that the PIN is correct
self.check_pin(client, self.pin6) self.check_pin(client, PIN6)
@pytest.mark.setup_client(mnemonic=MNEMONIC12, pin=True, passphrase=True) @pytest.mark.setup_client(mnemonic=MNEMONIC12, pin=True, passphrase=True)
def test_change_pin(self, client): def test_change_pin(self, client):
@ -71,7 +74,7 @@ class TestMsgChangepin(TrezorTest):
client.call_raw(proto.Cancel()) client.call_raw(proto.Cancel())
# Check current PIN value # Check current PIN value
self.check_pin(client, self.pin4) self.check_pin(client, PIN4)
# Let's change PIN # Let's change PIN
ret = client.call_raw(proto.ChangePin()) ret = client.call_raw(proto.ChangePin())
@ -88,12 +91,12 @@ class TestMsgChangepin(TrezorTest):
# Send new PIN for first time # Send new PIN for first time
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
pin_encoded = client.debug.encode_pin(self.pin6) pin_encoded = client.debug.encode_pin(PIN6)
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
# Send the PIN for second time # Send the PIN for second time
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
pin_encoded = client.debug.encode_pin(self.pin6) pin_encoded = client.debug.encode_pin(PIN6)
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
# Now we're done # Now we're done
@ -104,7 +107,7 @@ class TestMsgChangepin(TrezorTest):
assert features.pin_protection is True assert features.pin_protection is True
# Check that the PIN is correct # Check that the PIN is correct
self.check_pin(client, self.pin6) self.check_pin(client, PIN6)
@pytest.mark.setup_client(mnemonic=MNEMONIC12, pin=True, passphrase=True) @pytest.mark.setup_client(mnemonic=MNEMONIC12, pin=True, passphrase=True)
def test_remove_pin(self, client): def test_remove_pin(self, client):
@ -157,12 +160,12 @@ class TestMsgChangepin(TrezorTest):
# Send the PIN for first time # Send the PIN for first time
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
pin_encoded = client.debug.encode_pin(self.pin6) pin_encoded = client.debug.encode_pin(PIN6)
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
# Send the PIN for second time, but with typo # Send the PIN for second time, but with typo
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
pin_encoded = client.debug.encode_pin(self.pin4) pin_encoded = client.debug.encode_pin(PIN4)
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
# Now it should fail, because pins are different # Now it should fail, because pins are different
@ -194,12 +197,12 @@ class TestMsgChangepin(TrezorTest):
# Send the PIN for first time # Send the PIN for first time
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
pin_encoded = client.debug.encode_pin(self.pin6) pin_encoded = client.debug.encode_pin(PIN6)
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
# Send the PIN for second time, but with typo # Send the PIN for second time, but with typo
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
pin_encoded = client.debug.encode_pin(self.pin6 + "3") pin_encoded = client.debug.encode_pin(PIN6 + "3")
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
# Now it should fail, because pins are different # Now it should fail, because pins are different
@ -208,7 +211,7 @@ class TestMsgChangepin(TrezorTest):
# Check that there's still old PIN protection # Check that there's still old PIN protection
features = client.call_raw(proto.Initialize()) features = client.call_raw(proto.Initialize())
assert features.pin_protection is True assert features.pin_protection is True
self.check_pin(client, self.pin4) self.check_pin(client, PIN4)
def check_pin(self, client, pin): def check_pin(self, client, pin):
client.clear_session() client.clear_session()

@ -18,10 +18,10 @@ import pytest
from trezorlib import misc from trezorlib import misc
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
class TestMsgCipherkeyvalue(TrezorTest): class TestMsgCipherkeyvalue:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_encrypt(self, client): def test_encrypt(self, client):
res = misc.encrypt_keyvalue( res = misc.encrypt_keyvalue(

@ -18,11 +18,9 @@ import pytest
from trezorlib import messages as proto from trezorlib import messages as proto
from .common import TrezorTest
@pytest.mark.skip_t2 @pytest.mark.skip_t2
class TestMsgClearsession(TrezorTest): class TestMsgClearsession:
@pytest.mark.setup_client(pin=True, passphrase=True) @pytest.mark.setup_client(pin=True, passphrase=True)
def test_clearsession(self, client): def test_clearsession(self, client):
with client: with client:

@ -19,13 +19,13 @@ import pytest
from trezorlib.eos import get_public_key from trezorlib.eos import get_public_key
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.eos @pytest.mark.eos
@pytest.mark.skip_t1 @pytest.mark.skip_t1
class TestMsgEosGetpublickey(TrezorTest): class TestMsgEosGetpublickey:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_eos_get_public_key(self, client): def test_eos_get_public_key(self, client):
public_key = get_public_key(client, parse_path("m/44'/194'/0'/0/0")) public_key = get_public_key(client, parse_path("m/44'/194'/0'/0/0"))

@ -20,7 +20,7 @@ from trezorlib import eos
from trezorlib.messages import EosSignedTx from trezorlib.messages import EosSignedTx
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
CHAIN_ID = "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f" CHAIN_ID = "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f"
ADDRESS_N = parse_path("m/44'/194'/0'/0/0") ADDRESS_N = parse_path("m/44'/194'/0'/0/0")
@ -30,7 +30,7 @@ ADDRESS_N = parse_path("m/44'/194'/0'/0/0")
@pytest.mark.eos @pytest.mark.eos
@pytest.mark.skip_t1 @pytest.mark.skip_t1
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
class TestMsgEosSignTx(TrezorTest): class TestMsgEosSignTx:
@pytest.mark.setup_client(uninitialized=True) @pytest.mark.setup_client(uninitialized=True)
def input_flow(self, debug, pages): def input_flow(self, debug, pages):
# confirm number of actions # confirm number of actions

@ -19,12 +19,12 @@ import pytest
from trezorlib import ethereum from trezorlib import ethereum
from trezorlib.tools import H_ from trezorlib.tools import H_
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.ethereum @pytest.mark.ethereum
class TestMsgEthereumGetaddress(TrezorTest): class TestMsgEthereumGetaddress:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_ethereum_getaddress(self, client): def test_ethereum_getaddress(self, client):
assert ( assert (

@ -19,12 +19,12 @@ import pytest
from trezorlib import ethereum from trezorlib import ethereum
from trezorlib.tools import H_ from trezorlib.tools import H_
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.ethereum @pytest.mark.ethereum
class TestMsgEthereumGetPublicKey(TrezorTest): class TestMsgEthereumGetPublicKey:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_ethereum_getpublickey(self, client): def test_ethereum_getpublickey(self, client):
res = ethereum.get_public_node(client, [H_(44), H_(60), H_(0)]) res = ethereum.get_public_node(client, [H_(44), H_(60), H_(0)])

@ -19,12 +19,12 @@ import pytest
from trezorlib import ethereum from trezorlib import ethereum
from trezorlib.tools import H_ from trezorlib.tools import H_
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.ethereum @pytest.mark.ethereum
class TestMsgEthereumSignmessage(TrezorTest): class TestMsgEthereumSignmessage:
PATH = [H_(44), H_(60), H_(0), 0] PATH = [H_(44), H_(60), H_(0), 0]
ADDRESS = "0xEa53AF85525B1779eE99ece1a5560C0b78537C3b" ADDRESS = "0xEa53AF85525B1779eE99ece1a5560C0b78537C3b"

@ -20,14 +20,14 @@ from trezorlib import ethereum, messages
from trezorlib.exceptions import TrezorFailure from trezorlib.exceptions import TrezorFailure
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
TO_ADDR = "0x1d1c328764a41bda0492b66baa30c4a339ff85ef" TO_ADDR = "0x1d1c328764a41bda0492b66baa30c4a339ff85ef"
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.ethereum @pytest.mark.ethereum
class TestMsgEthereumSigntx(TrezorTest): class TestMsgEthereumSigntx:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_ethereum_signtx_known_erc20_token(self, client): def test_ethereum_signtx_known_erc20_token(self, client):
with client: with client:

@ -18,12 +18,10 @@ import pytest
from trezorlib import ethereum from trezorlib import ethereum
from .common import TrezorTest
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.ethereum @pytest.mark.ethereum
class TestMsgEthereumVerifymessage(TrezorTest): class TestMsgEthereumVerifymessage:
ADDRESS = "0xEa53AF85525B1779eE99ece1a5560C0b78537C3b" ADDRESS = "0xEa53AF85525B1779eE99ece1a5560C0b78537C3b"
VECTORS = [ VECTORS = [

@ -19,7 +19,7 @@ import pytest
from trezorlib import btc, ckd_public as bip32, messages as proto from trezorlib import btc, ckd_public as bip32, messages as proto
from trezorlib.tools import H_, CallException, parse_path from trezorlib.tools import H_, CallException, parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
def getmultisig(chain, nr, xpubs, signatures=[b"", b"", b""]): def getmultisig(chain, nr, xpubs, signatures=[b"", b"", b""]):
@ -31,7 +31,7 @@ def getmultisig(chain, nr, xpubs, signatures=[b"", b"", b""]):
) )
class TestMsgGetaddress(TrezorTest): class TestMsgGetaddress:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_btc(self, client): def test_btc(self, client):
assert ( assert (

@ -19,10 +19,8 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest
class TestMsgGetaddressSegwit:
class TestMsgGetaddressSegwit(TrezorTest):
def test_show_segwit(self, client): def test_show_segwit(self, client):
assert ( assert (
btc.get_address( btc.get_address(

@ -19,10 +19,8 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest
class TestMsgGetaddressSegwitNative:
class TestMsgGetaddressSegwitNative(TrezorTest):
def test_show_segwit(self, client): def test_show_segwit(self, client):
assert ( assert (
btc.get_address( btc.get_address(

@ -18,10 +18,10 @@ import pytest
from trezorlib import btc, ckd_public as bip32, messages as proto from trezorlib import btc, ckd_public as bip32, messages as proto
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
class TestMsgGetaddressShow(TrezorTest): class TestMsgGetaddressShow:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_show(self, client): def test_show(self, client):
assert ( assert (

@ -18,10 +18,10 @@ import pytest
from trezorlib import messages as proto, misc from trezorlib import messages as proto, misc
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
class TestMsgGetECDHSessionKey(TrezorTest): class TestMsgGetECDHSessionKey:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_ecdh(self, client): def test_ecdh(self, client):
identity = proto.IdentityType( identity = proto.IdentityType(

@ -19,10 +19,10 @@ import pytest
from trezorlib import btc, ckd_public as bip32, messages as proto from trezorlib import btc, ckd_public as bip32, messages as proto
from trezorlib.tools import H_ from trezorlib.tools import H_
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
class TestMsgGetpublickey(TrezorTest): class TestMsgGetpublickey:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_btc(self, client): def test_btc(self, client):
assert ( assert (

@ -19,10 +19,10 @@ import pytest
from trezorlib import btc from trezorlib import btc
from trezorlib.tools import H_, CallException from trezorlib.tools import H_, CallException
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
class TestMsgGetpublickeyCurve(TrezorTest): class TestMsgGetpublickeyCurve:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_default_curve(self, client): def test_default_curve(self, client):
assert ( assert (

@ -19,14 +19,14 @@ import pytest
from trezorlib import lisk from trezorlib import lisk
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
LISK_PATH = parse_path("m/44h/134h/0h/1h") LISK_PATH = parse_path("m/44h/134h/0h/1h")
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.lisk @pytest.mark.lisk
class TestMsgLiskGetaddress(TrezorTest): class TestMsgLiskGetaddress:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_lisk_getaddress(self, client): def test_lisk_getaddress(self, client):
assert lisk.get_address(client, LISK_PATH[:2]) == "1431530009238518937L" assert lisk.get_address(client, LISK_PATH[:2]) == "1431530009238518937L"

@ -19,14 +19,14 @@ import pytest
from trezorlib import lisk from trezorlib import lisk
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
LISK_PATH = parse_path("m/44h/134h/0h/0h") LISK_PATH = parse_path("m/44h/134h/0h/0h")
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.lisk @pytest.mark.lisk
class TestMsgLiskGetPublicKey(TrezorTest): class TestMsgLiskGetPublicKey:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_lisk_get_public_key(self, client): def test_lisk_get_public_key(self, client):
sig = lisk.get_public_key(client, LISK_PATH) sig = lisk.get_public_key(client, LISK_PATH)

@ -19,14 +19,14 @@ import pytest
from trezorlib import lisk from trezorlib import lisk
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
LISK_PATH = parse_path("m/44h/134h/0h/0h") LISK_PATH = parse_path("m/44h/134h/0h/0h")
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.lisk @pytest.mark.lisk
class TestMsgLiskSignmessage(TrezorTest): class TestMsgLiskSignmessage:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_sign(self, client): def test_sign(self, client):
sig = lisk.sign_message( sig = lisk.sign_message(

@ -19,12 +19,10 @@ import pytest
from trezorlib import lisk, messages as proto from trezorlib import lisk, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.lisk @pytest.mark.lisk
class TestMsgLiskSignTx(TrezorTest): class TestMsgLiskSignTx:
def test_lisk_sign_tx_send(self, client): def test_lisk_sign_tx_send(self, client):
with client: with client:
client.set_expected_responses( client.set_expected_responses(

@ -18,12 +18,10 @@ import pytest
from trezorlib import lisk, messages as proto from trezorlib import lisk, messages as proto
from .common import TrezorTest
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.lisk @pytest.mark.lisk
class TestMsgLiskVerifymessage(TrezorTest): class TestMsgLiskVerifymessage:
def test_verify(self, client): def test_verify(self, client):
with client: with client:
client.set_expected_responses( client.set_expected_responses(

@ -19,11 +19,11 @@ import pytest
from trezorlib import btc, debuglink, device from trezorlib import btc, debuglink, device
from trezorlib.messages.PassphraseSourceType import HOST as PASSPHRASE_ON_HOST from trezorlib.messages.PassphraseSourceType import HOST as PASSPHRASE_ON_HOST
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
@pytest.mark.setup_client(uninitialized=True) @pytest.mark.setup_client(uninitialized=True)
class TestDeviceLoad(TrezorTest): class TestDeviceLoad:
def test_load_device_1(self, client): def test_load_device_1(self, client):
debuglink.load_device_by_mnemonic( debuglink.load_device_by_mnemonic(
client, client,

@ -18,11 +18,9 @@ import pytest
from trezorlib import btc, debuglink from trezorlib import btc, debuglink
from .common import TrezorTest
@pytest.mark.skip_t2 @pytest.mark.skip_t2
class TestDeviceLoadXprv(TrezorTest): class TestDeviceLoadXprv:
@pytest.mark.setup_client(uninitialized=True) @pytest.mark.setup_client(uninitialized=True)
def test_load_device_xprv_1(self, client): def test_load_device_xprv_1(self, client):
debuglink.load_device_by_xprv( debuglink.load_device_by_xprv(

@ -19,13 +19,13 @@ import pytest
from trezorlib import monero from trezorlib import monero
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.monero @pytest.mark.monero
@pytest.mark.skip_t1 @pytest.mark.skip_t1
class TestMsgMoneroGetaddress(TrezorTest): class TestMsgMoneroGetaddress:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_monero_getaddress(self, client): def test_monero_getaddress(self, client):
assert ( assert (

@ -19,13 +19,13 @@ import pytest
from trezorlib import monero from trezorlib import monero
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.monero @pytest.mark.monero
@pytest.mark.skip_t1 @pytest.mark.skip_t1
class TestMsgMoneroGetwatchkey(TrezorTest): class TestMsgMoneroGetwatchkey:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_monero_getwatchkey(self, client): def test_monero_getwatchkey(self, client):
res = monero.get_watch_key(client, parse_path("m/44h/128h/0h")) res = monero.get_watch_key(client, parse_path("m/44h/128h/0h"))

@ -19,12 +19,12 @@ import pytest
from trezorlib import nem from trezorlib import nem
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.nem @pytest.mark.nem
class TestMsgNEMGetaddress(TrezorTest): class TestMsgNEMGetaddress:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_nem_getaddress(self, client): def test_nem_getaddress(self, client):
assert ( assert (

@ -19,14 +19,14 @@ import pytest
from trezorlib import nem from trezorlib import nem
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
# assertion data from T1 # assertion data from T1
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.nem @pytest.mark.nem
@pytest.mark.skip_t2 @pytest.mark.skip_t2
class TestMsgNEMSignTxMosaics(TrezorTest): class TestMsgNEMSignTxMosaics:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_nem_signtx_mosaic_supply_change(self, client): def test_nem_signtx_mosaic_supply_change(self, client):
tx = nem.sign_tx( tx = nem.sign_tx(

@ -20,14 +20,14 @@ from trezorlib import messages as proto, nem
from trezorlib.messages import ButtonRequestType as B from trezorlib.messages import ButtonRequestType as B
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
# assertion data from T1 # assertion data from T1
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.nem @pytest.mark.nem
@pytest.mark.skip_t1 @pytest.mark.skip_t1
class TestMsgNEMSignTxMosaics(TrezorTest): class TestMsgNEMSignTxMosaics:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_nem_signtx_mosaic_supply_change(self, client): def test_nem_signtx_mosaic_supply_change(self, client):
with client: with client:

@ -19,13 +19,13 @@ import pytest
from trezorlib import nem from trezorlib import nem
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
# assertion data from T1 # assertion data from T1
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.nem @pytest.mark.nem
class TestMsgNEMSignTxMultisig(TrezorTest): class TestMsgNEMSignTxMultisig:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_nem_signtx_aggregate_modification(self, client): def test_nem_signtx_aggregate_modification(self, client):
tx = nem.sign_tx( tx = nem.sign_tx(

@ -19,13 +19,13 @@ import pytest
from trezorlib import nem from trezorlib import nem
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
# assertion data from T1 # assertion data from T1
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.nem @pytest.mark.nem
class TestMsgNEMSignTxOther(TrezorTest): class TestMsgNEMSignTxOther:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_nem_signtx_importance_transfer(self, client): def test_nem_signtx_importance_transfer(self, client):
with client: with client:

@ -19,13 +19,13 @@ import pytest
from trezorlib import messages as proto, nem from trezorlib import messages as proto, nem
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
# assertion data from T1 # assertion data from T1
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.nem @pytest.mark.nem
class TestMsgNEMSignTx(TrezorTest): class TestMsgNEMSignTx:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_nem_signtx_simple(self, client): def test_nem_signtx_simple(self, client):
with client: with client:

@ -18,11 +18,9 @@ import pytest
from trezorlib import messages as proto from trezorlib import messages as proto
from .common import TrezorTest
@pytest.mark.skip_t2 @pytest.mark.skip_t2
class TestMsgPing(TrezorTest): class TestMsgPing:
@pytest.mark.setup_client(pin=True, passphrase=True) @pytest.mark.setup_client(pin=True, passphrase=True)
def test_ping(self, client): def test_ping(self, client):
with client: with client:

@ -18,14 +18,17 @@ import pytest
from trezorlib import device, messages as proto from trezorlib import device, messages as proto
from .common import TrezorTest from .common import MNEMONIC12
PIN4 = "1234"
PIN6 = "789456"
@pytest.mark.skip_t2 @pytest.mark.skip_t2
class TestMsgRecoverydevice(TrezorTest): class TestMsgRecoverydevice:
@pytest.mark.setup_client(uninitialized=True) @pytest.mark.setup_client(uninitialized=True)
def test_pin_passphrase(self, client): def test_pin_passphrase(self, client):
mnemonic = self.mnemonic12.split(" ") mnemonic = MNEMONIC12.split(" ")
ret = client.call_raw( ret = client.call_raw(
proto.RecoveryDevice( proto.RecoveryDevice(
word_count=12, word_count=12,
@ -45,12 +48,12 @@ class TestMsgRecoverydevice(TrezorTest):
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
# Enter PIN for first time # Enter PIN for first time
pin_encoded = client.debug.encode_pin(self.pin6) pin_encoded = client.debug.encode_pin(PIN6)
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
# Enter PIN for second time # Enter PIN for second time
pin_encoded = client.debug.encode_pin(self.pin6) pin_encoded = client.debug.encode_pin(PIN6)
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
fakes = 0 fakes = 0
@ -76,7 +79,7 @@ class TestMsgRecoverydevice(TrezorTest):
# Mnemonic is the same # Mnemonic is the same
client.init_device() client.init_device()
assert client.debug.read_mnemonic_secret() == self.mnemonic12.encode() assert client.debug.read_mnemonic_secret() == MNEMONIC12.encode()
assert client.features.pin_protection is True assert client.features.pin_protection is True
assert client.features.passphrase_protection is True assert client.features.passphrase_protection is True
@ -88,7 +91,7 @@ class TestMsgRecoverydevice(TrezorTest):
@pytest.mark.setup_client(uninitialized=True) @pytest.mark.setup_client(uninitialized=True)
def test_nopin_nopassphrase(self, client): def test_nopin_nopassphrase(self, client):
mnemonic = self.mnemonic12.split(" ") mnemonic = MNEMONIC12.split(" ")
ret = client.call_raw( ret = client.call_raw(
proto.RecoveryDevice( proto.RecoveryDevice(
word_count=12, word_count=12,
@ -128,7 +131,7 @@ class TestMsgRecoverydevice(TrezorTest):
# Mnemonic is the same # Mnemonic is the same
client.init_device() client.init_device()
assert client.debug.read_mnemonic_secret() == self.mnemonic12.encode() assert client.debug.read_mnemonic_secret() == MNEMONIC12.encode()
assert client.features.pin_protection is False assert client.features.pin_protection is False
assert client.features.passphrase_protection is False assert client.features.passphrase_protection is False
@ -190,12 +193,12 @@ class TestMsgRecoverydevice(TrezorTest):
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
# Enter PIN for first time # Enter PIN for first time
pin_encoded = client.debug.encode_pin(self.pin4) pin_encoded = client.debug.encode_pin(PIN4)
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
# Enter PIN for second time, but different one # Enter PIN for second time, but different one
pin_encoded = client.debug.encode_pin(self.pin6) pin_encoded = client.debug.encode_pin(PIN6)
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
# Failure should be raised # Failure should be raised

@ -18,11 +18,11 @@ import pytest
from trezorlib import messages as proto from trezorlib import messages as proto
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
@pytest.mark.skip_t2 @pytest.mark.skip_t2
class TestMsgRecoverydeviceDryrun(TrezorTest): class TestMsgRecoverydeviceDryrun:
def recovery_loop(self, client, mnemonic, result): def recovery_loop(self, client, mnemonic, result):
ret = client.call_raw( ret = client.call_raw(
proto.RecoveryDevice( proto.RecoveryDevice(

@ -18,14 +18,14 @@ import pytest
from trezorlib import device, messages as proto from trezorlib import device, messages as proto
from .common import TrezorTest from .common import MNEMONIC12
@pytest.mark.skip_t1 @pytest.mark.skip_t1
class TestMsgRecoverydeviceT2(TrezorTest): class TestMsgRecoverydeviceT2:
@pytest.mark.setup_client(uninitialized=True) @pytest.mark.setup_client(uninitialized=True)
def test_pin_passphrase(self, client): def test_pin_passphrase(self, client):
mnemonic = self.mnemonic12.split(" ") mnemonic = MNEMONIC12.split(" ")
ret = client.call_raw( ret = client.call_raw(
proto.RecoveryDevice( proto.RecoveryDevice(
passphrase_protection=True, passphrase_protection=True,
@ -84,14 +84,14 @@ class TestMsgRecoverydeviceT2(TrezorTest):
# Mnemonic is the same # Mnemonic is the same
client.init_device() client.init_device()
assert client.debug.read_mnemonic_secret() == self.mnemonic12.encode() assert client.debug.read_mnemonic_secret() == MNEMONIC12.encode()
assert client.features.pin_protection is True assert client.features.pin_protection is True
assert client.features.passphrase_protection is True assert client.features.passphrase_protection is True
@pytest.mark.setup_client(uninitialized=True) @pytest.mark.setup_client(uninitialized=True)
def test_nopin_nopassphrase(self, client): def test_nopin_nopassphrase(self, client):
mnemonic = self.mnemonic12.split(" ") mnemonic = MNEMONIC12.split(" ")
ret = client.call_raw( ret = client.call_raw(
proto.RecoveryDevice( proto.RecoveryDevice(
passphrase_protection=False, passphrase_protection=False,
@ -140,7 +140,7 @@ class TestMsgRecoverydeviceT2(TrezorTest):
# Mnemonic is the same # Mnemonic is the same
client.init_device() client.init_device()
assert client.debug.read_mnemonic_secret() == self.mnemonic12.encode() assert client.debug.read_mnemonic_secret() == MNEMONIC12.encode()
assert client.features.pin_protection is False assert client.features.pin_protection is False
assert client.features.passphrase_protection is False assert client.features.passphrase_protection is False

@ -19,11 +19,11 @@ from mnemonic import Mnemonic
from trezorlib import device, messages as proto from trezorlib import device, messages as proto
from .common import TrezorTest, generate_entropy from .common import generate_entropy
@pytest.mark.skip_t2 @pytest.mark.skip_t2
class TestMsgResetDevice(TrezorTest): class TestMsgResetDevice:
@pytest.mark.setup_client(uninitialized=True) @pytest.mark.setup_client(uninitialized=True)
def test_reset_device(self, client): def test_reset_device(self, client):
# No PIN, no passphrase # No PIN, no passphrase
@ -218,12 +218,12 @@ class TestMsgResetDevice(TrezorTest):
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
# Enter PIN for first time # Enter PIN for first time
pin_encoded = client.debug.encode_pin(self.pin4) pin_encoded = client.debug.encode_pin("1234")
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
assert isinstance(ret, proto.PinMatrixRequest) assert isinstance(ret, proto.PinMatrixRequest)
# Enter PIN for second time # Enter PIN for second time
pin_encoded = client.debug.encode_pin(self.pin6) pin_encoded = client.debug.encode_pin("6789")
ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) ret = client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
assert isinstance(ret, proto.Failure) assert isinstance(ret, proto.Failure)

@ -18,10 +18,8 @@ import pytest
from trezorlib import messages as proto from trezorlib import messages as proto
from .common import TrezorTest
class TestMsgResetDeviceNobackup:
class TestMsgResetDeviceNobackup(TrezorTest):
external_entropy = b"zlutoucky kun upel divoke ody" * 2 external_entropy = b"zlutoucky kun upel divoke ody" * 2
strength = 128 strength = 128

@ -19,11 +19,11 @@ from mnemonic import Mnemonic
from trezorlib import messages as proto from trezorlib import messages as proto
from .common import TrezorTest, generate_entropy from .common import generate_entropy
@pytest.mark.skip_t2 @pytest.mark.skip_t2
class TestMsgResetDeviceSkipbackup(TrezorTest): class TestMsgResetDeviceSkipbackup:
external_entropy = b"zlutoucky kun upel divoke ody" * 2 external_entropy = b"zlutoucky kun upel divoke ody" * 2
strength = 128 strength = 128

@ -19,8 +19,6 @@ import pytest
from trezorlib.ripple import get_address from trezorlib.ripple import get_address
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest
CUSTOM_MNEMONIC = ( CUSTOM_MNEMONIC = (
"armed bundle pudding lazy strategy impulse where identify " "armed bundle pudding lazy strategy impulse where identify "
"submit weekend physical antenna flight social acoustic absurd " "submit weekend physical antenna flight social acoustic absurd "
@ -31,7 +29,7 @@ CUSTOM_MNEMONIC = (
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.ripple @pytest.mark.ripple
@pytest.mark.skip_t1 # T1 support is not planned @pytest.mark.skip_t1 # T1 support is not planned
class TestMsgRippleGetAddress(TrezorTest): class TestMsgRippleGetAddress:
def test_ripple_get_address(self, client): def test_ripple_get_address(self, client):
# data from https://iancoleman.io/bip39/#english # data from https://iancoleman.io/bip39/#english
address = get_address(client, parse_path("m/44'/144'/0'/0/0")) address = get_address(client, parse_path("m/44'/144'/0'/0/0"))

@ -19,13 +19,11 @@ import pytest
from trezorlib import messages, ripple from trezorlib import messages, ripple
from trezorlib.tools import CallException, parse_path from trezorlib.tools import CallException, parse_path
from .common import TrezorTest
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.ripple @pytest.mark.ripple
@pytest.mark.skip_t1 # T1 support is not planned @pytest.mark.skip_t1 # T1 support is not planned
class TestMsgRippleSignTx(TrezorTest): class TestMsgRippleSignTx:
def test_ripple_sign_simple_tx(self, client): def test_ripple_sign_simple_tx(self, client):
msg = ripple.create_sign_tx_msg( msg = ripple.create_sign_tx_msg(
{ {

@ -21,7 +21,7 @@ import pytest
from trezorlib import messages as proto, misc from trezorlib import messages as proto, misc
from trezorlib.tools import H_ from trezorlib.tools import H_
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
def check_path(identity): def check_path(identity):
@ -47,7 +47,7 @@ def check_path(identity):
print("path:", "m/" + "/".join([str(x) for x in address_n])) print("path:", "m/" + "/".join([str(x) for x in address_n]))
class TestMsgSignidentity(TrezorTest): class TestMsgSignidentity:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_sign(self, client): def test_sign(self, client):
hidden = bytes.fromhex( hidden = bytes.fromhex(

@ -21,10 +21,10 @@ import pytest
from trezorlib import btc from trezorlib import btc
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
class TestMsgSignmessage(TrezorTest): class TestMsgSignmessage:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_sign(self, client): def test_sign(self, client):
sig = btc.sign_message( sig = btc.sign_message(

@ -19,12 +19,12 @@ import pytest
from trezorlib import btc from trezorlib import btc
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.decred @pytest.mark.decred
class TestMsgSignmessageDecred(TrezorTest): class TestMsgSignmessageDecred:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_sign_mainnet(self, client): def test_sign_mainnet(self, client):
address_n = parse_path("m/44'/42'/0'/0/0") address_n = parse_path("m/44'/42'/0'/0/0")

@ -21,10 +21,10 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
class TestMsgSignmessageSegwit(TrezorTest): class TestMsgSignmessageSegwit:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_sign(self, client): def test_sign(self, client):
sig = btc.sign_message( sig = btc.sign_message(

@ -21,10 +21,10 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
class TestMsgSignmessageSegwitNative(TrezorTest): class TestMsgSignmessageSegwitNative:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_sign(self, client): def test_sign(self, client):
sig = btc.sign_message( sig = btc.sign_message(

@ -19,7 +19,7 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import H_, CallException, btc_hash, parse_path from trezorlib.tools import H_, CallException, btc_hash, parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
from .conftest import TREZOR_VERSION from .conftest import TREZOR_VERSION
from .tx_cache import tx_cache from .tx_cache import tx_cache
@ -151,7 +151,7 @@ def check_sign_tx(
return btc.sign_tx(client, coin_name, inputs, outputs, prev_txes=txes) return btc.sign_tx(client, coin_name, inputs, outputs, prev_txes=txes)
class TestMsgSigntx(TrezorTest): class TestMsgSigntx:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_one_one_fee(self, client): def test_one_one_fee(self, client):
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882 # tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882

@ -19,14 +19,13 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import H_, CallException, parse_path from trezorlib.tools import H_, CallException, parse_path
from .common import TrezorTest
from .tx_cache import tx_cache from .tx_cache import tx_cache
TX_API = tx_cache("Bcash") TX_API = tx_cache("Bcash")
@pytest.mark.altcoin @pytest.mark.altcoin
class TestMsgSigntxBch(TrezorTest): class TestMsgSigntxBch:
def test_send_bch_change(self, client): def test_send_bch_change(self, client):
inp1 = proto.TxInputType( inp1 = proto.TxInputType(
address_n=parse_path("44'/145'/0'/0/0"), address_n=parse_path("44'/145'/0'/0/0"),

@ -19,7 +19,6 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import H_, CallException, parse_path from trezorlib.tools import H_, CallException, parse_path
from .common import TrezorTest
from .tx_cache import tx_cache from .tx_cache import tx_cache
TX_API = tx_cache("Bgold") TX_API = tx_cache("Bgold")
@ -27,7 +26,7 @@ TX_API = tx_cache("Bgold")
# All data taken from T1 # All data taken from T1
@pytest.mark.altcoin @pytest.mark.altcoin
class TestMsgSigntxBitcoinGold(TrezorTest): class TestMsgSigntxBitcoinGold:
def test_send_bitcoin_gold_change(self, client): def test_send_bitcoin_gold_change(self, client):
inp1 = proto.TxInputType( inp1 = proto.TxInputType(
address_n=parse_path("44'/156'/0'/0/0"), address_n=parse_path("44'/156'/0'/0/0"),

@ -19,14 +19,13 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest
from .tx_cache import tx_cache from .tx_cache import tx_cache
TX_API = tx_cache("Dash") TX_API = tx_cache("Dash")
@pytest.mark.altcoin @pytest.mark.altcoin
class TestMsgSigntxDash(TrezorTest): class TestMsgSigntxDash:
def test_send_dash(self, client): def test_send_dash(self, client):
inp1 = proto.TxInputType( inp1 = proto.TxInputType(
address_n=parse_path("44'/5'/0'/0/0"), address_n=parse_path("44'/5'/0'/0/0"),

@ -19,7 +19,6 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest
from .tx_cache import tx_cache from .tx_cache import tx_cache
TX_API = tx_cache("Decred Testnet") TX_API = tx_cache("Decred Testnet")
@ -47,7 +46,7 @@ TXHASH_16da18 = bytes.fromhex(
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.decred @pytest.mark.decred
class TestMsgSigntxDecred(TrezorTest): class TestMsgSigntxDecred:
def test_send_decred(self, client): def test_send_decred(self, client):
inp1 = proto.TxInputType( inp1 = proto.TxInputType(
# TscqTv1he8MZrV321SfRghw7LFBCJDKB3oz # TscqTv1he8MZrV321SfRghw7LFBCJDKB3oz

@ -19,14 +19,13 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest
from .tx_cache import tx_cache from .tx_cache import tx_cache
TX_API = tx_cache("Groestlcoin") TX_API = tx_cache("Groestlcoin")
@pytest.mark.altcoin @pytest.mark.altcoin
class TestMsgSigntxGRS(TrezorTest): class TestMsgSigntxGRS:
def test_legacy(self, client): def test_legacy(self, client):
inp1 = proto.TxInputType( inp1 = proto.TxInputType(
address_n=parse_path( address_n=parse_path(

@ -19,7 +19,6 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest
from .conftest import TREZOR_VERSION from .conftest import TREZOR_VERSION
from .tx_cache import tx_cache from .tx_cache import tx_cache
@ -36,7 +35,7 @@ TXHASH_7b28bd = bytes.fromhex(
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.komodo @pytest.mark.komodo
class TestMsgSigntxKomodo(TrezorTest): class TestMsgSigntxKomodo:
def test_one_one_fee_sapling(self, client): def test_one_one_fee_sapling(self, client):
# prevout: 2807c5b126ec8e2b078cab0f12e4c8b4ce1d7724905f8ebef8dca26b0c8e0f1d:0 # prevout: 2807c5b126ec8e2b078cab0f12e4c8b4ce1d7724905f8ebef8dca26b0c8e0f1d:0
# input 1: 10.9998 KMD # input 1: 10.9998 KMD

@ -19,14 +19,13 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import H_, CallException, parse_path from trezorlib.tools import H_, CallException, parse_path
from .common import TrezorTest
from .conftest import TREZOR_VERSION from .conftest import TREZOR_VERSION
from .tx_cache import tx_cache from .tx_cache import tx_cache
TX_API = tx_cache("Testnet") TX_API = tx_cache("Testnet")
class TestMsgSigntxSegwit(TrezorTest): class TestMsgSigntxSegwit:
def test_send_p2sh(self, client): def test_send_p2sh(self, client):
inp1 = proto.TxInputType( inp1 = proto.TxInputType(
address_n=parse_path("49'/1'/0'/1/0"), address_n=parse_path("49'/1'/0'/1/0"),

@ -18,13 +18,12 @@ from trezorlib import btc, messages as proto
from trezorlib.ckd_public import deserialize from trezorlib.ckd_public import deserialize
from trezorlib.tools import H_, parse_path from trezorlib.tools import H_, parse_path
from .common import TrezorTest
from .tx_cache import tx_cache from .tx_cache import tx_cache
TX_API = tx_cache("Testnet") TX_API = tx_cache("Testnet")
class TestMsgSigntxSegwitNative(TrezorTest): class TestMsgSigntxSegwitNative:
def test_send_p2sh(self, client): def test_send_p2sh(self, client):
inp1 = proto.TxInputType( inp1 = proto.TxInputType(
address_n=parse_path("49'/1'/0'/1/0"), address_n=parse_path("49'/1'/0'/1/0"),

@ -19,7 +19,6 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest
from .tx_cache import tx_cache from .tx_cache import tx_cache
TX_API = tx_cache("Zcash Testnet") TX_API = tx_cache("Zcash Testnet")
@ -34,7 +33,7 @@ TXHASH_e38206 = bytes.fromhex(
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.zcash @pytest.mark.zcash
class TestMsgSigntxZcash(TrezorTest): class TestMsgSigntxZcash:
def test_one_one_fee_overwinter(self, client): def test_one_one_fee_overwinter(self, client):
# prevout: aaf51e4606c264e47e5c42c958fe4cf1539c5172684721e38e69f4ef634d75dc:1 # prevout: aaf51e4606c264e47e5c42c958fe4cf1539c5172684721e38e69f4ef634d75dc:1
# input 1: 3.0 TAZ # input 1: 3.0 TAZ

@ -19,13 +19,13 @@ import pytest
from trezorlib import messages as proto, stellar from trezorlib import messages as proto, stellar
from trezorlib.tools import CallException, parse_path from trezorlib.tools import CallException, parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
from .conftest import TREZOR_VERSION from .conftest import TREZOR_VERSION
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.stellar @pytest.mark.stellar
class TestMsgStellarGetAddress(TrezorTest): class TestMsgStellarGetAddress:
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_stellar_get_address(self, client): def test_stellar_get_address(self, client):
address = stellar.get_address(client, parse_path(stellar.DEFAULT_BIP32_PATH)) address = stellar.get_address(client, parse_path(stellar.DEFAULT_BIP32_PATH))

@ -53,12 +53,12 @@ import pytest
from trezorlib import messages as proto, stellar from trezorlib import messages as proto, stellar
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.stellar @pytest.mark.stellar
class TestMsgStellarSignTransaction(TrezorTest): class TestMsgStellarSignTransaction:
ADDRESS_N = parse_path(stellar.DEFAULT_BIP32_PATH) ADDRESS_N = parse_path(stellar.DEFAULT_BIP32_PATH)
NETWORK_PASSPHRASE = "Test SDF Network ; September 2015" NETWORK_PASSPHRASE = "Test SDF Network ; September 2015"

@ -19,13 +19,11 @@ import pytest
from trezorlib.tezos import get_address from trezorlib.tezos import get_address
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.tezos @pytest.mark.tezos
@pytest.mark.skip_t1 @pytest.mark.skip_t1
class TestMsgTezosGetAddress(TrezorTest): class TestMsgTezosGetAddress:
def test_tezos_get_address(self, client): def test_tezos_get_address(self, client):
path = parse_path("m/44'/1729'/0'") path = parse_path("m/44'/1729'/0'")
address = get_address(client, path, show_display=True) address = get_address(client, path, show_display=True)

@ -19,13 +19,11 @@ import pytest
from trezorlib.tezos import get_public_key from trezorlib.tezos import get_public_key
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.tezos @pytest.mark.tezos
@pytest.mark.skip_t1 @pytest.mark.skip_t1
class TestMsgTezosGetPublicKey(TrezorTest): class TestMsgTezosGetPublicKey:
def test_tezos_get_public_key(self, client): def test_tezos_get_public_key(self, client):
path = parse_path("m/44'/1729'/0'") path = parse_path("m/44'/1729'/0'")
pk = get_public_key(client, path) pk = get_public_key(client, path)

@ -20,8 +20,6 @@ from trezorlib import messages, tezos
from trezorlib.protobuf import dict_to_proto from trezorlib.protobuf import dict_to_proto
from trezorlib.tools import parse_path from trezorlib.tools import parse_path
from .common import TrezorTest
TEZOS_PATH = parse_path("m/44'/1729'/0'") TEZOS_PATH = parse_path("m/44'/1729'/0'")
TEZOS_PATH_10 = parse_path("m/44'/1729'/10'") TEZOS_PATH_10 = parse_path("m/44'/1729'/10'")
@ -29,7 +27,7 @@ TEZOS_PATH_10 = parse_path("m/44'/1729'/10'")
@pytest.mark.altcoin @pytest.mark.altcoin
@pytest.mark.tezos @pytest.mark.tezos
@pytest.mark.skip_t1 @pytest.mark.skip_t1
class TestMsgTezosSignTx(TrezorTest): class TestMsgTezosSignTx:
def test_tezos_sign_tx_transaction(self, client): def test_tezos_sign_tx_transaction(self, client):
resp = tezos.sign_tx( resp = tezos.sign_tx(
client, client,

@ -20,10 +20,8 @@ import pytest
from trezorlib import btc from trezorlib import btc
from .common import TrezorTest
class TestMsgVerifymessage:
class TestMsgVerifymessage(TrezorTest):
def test_message_long(self, client): def test_message_long(self, client):
ret = btc.verify_message( ret = btc.verify_message(
client, client,

@ -16,10 +16,8 @@
from trezorlib import btc from trezorlib import btc
from .common import TrezorTest
class TestMsgVerifymessageSegwit:
class TestMsgVerifymessageSegwit(TrezorTest):
def test_message_long(self, client): def test_message_long(self, client):
ret = btc.verify_message( ret = btc.verify_message(
client, client,

@ -16,10 +16,8 @@
from trezorlib import btc from trezorlib import btc
from .common import TrezorTest
class TestMsgVerifymessageSegwitNative:
class TestMsgVerifymessageSegwitNative(TrezorTest):
def test_message_long(self, client): def test_message_long(self, client):
ret = btc.verify_message( ret = btc.verify_message(
client, client,

@ -18,10 +18,8 @@ import pytest
from trezorlib import device, messages as proto from trezorlib import device, messages as proto
from .common import TrezorTest
class TestMsgWipedevice:
class TestMsgWipedevice(TrezorTest):
@pytest.mark.setup_client(pin=True, passphrase=True) @pytest.mark.setup_client(pin=True, passphrase=True)
def test_wipe_device(self, client): def test_wipe_device(self, client):
features = client.call_raw(proto.Initialize()) features = client.call_raw(proto.Initialize())

@ -19,7 +19,7 @@ import pytest
from trezorlib import btc, ckd_public as bip32, messages as proto from trezorlib import btc, ckd_public as bip32, messages as proto
from trezorlib.tools import CallException, parse_path from trezorlib.tools import CallException, parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
from .tx_cache import tx_cache from .tx_cache import tx_cache
TX_API = tx_cache("Bitcoin") TX_API = tx_cache("Bitcoin")
@ -29,7 +29,7 @@ TXHASH_c6091a = bytes.fromhex(
) )
class TestMultisig(TrezorTest): class TestMultisig:
def test_2_of_3(self, client): def test_2_of_3(self, client):
nodes = [ nodes = [
btc.get_public_node(client, parse_path("48'/0'/%d'" % index)).node btc.get_public_node(client, parse_path("48'/0'/%d'" % index)).node

@ -19,13 +19,13 @@ import pytest
from trezorlib import btc, ckd_public as bip32, messages as proto from trezorlib import btc, ckd_public as bip32, messages as proto
from trezorlib.tools import H_, parse_path from trezorlib.tools import H_, parse_path
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
from .tx_cache import tx_cache from .tx_cache import tx_cache
TX_API = tx_cache("Testnet") TX_API = tx_cache("Testnet")
class TestMultisigChange(TrezorTest): class TestMultisigChange:
node_ext1 = bip32.deserialize( node_ext1 = bip32.deserialize(
"tpubDADHV9u9Y6gkggintTdMjJE3be58zKNLhpxBQyuEM6Pwx3sN9JVLmMCMN4DNVwL9AKec27z5TaWcWuHzMXiGAtcra5DjwWbvppGX4gaEGVN" "tpubDADHV9u9Y6gkggintTdMjJE3be58zKNLhpxBQyuEM6Pwx3sN9JVLmMCMN4DNVwL9AKec27z5TaWcWuHzMXiGAtcra5DjwWbvppGX4gaEGVN"
) )

@ -19,7 +19,6 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from trezorlib.tools import CallException, parse_path from trezorlib.tools import CallException, parse_path
from .common import TrezorTest
from .conftest import TREZOR_VERSION from .conftest import TREZOR_VERSION
from .tx_cache import tx_cache from .tx_cache import tx_cache
@ -30,7 +29,7 @@ TXHASH_d5f65e = bytes.fromhex(
) )
class TestOpReturn(TrezorTest): class TestOpReturn:
def test_opreturn(self, client): def test_opreturn(self, client):
inp1 = proto.TxInputType( inp1 = proto.TxInputType(
address_n=parse_path("44'/0'/0'/0/2"), prev_hash=TXHASH_d5f65e, prev_index=0 address_n=parse_path("44'/0'/0'/0/2"), prev_hash=TXHASH_d5f65e, prev_index=0

@ -21,13 +21,11 @@ import pytest
from trezorlib import messages as proto from trezorlib import messages as proto
from trezorlib.exceptions import PinException from trezorlib.exceptions import PinException
from .common import TrezorTest
# FIXME TODO Add passphrase tests # FIXME TODO Add passphrase tests
@pytest.mark.skip_t2 @pytest.mark.skip_t2
class TestProtectCall(TrezorTest): class TestProtectCall:
def _some_protected_call(self, client, button, pin, passphrase): def _some_protected_call(self, client, button, pin, passphrase):
# This method perform any call which have protection in the device # This method perform any call which have protection in the device
res = client.ping( res = client.ping(
@ -38,52 +36,46 @@ class TestProtectCall(TrezorTest):
) )
assert res == "random data" assert res == "random data"
""" @pytest.mark.setup_client(pin="1234", passphrase=True)
def test_expected_responses(self): def test_expected_responses(self, client):
self.setup_mnemonic_pin_passphrase()
# This is low-level test of set_expected_responses() # This is low-level test of set_expected_responses()
# feature of debugging client # feature of debugging client
with self.client: with pytest.raises(AssertionError), client:
# Scenario 1 - Received unexpected message # Scenario 1 - Received unexpected message
self.client.set_expected_responses([]) client.set_expected_responses([])
with pytest.raises(CallException): self._some_protected_call(client, True, True, True)
self._some_protected_call(True, True, True)
with self.client: with pytest.raises(AssertionError), client:
# Scenario 2 - Received other than expected message # Scenario 2 - Received other than expected message
self.client.set_expected_responses([proto.Success()]) client.set_expected_responses([proto.Success()])
with pytest.raises(CallException): self._some_protected_call(client, True, True, True)
self._some_protected_call(True, True, True)
with pytest.raises(AssertionError), client:
def scenario3(): # Scenario 3 - Not received expected message
with self.client: client.set_expected_responses(
# Scenario 3 - Not received expected message [proto.ButtonRequest(), proto.Success(), proto.Success()]
self.client.set_expected_responses([proto.ButtonRequest(), ) # This is expected, but not received
proto.Success(), self._some_protected_call(client, True, False, False)
proto.Success()]) # This is expected, but not received
self._some_protected_call(True, False, False) with pytest.raises(AssertionError), client:
with pytest.raises(Exception):
scenario3()
with self.client:
# Scenario 4 - Received what expected # Scenario 4 - Received what expected
self.client.set_expected_responses([proto.ButtonRequest(), client.set_expected_responses(
proto.PinMatrixRequest(), [
proto.PassphraseRequest(), proto.ButtonRequest(),
proto.Success(message='random data')]) proto.PinMatrixRequest(),
self._some_protected_call(True, True, True) proto.PassphraseRequest(),
proto.Success(message="random data"),
def scenario5(): ]
with self.client: )
# Scenario 5 - Failed message by field filter self._some_protected_call(client, True, True, True)
self.client.set_expected_responses([proto.ButtonRequest(),
proto.Success(message='wrong data')]) with pytest.raises(AssertionError), client:
self._some_protected_call(True, True, True) # Scenario 5 - Failed message by field filter
with pytest.raises(CallException): client.set_expected_responses(
scenario5() [proto.ButtonRequest(), proto.Success(message="wrong data")]
""" )
self._some_protected_call(client, True, True, True)
def test_no_protection(self, client): def test_no_protection(self, client):
with client: with client:

@ -19,7 +19,7 @@ import pytest
from trezorlib import btc, debuglink, device, messages as proto, misc from trezorlib import btc, debuglink, device, messages as proto, misc
from trezorlib.exceptions import TrezorFailure from trezorlib.exceptions import TrezorFailure
from .common import TrezorTest from .common import MNEMONIC12
from .tx_cache import tx_cache from .tx_cache import tx_cache
TXHASH_d5f65e = bytes.fromhex( TXHASH_d5f65e = bytes.fromhex(
@ -28,7 +28,7 @@ TXHASH_d5f65e = bytes.fromhex(
@pytest.mark.skip_t2 @pytest.mark.skip_t2
class TestProtectionLevels(TrezorTest): class TestProtectionLevels:
@pytest.mark.setup_client(pin=True, passphrase=True) @pytest.mark.setup_client(pin=True, passphrase=True)
def test_initialize(self, client): def test_initialize(self, client):
with client: with client:
@ -163,7 +163,7 @@ class TestProtectionLevels(TrezorTest):
@pytest.mark.setup_client(uninitialized=True) @pytest.mark.setup_client(uninitialized=True)
def test_recovery_device(self, client): def test_recovery_device(self, client):
client.set_mnemonic(self.mnemonic12) client.set_mnemonic(MNEMONIC12)
with client: with client:
client.set_expected_responses( client.set_expected_responses(
[proto.ButtonRequest()] [proto.ButtonRequest()]

@ -18,7 +18,7 @@ import pytest
from trezorlib import btc, messages as proto from trezorlib import btc, messages as proto
from .common import MNEMONIC12, TrezorTest from .common import MNEMONIC12
from .tx_cache import tx_cache from .tx_cache import tx_cache
TXHASH_d5f65e = bytes.fromhex( TXHASH_d5f65e = bytes.fromhex(
@ -28,39 +28,7 @@ TXHASH_d5f65e = bytes.fromhex(
# address_n = [177] < 68 # address_n = [177] < 68
# address_n = [16518] < 66 # address_n = [16518] < 66
class TestZerosig(TrezorTest): class TestZerosig:
"""
def test_mine_zero_signature(self):
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
# input 0: 0.0039 BTC
inp1 = proto.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
# amount=390000,
prev_hash=TXHASH_d5f65e,
prev_index=0,
)
msg = self.client._prepare_sign_tx('Bitcoin', [inp1, ], [])
for n in range(3500, 200000):
out1 = proto.TxOutputType(address_n=[n],
amount=390000 - 10000,
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
msg.ClearField('outputs')
msg.outputs.extend([out1, ])
tx = self.client.call(msg)
siglen = tx.serialized_tx[44]
print(siglen)
if siglen < 67:
print("!!!!", n)
print(tx.serialized_tx.hex())
return
"""
@pytest.mark.setup_client(mnemonic=MNEMONIC12) @pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_one_zero_signature(self, client): def test_one_zero_signature(self, client):
inp1 = proto.TxInputType( inp1 = proto.TxInputType(

Loading…
Cancel
Save