mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 17:38:39 +00:00
Fixed tests
This commit is contained in:
parent
981cf2ce7a
commit
c6db133907
@ -10,18 +10,22 @@ class TrezorTest(unittest.TestCase):
|
||||
self.transport = config.TRANSPORT(*config.TRANSPORT_ARGS)
|
||||
self.client = TrezorClient(self.transport, DebugLink(self.debug_transport), debug=True)
|
||||
|
||||
self.mnemonic1 = 'juice enrich pool orbit brick prevent system chronic people industry insane private'
|
||||
self.mnemonic2 = 'bark depend buffalo library lonely syrup exact trip kitten yellow arch into damage phone toy wild color soon suit move opinion type replace donate'
|
||||
self.mnemonic1 = 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle'
|
||||
self.mnemonic2 = 'owner little vague addict embark decide pink prosper true fork panda embody mixture exchange choose canoe electric jewel'
|
||||
self.pin1 = '1234'
|
||||
self.pin2 = '43211'
|
||||
|
||||
self.client.setup_debuglink(button=True, pin_correct=True)
|
||||
|
||||
self.client.load_device(
|
||||
self.client.load_device_by_mnemonic(
|
||||
mnemonic=self.mnemonic1,
|
||||
pin=self.pin1)
|
||||
pin=self.pin1,
|
||||
passphrase_protection=False,
|
||||
label='test',
|
||||
language='english',
|
||||
)
|
||||
|
||||
self.client.apply_settings(label='unit testing', coin_shortcut='BTC', language='english')
|
||||
# self.client.apply_settings(label='unit testing', coin_shortcut='BTC', language='english')
|
||||
|
||||
print "Setup finished"
|
||||
print "--------------"
|
||||
|
@ -3,30 +3,39 @@ import common
|
||||
|
||||
class TestAddresses(common.TrezorTest):
|
||||
def test_btc(self):
|
||||
self.client.load_device(seed=self.mnemonic1, pin='')
|
||||
self.client.apply_settings(coin_shortcut='BTC')
|
||||
self.client.load_device_by_mnemonic(mnemonic=self.mnemonic1,
|
||||
pin='',
|
||||
passphrase_protection=False,
|
||||
label='test',
|
||||
language='english')
|
||||
|
||||
self.assertEqual(self.client.get_address([]), '1GBDQapuquKZGPxWTB39s5bayLDTv5sD77')
|
||||
self.assertEqual(self.client.get_address([1]), '13HWRT9JtftSF6uv65eMrQowHn3CioKegP')
|
||||
self.assertEqual(self.client.get_address([0, 1]), '1GnnT11aZeH6QZCtT7EjCvRF3EXHoY3owE')
|
||||
self.assertEqual(self.client.get_address([9, 0]), '1KeRRK74ARTxnby8dYsm2UreAx5tBGbbY7')
|
||||
self.assertEqual(self.client.get_address([0, 9999999]), '1JeDAdRMxeuWCQ8ohWySCD5KEPoN2sEanK')
|
||||
self.assertEqual(self.client.get_address('Bitcoin', []), '1EfKbQupktEMXf4gujJ9kCFo83k1iMqwqK')
|
||||
self.assertEqual(self.client.get_address('Bitcoin', [1]), '1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb')
|
||||
self.assertEqual(self.client.get_address('Bitcoin', [0, -1]), '1JVq66pzRBvqaBRFeU9SPVvg3er4ZDgoMs')
|
||||
self.assertEqual(self.client.get_address('Bitcoin', [-9, 0]), '1F4YdQdL9ZQwvcNTuy5mjyQxXkyCfMcP2P')
|
||||
self.assertEqual(self.client.get_address('Bitcoin', [0, 9999999]), '1GS8X3yc7ntzwGw9vXwj9wqmBWZkTFewBV')
|
||||
|
||||
def test_ltc(self):
|
||||
self.client.load_device(seed=self.mnemonic1, pin='')
|
||||
self.client.apply_settings(coin_shortcut='LTC')
|
||||
self.client.load_device_by_mnemonic(mnemonic=self.mnemonic1,
|
||||
pin='',
|
||||
passphrase_protection=False,
|
||||
label='test',
|
||||
language='english')
|
||||
|
||||
self.assertEqual(self.client.get_address([]), 'LaQAfo8jvZZcXCefdK2T96fMBYak5XomhR')
|
||||
self.assertEqual(self.client.get_address([1]), 'LMWTgfT8yL8VVuc5GDdf8RshVzQUw9AoUK')
|
||||
self.assertEqual(self.client.get_address([0, 1]), 'Lb1jiDKQeJX9fMu3dFE2UwV1FStZwvijfE')
|
||||
self.assertEqual(self.client.get_address([9, 0]), 'LdsNgXQtF5i23QfHogs4JVvQPATAFbfWYA')
|
||||
self.assertEqual(self.client.get_address([0, 9999999]), 'LcsARqjC3K9ZTCpxsexjUE95ScAeEPqR69')
|
||||
self.assertEqual(self.client.get_address('Litecoin', []), 'LYtGrdDeqYUQnTkr5sHT2DKZLG7Hqg7HTK')
|
||||
self.assertEqual(self.client.get_address('Litecoin', [1]), 'LKRGNecThFP3Q6c5fosLVA53Z2hUDb1qnE')
|
||||
self.assertEqual(self.client.get_address('Litecoin', [0, -1]), 'LcinMK8pVrAtpz7Qpc8jfWzSFsDLgLYfG6')
|
||||
self.assertEqual(self.client.get_address('Litecoin', [-9, 0]), 'LZHVtcwAEDf1BR4d67551zUijyLUpDF9EX')
|
||||
self.assertEqual(self.client.get_address('Litecoin', [0, 9999999]), 'Laf5nGHSCT94C5dK6fw2RxuXPiw2ZuRR9S')
|
||||
|
||||
def test_tbtc(self):
|
||||
self.client.load_device(seed=self.mnemonic1, pin='')
|
||||
self.client.apply_settings(coin_shortcut='tBTC')
|
||||
self.client.load_device_by_mnemonic(mnemonic=self.mnemonic1,
|
||||
pin='',
|
||||
passphrase_protection=False,
|
||||
label='test',
|
||||
language='english')
|
||||
|
||||
self.assertEqual(self.client.get_address([111, 42]), 'mypL2oDrCj4196uuvtC6QJnsetu3YMUdB7')
|
||||
self.assertEqual(self.client.get_address('Testnet', [111, 42]), 'moN6aN6NP1KWgnPSqzrrRPvx2x1UtZJssa')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -2,8 +2,8 @@ import time
|
||||
import unittest
|
||||
import common
|
||||
|
||||
from trezorlib.client import CallException, PinException
|
||||
from trezorlib import proto
|
||||
from trezorlib.client import PinException
|
||||
# from trezorlib import messages_pb2 as proto
|
||||
|
||||
class TestProtectCall(common.TrezorTest):
|
||||
def _some_protected_call(self):
|
||||
@ -13,13 +13,23 @@ class TestProtectCall(common.TrezorTest):
|
||||
self.assertEqual(len(entropy), entropy_len)
|
||||
|
||||
def test_no_protection(self):
|
||||
self.client.load_device(seed=self.mnemonic1, pin='')
|
||||
self.client.load_device_by_mnemonic(
|
||||
mnemonic=self.mnemonic1,
|
||||
pin='',
|
||||
passphrase_protection=False,
|
||||
label='test',
|
||||
language='english',
|
||||
)
|
||||
|
||||
self.assertEqual(self.client.debuglink.read_pin()[0], '')
|
||||
self._some_protected_call()
|
||||
|
||||
def test_pin(self):
|
||||
self.client.load_device(seed=self.mnemonic1, pin=self.pin2)
|
||||
self.client.load_device_by_mnemonic(mnemonic=self.mnemonic1,
|
||||
pin=self.pin2,
|
||||
passphrase_protection=False,
|
||||
label='test',
|
||||
language='english')
|
||||
|
||||
self.assertEqual(self.client.debuglink.read_pin()[0], self.pin2)
|
||||
self._some_protected_call()
|
||||
@ -48,6 +58,7 @@ class TestProtectCall(common.TrezorTest):
|
||||
self.assertRaises(PinException, self._some_protected_call)
|
||||
test_backoff(attempt, start)
|
||||
|
||||
'''
|
||||
# Unplug Trezor now
|
||||
self.client.debuglink.stop()
|
||||
self.client.close()
|
||||
@ -64,6 +75,7 @@ class TestProtectCall(common.TrezorTest):
|
||||
print "Expected reboot time at least %s seconds" % expected
|
||||
print "Rebooted in %s seconds" % took
|
||||
self.assertLessEqual(expected, time.time() - start, "Bootup took %s seconds, expected %s seconds or more!" % (took, expected))
|
||||
'''
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user