1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

tests: start rewriting device tests to pytest

This commit is contained in:
Pavol Rusnak 2017-07-28 18:07:20 +02:00
parent 8a1d211ee9
commit 81d5170c10
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
50 changed files with 71 additions and 320 deletions

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ distribute-*.tar.gz
docs/_build docs/_build
docs/.docs-build-environment docs/.docs-build-environment
.tox/ .tox/
.cache/

View File

@ -23,22 +23,81 @@ import hashlib
from trezorlib.client import TrezorClient, TrezorClientDebugLink from trezorlib.client import TrezorClient, TrezorClientDebugLink
from trezorlib import tx_api from trezorlib import tx_api
import config
tx_api.cache_dir = '../txcache' tx_api.cache_dir = '../txcache'
try:
from trezorlib.transport_hid import HidTransport
HID_ENABLED = True
except Exception as e:
print('HID transport disabled:', e.message, e.args)
HID_ENABLED = False
try:
from trezorlib.transport_pipe import PipeTransport
PIPE_ENABLED = True
except Exception as e:
print('PIPE transport disabled:', e.message, e.args)
PIPE_ENABLED = False
try:
from trezorlib.transport_udp import UdpTransport
UDP_ENABLED = True
except Exception as e:
print('UDP transport disabled:', e.message, e.args)
UDP_ENABLED = False
def pipe_exists(path):
import os
import stat
try:
return stat.S_ISFIFO(os.stat(path).st_mode)
except:
return False
if HID_ENABLED and len(HidTransport.enumerate()) > 0:
devices = HidTransport.enumerate()
print('Using TREZOR')
TRANSPORT = HidTransport
TRANSPORT_ARGS = (devices[0],)
TRANSPORT_KWARGS = {'debug_link': False}
DEBUG_TRANSPORT = HidTransport
DEBUG_TRANSPORT_ARGS = (devices[0],)
DEBUG_TRANSPORT_KWARGS = {'debug_link': True}
elif PIPE_ENABLED and pipe_exists('/tmp/pipe.trezor.to'):
print('Using Emulator (v1=pipe)')
TRANSPORT = PipeTransport
TRANSPORT_ARGS = ('/tmp/pipe.trezor', False)
TRANSPORT_KWARGS = {}
DEBUG_TRANSPORT = PipeTransport
DEBUG_TRANSPORT_ARGS = ('/tmp/pipe.trezor_debug', False)
DEBUG_TRANSPORT_KWARGS = {}
elif UDP_ENABLED:
print('Using Emulator (v2=udp)')
TRANSPORT = UdpTransport
TRANSPORT_ARGS = ('', )
TRANSPORT_KWARGS = {}
DEBUG_TRANSPORT = UdpTransport
DEBUG_TRANSPORT_ARGS = ('', )
DEBUG_TRANSPORT_KWARGS = {}
class TrezorTest(unittest.TestCase): class TrezorTest(unittest.TestCase):
def setUp(self): def setUp(self):
transport = config.TRANSPORT(*config.TRANSPORT_ARGS, **config.TRANSPORT_KWARGS) transport = TRANSPORT(*TRANSPORT_ARGS, **TRANSPORT_KWARGS)
if hasattr(config, 'DEBUG_TRANSPORT'): debug_transport = DEBUG_TRANSPORT(*DEBUG_TRANSPORT_ARGS, **DEBUG_TRANSPORT_KWARGS)
debug_transport = config.DEBUG_TRANSPORT(*config.DEBUG_TRANSPORT_ARGS, **config.DEBUG_TRANSPORT_KWARGS)
self.client = TrezorClientDebugLink(transport) self.client = TrezorClientDebugLink(transport)
self.client.set_debuglink(debug_transport) self.client.set_debuglink(debug_transport)
else:
self.client = TrezorClient(transport)
self.client.set_tx_api(tx_api.TxApiBitcoin) self.client.set_tx_api(tx_api.TxApiBitcoin)
# self.client.set_buttonwait(3) # self.client.set_buttonwait(3)

View File

@ -1,85 +0,0 @@
# This file is part of the TREZOR project.
#
# Copyright (C) 2012-2016 Marek Palatinus <slush@satoshilabs.com>
# Copyright (C) 2012-2016 Pavol Rusnak <stick@satoshilabs.com>
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import sys
sys.path = ['../../'] + sys.path
try:
from trezorlib.transport_hid import HidTransport
HID_ENABLED = True
except Exception as e:
print('HID transport disabled:', e.message, e.args)
HID_ENABLED = False
try:
from trezorlib.transport_pipe import PipeTransport
PIPE_ENABLED = True
except Exception as e:
print('PIPE transport disabled:', e.message, e.args)
PIPE_ENABLED = False
try:
from trezorlib.transport_udp import UdpTransport
UDP_ENABLED = True
except Exception as e:
print('UDP transport disabled:', e.message, e.args)
UDP_ENABLED = False
def pipe_exists(path):
import os
import stat
try:
return stat.S_ISFIFO(os.stat(path).st_mode)
except:
return False
if HID_ENABLED and len(HidTransport.enumerate()) > 0:
devices = HidTransport.enumerate()
print('Using TREZOR')
TRANSPORT = HidTransport
TRANSPORT_ARGS = (devices[0],)
TRANSPORT_KWARGS = {'debug_link': False}
DEBUG_TRANSPORT = HidTransport
DEBUG_TRANSPORT_ARGS = (devices[0],)
DEBUG_TRANSPORT_KWARGS = {'debug_link': True}
elif PIPE_ENABLED and pipe_exists('/tmp/pipe.trezor.to'):
print('Using Emulator (v1=pipe)')
TRANSPORT = PipeTransport
TRANSPORT_ARGS = ('/tmp/pipe.trezor', False)
TRANSPORT_KWARGS = {}
DEBUG_TRANSPORT = PipeTransport
DEBUG_TRANSPORT_ARGS = ('/tmp/pipe.trezor_debug', False)
DEBUG_TRANSPORT_KWARGS = {}
elif UDP_ENABLED:
print('Using Emulator (v2=udp)')
TRANSPORT = UdpTransport
TRANSPORT_ARGS = ('', )
TRANSPORT_KWARGS = {}
DEBUG_TRANSPORT = UdpTransport
DEBUG_TRANSPORT_ARGS = ('', )
DEBUG_TRANSPORT_KWARGS = {}

View File

@ -1,5 +0,0 @@
#!/bin/bash
for i in test_*.py; do
echo Starting: $i
python $i > $i.out 2> $i.err
done

View File

@ -1,3 +0,0 @@
#!/bin/bash
python -m unittest discover

View File

@ -50,7 +50,3 @@ class TestBasic(common.TrezorTest):
# Device ID must be fresh after every reset # Device ID must be fresh after every reset
self.assertNotEqual(id1, id2) self.assertNotEqual(id1, id2)
if __name__ == '__main__':
unittest.main()

View File

@ -69,7 +69,3 @@ class TestBip32Speed(common.TrezorTest):
# Cached time expected to be at least 2x faster # Cached time expected to be at least 2x faster
self.assertLessEqual(cache_time, nocache_time / 2.) self.assertLessEqual(cache_time, nocache_time / 2.)
if __name__ == '__main__':
unittest.main()

View File

@ -52,7 +52,3 @@ class TestDebugLink(common.TrezorTest):
pin_encoded = self.client.debug.read_pin_encoded() pin_encoded = self.client.debug.read_pin_encoded()
resp = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded)) resp = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
self.assertIsInstance(resp, proto.Success) self.assertIsInstance(resp, proto.Success)
if __name__ == '__main__':
unittest.main()

View File

@ -91,7 +91,3 @@ class TestMsgApplysettings(common.TrezorTest):
proto.Success(), proto.Success(),
proto.Features()]) proto.Features()])
self.client.apply_settings(homescreen=img) self.client.apply_settings(homescreen=img)
if __name__ == '__main__':
unittest.main()

View File

@ -216,7 +216,3 @@ class TestMsgChangepin(common.TrezorTest):
features = self.client.call_raw(proto.Initialize()) features = self.client.call_raw(proto.Initialize())
self.assertTrue(features.pin_protection) self.assertTrue(features.pin_protection)
self.assertEqual(self.client.debug.read_pin()[0], self.pin4) self.assertEqual(self.client.debug.read_pin()[0], self.pin4)
if __name__ == '__main__':
unittest.main()

View File

@ -86,7 +86,3 @@ class TestMsgCipherkeyvalue(common.TrezorTest):
def test_decrypt_badlen(self): def test_decrypt_badlen(self):
self.setup_mnemonic_nopin_nopassphrase() self.setup_mnemonic_nopin_nopassphrase()
self.assertRaises(Exception, self.client.decrypt_keyvalue, [0, 1, 2], b"test", b"testing") self.assertRaises(Exception, self.client.decrypt_keyvalue, [0, 1, 2], b"test", b"testing")
if __name__ == '__main__':
unittest.main()

View File

@ -52,7 +52,3 @@ class TestMsgClearsession(common.TrezorTest):
self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Success()]) self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Success()])
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True) res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
self.assertEqual(res, 'random data') self.assertEqual(res, 'random data')
if __name__ == '__main__':
unittest.main()

View File

@ -1,54 +0,0 @@
# This file is part of the TREZOR project.
#
# Copyright (C) 2012-2016 Marek Palatinus <slush@satoshilabs.com>
# Copyright (C) 2012-2016 Pavol Rusnak <stick@satoshilabs.com>
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
import unittest
import binascii
import common
import trezorlib.types_pb2 as proto_types
class TestMsgEstimatetxsize(common.TrezorTest):
def test_estimate_size(self):
self.setup_mnemonic_nopin_nopassphrase()
inp1 = proto_types.TxInputType(
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
# amount=390000,
prev_hash=binascii.unhexlify('d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882'),
prev_index=0,
)
out1 = proto_types.TxOutputType(
address='1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1',
amount=390000 - 10000,
script_type=proto_types.PAYTOADDRESS,
)
est_size = self.client.estimate_tx_size('Bitcoin', [inp1, ], [out1, ])
self.assertEqual(est_size, 194)
(_, tx) = self.client.sign_tx('Bitcoin', [inp1, ], [out1, ])
real_size = len(tx)
self.assertGreaterEqual(est_size, real_size)
if __name__ == '__main__':
unittest.main()

View File

@ -30,7 +30,3 @@ class TestMsgEthereumGetaddress(common.TrezorTest):
self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([0, -1])), b'e5d96dfa07bcf1a3ae43677840c31394258861bf') self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([0, -1])), b'e5d96dfa07bcf1a3ae43677840c31394258861bf')
self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([-9, 0])), b'f68804ac9eca9483ab4241d3e4751590d2c05102') self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([-9, 0])), b'f68804ac9eca9483ab4241d3e4751590d2c05102')
self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([0, 9999999])), b'7a6366ecfcaf0d5dcc1539c171696c6cdd1eb8ed') self.assertEqual(binascii.hexlify(self.client.ethereum_get_address([0, 9999999])), b'7a6366ecfcaf0d5dcc1539c171696c6cdd1eb8ed')
if __name__ == '__main__':
unittest.main()

View File

@ -33,7 +33,3 @@ class TestMsgEthereumSignmessage(common.TrezorTest):
sig = self.client.ethereum_sign_message([0], 'VeryLongMessage!' * 64) sig = self.client.ethereum_sign_message([0], 'VeryLongMessage!' * 64)
self.assertEqual(binascii.hexlify(sig.address), b'cb3864960e8db1a751212c580af27ee8867d688f') self.assertEqual(binascii.hexlify(sig.address), b'cb3864960e8db1a751212c580af27ee8867d688f')
self.assertEqual(binascii.hexlify(sig.signature), b'70d03c8447b64489e80ae44ce4f1a543e8eb5dd9e9a19c4743ce95fbd9b8234b2d2a16db87cee857f5b474107ad2c0c0c86118f8a33d5df3d98b766be92d71331b') self.assertEqual(binascii.hexlify(sig.signature), b'70d03c8447b64489e80ae44ce4f1a543e8eb5dd9e9a19c4743ce95fbd9b8234b2d2a16db87cee857f5b474107ad2c0c0c86118f8a33d5df3d98b766be92d71331b')
if __name__ == '__main__':
unittest.main()

View File

@ -244,7 +244,3 @@ class TestMsgEthereumSigntx(common.TrezorTest):
self.assertEqual(sig_v, 42) self.assertEqual(sig_v, 42)
self.assertEqual(binascii.hexlify(sig_r), 'f7505f709d5999343aea3c384034c62d0514336ff6c6af65582006f708f81503') self.assertEqual(binascii.hexlify(sig_r), 'f7505f709d5999343aea3c384034c62d0514336ff6c6af65582006f708f81503')
self.assertEqual(binascii.hexlify(sig_s), '44e09e29a4b6247000b46ddc94fe391e94deb2b39ad6ac6398e6db5bec095ba9') self.assertEqual(binascii.hexlify(sig_s), '44e09e29a4b6247000b46ddc94fe391e94deb2b39ad6ac6398e6db5bec095ba9')
if __name__ == '__main__':
unittest.main()

View File

@ -39,7 +39,3 @@ class TestMsgEthereumVerifymessage(common.TrezorTest):
'VeryLongMessage!' * 64 'VeryLongMessage!' * 64
) )
self.assertTrue(ret) self.assertTrue(ret)
if __name__ == '__main__':
unittest.main()

View File

@ -58,7 +58,3 @@ class TestMsgGetaddress(common.TrezorTest):
self.assertEqual(address2, '1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb') self.assertEqual(address2, '1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb')
self.assertEqual(address1, address2) self.assertEqual(address1, address2)
if __name__ == '__main__':
unittest.main()

View File

@ -38,7 +38,3 @@ class TestMsgGetaddressSegwit(common.TrezorTest):
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i), self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i),
False, multisig1, script_type=proto_types.SPENDP2SHWITNESS), False, multisig1, script_type=proto_types.SPENDP2SHWITNESS),
'2N2MxyAfifVhb3AMagisxaj3uij8bfXqf4Y') '2N2MxyAfifVhb3AMagisxaj3uij8bfXqf4Y')
if __name__ == '__main__':
unittest.main()

View File

@ -41,7 +41,3 @@ class TestMsgGetaddressSegwitNative(common.TrezorTest):
self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i), self.assertEqual(self.client.get_address("Testnet", self.client.expand_path("999'/1'/%d'/2/0" % i),
False, multisig1, script_type=proto_types.SPENDWITNESS), False, multisig1, script_type=proto_types.SPENDWITNESS),
'T7nY3A3kewpDKumsdhonP4TBDfTXFSc2RNhZxkqmeeszRDHjM5yUn') 'T7nY3A3kewpDKumsdhonP4TBDfTXFSc2RNhZxkqmeeszRDHjM5yUn')
if __name__ == '__main__':
unittest.main()

View File

@ -64,7 +64,3 @@ class TestMsgGetaddress(common.TrezorTest):
for i in range(15): for i in range(15):
self.assertEqual(self.client.get_address('Bitcoin', [i], show_display=True, multisig=multisig), '3QaKF8zobqcqY8aS6nxCD5ZYdiRfL3RCmU') self.assertEqual(self.client.get_address('Bitcoin', [i], show_display=True, multisig=multisig), '3QaKF8zobqcqY8aS6nxCD5ZYdiRfL3RCmU')
if __name__ == '__main__':
unittest.main()

View File

@ -49,7 +49,3 @@ class TestMsgGetentropy(common.TrezorTest):
ent = self.client.get_entropy(l) ent = self.client.get_entropy(l)
self.assertTrue(len(ent) == l) self.assertTrue(len(ent) == l)
print('entropy = ', entropy(ent)) print('entropy = ', entropy(ent))
if __name__ == '__main__':
unittest.main()

View File

@ -42,7 +42,3 @@ class TestMsgGetpublic_key(common.TrezorTest):
def test_tbtc(self): def test_tbtc(self):
self.setup_mnemonic_nopin_nopassphrase() self.setup_mnemonic_nopin_nopassphrase()
self.assertEqual(bip32.serialize(self.client.get_public_node([111, 42]).node, 0x043587CF), 'tpubDAgixSyai5PWbc8N1mBkHDR5nLgAnHFtY7r4y5EzxqAxrt9YUDpZL3kaRoHVvCfrcwNo31c2isBP2uTHcZxEosuKbyJhCAbrvGoPuLUZ7Mz') self.assertEqual(bip32.serialize(self.client.get_public_node([111, 42]).node, 0x043587CF), 'tpubDAgixSyai5PWbc8N1mBkHDR5nLgAnHFtY7r4y5EzxqAxrt9YUDpZL3kaRoHVvCfrcwNo31c2isBP2uTHcZxEosuKbyJhCAbrvGoPuLUZ7Mz')
if __name__ == '__main__':
unittest.main()

View File

@ -87,7 +87,3 @@ class TestDeviceLoad(common.TrezorTest):
self.assertEqual(address_nfkd, address_nfc) self.assertEqual(address_nfkd, address_nfc)
self.assertEqual(address_nfkd, address_nfkc) self.assertEqual(address_nfkd, address_nfkc)
self.assertEqual(address_nfkd, address_nfd) self.assertEqual(address_nfkd, address_nfd)
if __name__ == '__main__':
unittest.main()

View File

@ -41,7 +41,3 @@ class TestDeviceLoadXprv(common.TrezorTest):
address = self.client.get_address('Bitcoin', []) address = self.client.get_address('Bitcoin', [])
self.assertEqual(address, '1CHUbFa4wTTPYgkYaw2LHSd5D4qJjMU8ri') self.assertEqual(address, '1CHUbFa4wTTPYgkYaw2LHSd5D4qJjMU8ri')
if __name__ == '__main__':
unittest.main()

View File

@ -61,7 +61,3 @@ class TestPing(common.TrezorTest):
self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Success()]) self.client.set_expected_responses([proto.ButtonRequest(code=proto_types.ButtonRequest_ProtectCall), proto.Success()])
res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True) res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True)
self.assertEqual(res, 'random data') self.assertEqual(res, 'random data')
if __name__ == '__main__':
unittest.main()

View File

@ -172,7 +172,3 @@ class TestDeviceRecovery(common.TrezorTest):
def test_already_initialized(self): def test_already_initialized(self):
self.setup_mnemonic_nopin_nopassphrase() self.setup_mnemonic_nopin_nopassphrase()
self.assertRaises(Exception, self.client.recovery_device, 12, False, False, 'label', 'english') self.assertRaises(Exception, self.client.recovery_device, 12, False, False, 'label', 'english')
if __name__ == '__main__':
unittest.main()

View File

@ -69,7 +69,3 @@ class TestDeviceRecoveryDryRun(common.TrezorTest):
self.setup_mnemonic_nopin_nopassphrase() self.setup_mnemonic_nopin_nopassphrase()
mnemonic = ['stick'] * 12 mnemonic = ['stick'] * 12
self.recovery_loop(mnemonic, proto.Failure) self.recovery_loop(mnemonic, proto.Failure)
if __name__ == '__main__':
unittest.main()

View File

@ -203,7 +203,3 @@ class TestDeviceReset(common.TrezorTest):
def test_already_initialized(self): def test_already_initialized(self):
self.setup_mnemonic_nopin_nopassphrase() self.setup_mnemonic_nopin_nopassphrase()
self.assertRaises(Exception, self.client.reset_device, False, 128, True, True, 'label', 'english') self.assertRaises(Exception, self.client.reset_device, False, 128, True, True, 'label', 'english')
if __name__ == '__main__':
unittest.main()

View File

@ -128,7 +128,3 @@ class TestDeviceResetSkipBackup(common.TrezorTest):
self.setup_mnemonic_nopin_nopassphrase() self.setup_mnemonic_nopin_nopassphrase()
ret = self.client.call_raw(proto.BackupDevice()) ret = self.client.call_raw(proto.BackupDevice())
self.assertIsInstance(ret, proto.Failure) self.assertIsInstance(ret, proto.Failure)
if __name__ == '__main__':
unittest.main()

View File

@ -91,7 +91,3 @@ class TestMsgSignidentity(common.TrezorTest):
self.assertEqual(sig.address, '') self.assertEqual(sig.address, '')
self.assertEqual(binascii.hexlify(sig.public_key), b'000fac2a491e0f5b871dc48288a4cae551bac5cb0ed19df0764d6e721ec5fade18') self.assertEqual(binascii.hexlify(sig.public_key), b'000fac2a491e0f5b871dc48288a4cae551bac5cb0ed19df0764d6e721ec5fade18')
self.assertEqual(binascii.hexlify(sig.signature), b'00f05e5085e666429de397c70a081932654369619c0bd2a6579ea6c1ef2af112ef79998d6c862a16b932d44b1ac1b83c8cbcd0fbda228274fde9e0d0ca6e9cb709') self.assertEqual(binascii.hexlify(sig.signature), b'00f05e5085e666429de397c70a081932654369619c0bd2a6579ea6c1ef2af112ef79998d6c862a16b932d44b1ac1b83c8cbcd0fbda228274fde9e0d0ca6e9cb709')
if __name__ == '__main__':
unittest.main()

View File

@ -54,7 +54,3 @@ class TestMsgSignmessage(common.TrezorTest):
sig_nfc = self.client.sign_message('Bitcoin', [0], words_nfc) sig_nfc = self.client.sign_message('Bitcoin', [0], words_nfc)
self.assertEqual(sig_nfc.address, '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e') self.assertEqual(sig_nfc.address, '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e')
self.assertEqual(binascii.hexlify(sig_nfc.signature), b'20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6') self.assertEqual(binascii.hexlify(sig_nfc.signature), b'20d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
if __name__ == '__main__':
unittest.main()

View File

@ -56,7 +56,3 @@ class TestMsgSignmessage(common.TrezorTest):
sig_nfc = self.client.sign_message('Bitcoin', [0], words_nfc, script_type=proto_types.SPENDP2SHWITNESS) sig_nfc = self.client.sign_message('Bitcoin', [0], words_nfc, script_type=proto_types.SPENDP2SHWITNESS)
self.assertEqual(sig_nfc.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1') self.assertEqual(sig_nfc.address, '3CwYaeWxhpXXiHue3ciQez1DLaTEAXcKa1')
self.assertEqual(binascii.hexlify(sig_nfc.signature), b'24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6') self.assertEqual(binascii.hexlify(sig_nfc.signature), b'24d0ec02ed8da8df23e7fe9e680e7867cc290312fe1c970749d8306ddad1a1eda41c6a771b13d495dd225b13b0a9d0f915a984ee3d0703f92287bf8009fbb9f7d6')
if __name__ == '__main__':
unittest.main()

View File

@ -731,7 +731,3 @@ class TestMsgSigntx(common.TrezorTest):
# Accepted by network: tx # Accepted by network: tx
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000136825bfdb78c8ede226c7c4f25a018e99a2c061d63c7fb425fca7c7d6721dad6000000006a473044022047845c366eb24f40be315c7815a154513c444c7989eb80f7ce7ff6aeb703d26a022007c1f5efadf67c5889634fd7ac39a7ce78bffac291673e8772ecd8389c901d9f01210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff01c6100795000000001976a9143d2496e67f5f57a924353da42d4725b318e7a8ea88ac00000000') self.assertEqual(binascii.hexlify(serialized_tx), b'010000000136825bfdb78c8ede226c7c4f25a018e99a2c061d63c7fb425fca7c7d6721dad6000000006a473044022047845c366eb24f40be315c7815a154513c444c7989eb80f7ce7ff6aeb703d26a022007c1f5efadf67c5889634fd7ac39a7ce78bffac291673e8772ecd8389c901d9f01210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a6ffffffff01c6100795000000001976a9143d2496e67f5f57a924353da42d4725b318e7a8ea88ac00000000')
if __name__ == '__main__':
unittest.main()

View File

@ -204,7 +204,3 @@ class TestMsgSigntxSegwit(common.TrezorTest):
proto.Failure(code=proto_types.Failure_ProcessError), proto.Failure(code=proto_types.Failure_ProcessError),
]) ])
self.assertRaises(CallException, self.client.sign_tx, 'Testnet Cash', [inp1, inp2], [out1, out2], debug_processor=attack_processor) self.assertRaises(CallException, self.client.sign_tx, 'Testnet Cash', [inp1, inp2], [out1, out2], debug_processor=attack_processor)
if __name__ == '__main__':
unittest.main()

View File

@ -237,7 +237,3 @@ class TestMsgSigntxSegwit(common.TrezorTest):
proto.Failure(code=proto_types.Failure_ProcessError), proto.Failure(code=proto_types.Failure_ProcessError),
]) ])
self.assertRaises(CallException, self.client.sign_tx, 'Testnet', [inp1], [out1, out2], debug_processor=attack_processor) self.assertRaises(CallException, self.client.sign_tx, 'Testnet', [inp1], [out1, out2], debug_processor=attack_processor)
if __name__ == '__main__':
unittest.main()

View File

@ -476,7 +476,3 @@ class TestMsgSigntxSegwit(common.TrezorTest):
# c0bf56060a109624b4635222696d94a7d533cacea1b3f8245417a4348c045829 # c0bf56060a109624b4635222696d94a7d533cacea1b3f8245417a4348c045829
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000000101e5918f661488bb7f0a7d04fc1dad61b5d0bad5167a05b3a637e36ace881cbc3100000000232200205b9824093eaf5cdcf8247c00dc0b557a7720957828fcde8384ac11f80a91f403ffffffff01d071180000000000220020e77caf5fbef07b1e461475c02afd4aed877693263d69c81e14617304349b629a040047304402204832553b0da1009da496881e58e8e2e41010cfe5c0161623048093f1b1a817b7022020dad8bf887acf574af80bfe4b39cd24e95019fd5e6b8ae967471e21ddc67354014830450221009e5d60847e7275edcf4619ed8ee462c56a042eef75d17da2d44e6b13d78e50e50220665195492900ef87a5eb8a924fa0ac9afc4fc75ca704ff356dc3a213979970c80169522103f4040006e3561b3e76c6d4113225c84748ab9d55ffd23f9578ab4c18fb0c3b9721020975f2e6922897ff6b80da6412a8d6ebd67e33c9611d081656a53ef967964e5021026b0546f23a6ce6b756c2c30b4176ce6f1c3268744f7aca82668d5116c4f764e453ae00000000') self.assertEqual(binascii.hexlify(serialized_tx), b'01000000000101e5918f661488bb7f0a7d04fc1dad61b5d0bad5167a05b3a637e36ace881cbc3100000000232200205b9824093eaf5cdcf8247c00dc0b557a7720957828fcde8384ac11f80a91f403ffffffff01d071180000000000220020e77caf5fbef07b1e461475c02afd4aed877693263d69c81e14617304349b629a040047304402204832553b0da1009da496881e58e8e2e41010cfe5c0161623048093f1b1a817b7022020dad8bf887acf574af80bfe4b39cd24e95019fd5e6b8ae967471e21ddc67354014830450221009e5d60847e7275edcf4619ed8ee462c56a042eef75d17da2d44e6b13d78e50e50220665195492900ef87a5eb8a924fa0ac9afc4fc75ca704ff356dc3a213979970c80169522103f4040006e3561b3e76c6d4113225c84748ab9d55ffd23f9578ab4c18fb0c3b9721020975f2e6922897ff6b80da6412a8d6ebd67e33c9611d081656a53ef967964e5021026b0546f23a6ce6b756c2c30b4176ce6f1c3268744f7aca82668d5116c4f764e453ae00000000')
if __name__ == '__main__':
unittest.main()

View File

@ -72,7 +72,3 @@ class TestMsgSigntx(common.TrezorTest):
# Accepted by network: tx dcc2a10894e0e8a785c2afd4de2d958207329b9acc2b987fd768a09c5efc4547 # Accepted by network: tx dcc2a10894e0e8a785c2afd4de2d958207329b9acc2b987fd768a09c5efc4547
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000015c2f725c959f9b0c66db42f185a9ebb51b51d675d79a047d4a6c62cc633e3793000000006a4730440220670b2b63d749a7038f9aea6ddf0302fe63bdcad93dafa4a89a1f0e7300ae2484022002c50af43fd867490cea0c527273c5828ff1b9a5115678f155a1830737cf29390121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0ffffffff0128c55b07000000001976a9145b157a678a10021243307e4bb58f36375aa80e1088ac00000000') self.assertEqual(binascii.hexlify(serialized_tx), b'01000000015c2f725c959f9b0c66db42f185a9ebb51b51d675d79a047d4a6c62cc633e3793000000006a4730440220670b2b63d749a7038f9aea6ddf0302fe63bdcad93dafa4a89a1f0e7300ae2484022002c50af43fd867490cea0c527273c5828ff1b9a5115678f155a1830737cf29390121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0ffffffff0128c55b07000000001976a9145b157a678a10021243307e4bb58f36375aa80e1088ac00000000')
if __name__ == '__main__':
unittest.main()

View File

@ -160,7 +160,3 @@ class TestMsgVerifymessage(common.TrezorTest):
self.assertTrue(res_nfkd) self.assertTrue(res_nfkd)
self.assertTrue(res_nfc) self.assertTrue(res_nfc)
if __name__ == '__main__':
unittest.main()

View File

@ -96,7 +96,3 @@ class TestMsgVerifymessageSegwit(common.TrezorTest):
self.assertTrue(res_nfkd) self.assertTrue(res_nfkd)
self.assertTrue(res_nfc) self.assertTrue(res_nfc)
if __name__ == '__main__':
unittest.main()

View File

@ -40,7 +40,3 @@ class TestDeviceWipe(common.TrezorTest):
self.assertEqual(features.pin_protection, False) self.assertEqual(features.pin_protection, False)
self.assertEqual(features.passphrase_protection, False) self.assertEqual(features.passphrase_protection, False)
self.assertNotEqual(features.device_id, device_id) self.assertNotEqual(features.device_id, device_id)
if __name__ == '__main__':
unittest.main()

View File

@ -256,7 +256,3 @@ class TestMultisig(common.TrezorTest):
with self.client: with self.client:
# It should throw Failure 'Pubkey not found in multisig script' # It should throw Failure 'Pubkey not found in multisig script'
self.assertRaises(CallException, self.client.sign_tx, 'Bitcoin', [inp1, ], [out1, ]) self.assertRaises(CallException, self.client.sign_tx, 'Bitcoin', [inp1, ], [out1, ])
if __name__ == '__main__':
unittest.main()

View File

@ -375,7 +375,3 @@ class TestMultisigChange(common.TrezorTest):
(_, serialized_tx) = self.client.sign_tx('Bitcoin', [self.inp1, self.inp3, ], [out1, out2, ]) (_, serialized_tx) = self.client.sign_tx('Bitcoin', [self.inp1, self.inp3, ], [out1, out2, ])
self.assertEqual(binascii.hexlify(serialized_tx), b'01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b40047304402204b7d6c7e9feef91209cbdf4deaf855696dc22a40e57bd3eafd5e00b0ee41d9de0220262c5a05d0b46ef98fddfef3831b3ebb6841ffbeb10666f8fb6f8d2e3023e30d014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffffe39b254db8137202c7690cb0c6738f2e61661ce16f92b3f2087a00e5e51abce401000000b500483045022100bb2118da21c8a84f115b655f640f269a40be77ae2c0af9c5ffd8260a85dbfc7702202e7b5b6c05b8f50bd879dbee88828e80e85448d686b63a1a50e99d921923f6f5014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e2102e0c21e2a7cf00b94c5421725acff97f9826598b91f2340c5ddda730caca7d648210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff02a08601000000000017a914a4efc33d43d7a8a0040182c76ab624ff862f50d287a08601000000000017a9147615527d78854293edadf83682ea26937f8a51bb8700000000') self.assertEqual(binascii.hexlify(serialized_tx), b'01000000023da7e83c25051d520133e56bfa86206352a285988e096bd14aaf5532a68ed0d100000000b40047304402204b7d6c7e9feef91209cbdf4deaf855696dc22a40e57bd3eafd5e00b0ee41d9de0220262c5a05d0b46ef98fddfef3831b3ebb6841ffbeb10666f8fb6f8d2e3023e30d014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e210388460dc439f4c8f5bcfc268c36e11b4375cad5c3535c336cfdf8c32c3afad5c1210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffffe39b254db8137202c7690cb0c6738f2e61661ce16f92b3f2087a00e5e51abce401000000b500483045022100bb2118da21c8a84f115b655f640f269a40be77ae2c0af9c5ffd8260a85dbfc7702202e7b5b6c05b8f50bd879dbee88828e80e85448d686b63a1a50e99d921923f6f5014c69522102c0d0c5fee952620757c6128dbf327c996cd72ed3358d15d6518a1186099bc15e2102e0c21e2a7cf00b94c5421725acff97f9826598b91f2340c5ddda730caca7d648210338d78612e990f2eea0c426b5e48a8db70b9d7ed66282b3b26511e0b1c75515a653aeffffffff02a08601000000000017a914a4efc33d43d7a8a0040182c76ab624ff862f50d287a08601000000000017a9147615527d78854293edadf83682ea26937f8a51bb8700000000')
if __name__ == '__main__':
unittest.main()

View File

@ -113,7 +113,3 @@ class TestOpReturn(common.TrezorTest):
proto.Failure() proto.Failure()
]) ])
self.assertRaises(CallException, self.client.sign_tx, 'Bitcoin', [inp1, ], [out1, ]) self.assertRaises(CallException, self.client.sign_tx, 'Bitcoin', [inp1, ], [out1, ])
if __name__ == '__main__':
unittest.main()

View File

@ -132,7 +132,3 @@ class TestProtectCall(common.TrezorTest):
start = time.time() start = time.time()
self.assertRaises(PinException, self._some_protected_call, False, True, False) self.assertRaises(PinException, self._some_protected_call, False, True, False)
test_backoff(attempt, start) test_backoff(attempt, start)
if __name__ == '__main__':
unittest.main()

View File

@ -227,7 +227,3 @@ class TestProtectionLevels(common.TrezorTest):
# def test_firmware_upload(self): # def test_firmware_upload(self):
# pass # pass
if __name__ == '__main__':
unittest.main()

View File

@ -116,7 +116,3 @@ class TestZeroSig(common.TrezorTest):
# TREZOR must strip leading zero from signature # TREZOR must strip leading zero from signature
self.assertEqual(siglen, 66) self.assertEqual(siglen, 66)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1 @@
{"txid": "d2dcdaf547ea7f57a713c607f15e883ddc4a98167ee2c43ed953c53cb5153e24", "version": 1, "locktime": 0, "vin": [{"txid": "4e686d9815219fc2e57baae29c3b44567693b96fbe150550c269786fbbc6d653", "vout": 0, "sequence": 4294967295, "n": 0, "scriptSig": {"hex": "160014e31581ae69eca39192917940e6604fe6546441c0", "asm": "0014e31581ae69eca39192917940e6604fe6546441c0"}, "addr": "2N2Bw4ofaXx79bEdmG556FMGqa2EWmzJKr8", "valueSat": 2870562139, "value": 28.70562139, "doubleSpentTxID": null}], "vout": [{"value": "27.47158341", "n": 0, "scriptPubKey": {"hex": "a914f96f26251d4edd4c915aa76885dc0a91ec83df1087", "asm": "OP_HASH160 f96f26251d4edd4c915aa76885dc0a91ec83df10 OP_EQUAL", "addresses": ["2NFz7PpPg58HExT4stQDFoqpqduKaiwApqu"], "type": "scripthash"}, "spentTxId": "fe26bc077de27b72ffc5ce77a7e296c7c855b7deb3dec72a3f82c0c07c722bb0", "spentIndex": 0, "spentHeight": 1155197}, {"value": "1.23400000", "n": 1, "scriptPubKey": {"hex": "76a9145740ddea127387c6650ab531994fe6a29b0cec3388ac", "asm": "OP_DUP OP_HASH160 5740ddea127387c6650ab531994fe6a29b0cec33 OP_EQUALVERIFY OP_CHECKSIG", "addresses": ["moUJnmge8SRXuediK7bW6t4YfrPqbE6hD7"], "type": "pubkeyhash"}, "spentTxId": null, "spentIndex": null, "spentHeight": null}], "blockhash": "000000000000061da5f05a6cfbe100b95895e42878d479c30b0f7c1ebfe786ed", "blockheight": 1155197, "confirmations": 148, "time": 1501158191, "blocktime": 1501158191, "valueOut": 28.70558341, "size": 140, "valueIn": 28.70562139, "fees": 3.798e-05}

View File

@ -0,0 +1 @@
{"txid": "fe26bc077de27b72ffc5ce77a7e296c7c855b7deb3dec72a3f82c0c07c722bb0", "version": 1, "locktime": 0, "vin": [{"txid": "d2dcdaf547ea7f57a713c607f15e883ddc4a98167ee2c43ed953c53cb5153e24", "vout": 0, "sequence": 4294967295, "n": 0, "scriptSig": {"hex": "160014d3b73f29a0acf580b6310ab8a6cb7a3328c082e5", "asm": "0014d3b73f29a0acf580b6310ab8a6cb7a3328c082e5"}, "addr": "2NFz7PpPg58HExT4stQDFoqpqduKaiwApqu", "valueSat": 2747158341, "value": 27.47158341, "doubleSpentTxID": null}], "vout": [{"value": "27.03944543", "n": 0, "scriptPubKey": {"hex": "a9144684ab712fd939e2c8f16dc8d466ceeacd968ab987", "asm": "OP_HASH160 4684ab712fd939e2c8f16dc8d466ceeacd968ab9 OP_EQUAL", "addresses": ["2Myg6DmGrwnkuFaXEtYgi1dsTHTy62Pg4hE"], "type": "scripthash"}, "spentTxId": null, "spentIndex": null, "spentHeight": null}, {"value": "0.43210000", "n": 1, "scriptPubKey": {"hex": "76a914151fc2ae3cee358d808d5656ed1e9f18b2cffaef88ac", "asm": "OP_DUP OP_HASH160 151fc2ae3cee358d808d5656ed1e9f18b2cffaef OP_EQUALVERIFY OP_CHECKSIG", "addresses": ["mhSeXqbaojGkaezxgwobgMxGHzv79x7rhK"], "type": "pubkeyhash"}, "spentTxId": null, "spentIndex": null, "spentHeight": null}], "blockhash": "000000000000061da5f05a6cfbe100b95895e42878d479c30b0f7c1ebfe786ed", "blockheight": 1155197, "confirmations": 148, "time": 1501158191, "blocktime": 1501158191, "valueOut": 27.47154543, "size": 140, "valueIn": 27.47158341, "fees": 3.798e-05}

View File

@ -909,7 +909,7 @@ class ProtocolMixin(object):
@field('message') @field('message')
@expect(proto.Success) @expect(proto.Success)
@session @session
def reset_device(self, display_random, strength, passphrase_protection, pin_protection, label, language, u2f_counter, skip_backup): def reset_device(self, display_random, strength, passphrase_protection, pin_protection, label, language, u2f_counter=0, skip_backup=False):
if self.features.initialized: if self.features.initialized:
raise Exception("Device is initialized already. Call wipe_device() and try again.") raise Exception("Device is initialized already. Call wipe_device() and try again.")