2016-05-20 13:27:20 -07:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2013-01-14 05:44:31 -08:00
|
|
|
import unittest
|
2014-02-13 07:47:28 -08:00
|
|
|
from trezorlib.client import TrezorDebugClient
|
2014-03-28 13:34:15 -07:00
|
|
|
from trezorlib.tx_api import TXAPIBitcoin
|
2016-05-26 08:20:44 -07:00
|
|
|
import config
|
2013-01-14 05:44:31 -08:00
|
|
|
|
2013-09-12 20:28:56 -07:00
|
|
|
class TrezorTest(unittest.TestCase):
|
2013-01-14 05:44:31 -08:00
|
|
|
def setUp(self):
|
2014-02-04 07:12:52 -08:00
|
|
|
self.debug_transport = config.DEBUG_TRANSPORT(*config.DEBUG_TRANSPORT_ARGS, **config.DEBUG_TRANSPORT_KWARGS)
|
|
|
|
self.transport = config.TRANSPORT(*config.TRANSPORT_ARGS, **config.TRANSPORT_KWARGS)
|
2014-02-13 07:47:28 -08:00
|
|
|
self.client = TrezorDebugClient(self.transport)
|
|
|
|
self.client.set_debuglink(self.debug_transport)
|
2015-07-22 08:32:28 -07:00
|
|
|
self.client.set_tx_api(TXAPIBitcoin())
|
2014-12-10 06:26:18 -08:00
|
|
|
# self.client.set_buttonwait(3)
|
2013-09-12 20:28:56 -07:00
|
|
|
|
2014-03-07 12:44:27 -08:00
|
|
|
# 1 2 3 4 5 6 7 8 9 10 11 12
|
2014-02-16 16:54:54 -08:00
|
|
|
self.mnemonic12 = 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle'
|
|
|
|
self.mnemonic18 = 'owner little vague addict embark decide pink prosper true fork panda embody mixture exchange choose canoe electric jewel'
|
|
|
|
self.mnemonic24 = 'dignity pass list indicate nasty swamp pool script soccer toe leaf photo multiply desk host tomato cradle drill spread actor shine dismiss champion exotic'
|
2016-10-21 06:24:30 -07:00
|
|
|
self.mnemonic_all = ' '.join(['all'] * 12)
|
2013-09-12 20:28:56 -07:00
|
|
|
|
2014-02-16 16:54:54 -08:00
|
|
|
self.pin4 = '1234'
|
|
|
|
self.pin6 = '789456'
|
|
|
|
self.pin8 = '45678978'
|
2013-09-12 20:28:56 -07:00
|
|
|
|
2014-02-16 16:54:54 -08:00
|
|
|
self.client.wipe_device()
|
2013-09-12 20:28:56 -07:00
|
|
|
|
2016-05-04 18:16:17 -07:00
|
|
|
print("Setup finished")
|
|
|
|
print("--------------")
|
2014-02-16 16:54:54 -08:00
|
|
|
|
2016-10-21 06:24:30 -07:00
|
|
|
def setup_mnemonic_allallall(self):
|
|
|
|
self.client.load_device_by_mnemonic(mnemonic=self.mnemonic_all, pin='', passphrase_protection=False, label='test', language='english')
|
|
|
|
|
2014-02-16 16:54:54 -08:00
|
|
|
def setup_mnemonic_nopin_nopassphrase(self):
|
|
|
|
self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12, pin='', passphrase_protection=False, label='test', language='english')
|
|
|
|
|
2014-12-13 10:07:30 -08:00
|
|
|
def setup_mnemonic_pin_nopassphrase(self):
|
|
|
|
self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12, pin=self.pin4, passphrase_protection=False, label='test', language='english')
|
|
|
|
|
2014-02-16 16:54:54 -08:00
|
|
|
def setup_mnemonic_pin_passphrase(self):
|
|
|
|
self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12, pin=self.pin4, passphrase_protection=True, label='test', language='english')
|
|
|
|
|
2013-01-14 05:44:31 -08:00
|
|
|
def tearDown(self):
|
2014-02-13 08:20:40 -08:00
|
|
|
self.client.close()
|