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

Fixed tests

This commit is contained in:
slush0 2014-01-12 16:16:07 +01:00
parent 981cf2ce7a
commit c6db133907
3 changed files with 51 additions and 26 deletions

View File

@ -10,18 +10,22 @@ class TrezorTest(unittest.TestCase):
self.transport = config.TRANSPORT(*config.TRANSPORT_ARGS) self.transport = config.TRANSPORT(*config.TRANSPORT_ARGS)
self.client = TrezorClient(self.transport, DebugLink(self.debug_transport), debug=True) 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.mnemonic1 = 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle'
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.mnemonic2 = 'owner little vague addict embark decide pink prosper true fork panda embody mixture exchange choose canoe electric jewel'
self.pin1 = '1234' self.pin1 = '1234'
self.pin2 = '43211' self.pin2 = '43211'
self.client.setup_debuglink(button=True, pin_correct=True) self.client.setup_debuglink(button=True, pin_correct=True)
self.client.load_device( self.client.load_device_by_mnemonic(
mnemonic=self.mnemonic1, 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 "Setup finished"
print "--------------" print "--------------"

View File

@ -3,30 +3,39 @@ import common
class TestAddresses(common.TrezorTest): class TestAddresses(common.TrezorTest):
def test_btc(self): def test_btc(self):
self.client.load_device(seed=self.mnemonic1, pin='') self.client.load_device_by_mnemonic(mnemonic=self.mnemonic1,
self.client.apply_settings(coin_shortcut='BTC') pin='',
passphrase_protection=False,
label='test',
language='english')
self.assertEqual(self.client.get_address([]), '1GBDQapuquKZGPxWTB39s5bayLDTv5sD77') self.assertEqual(self.client.get_address('Bitcoin', []), '1EfKbQupktEMXf4gujJ9kCFo83k1iMqwqK')
self.assertEqual(self.client.get_address([1]), '13HWRT9JtftSF6uv65eMrQowHn3CioKegP') self.assertEqual(self.client.get_address('Bitcoin', [1]), '1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb')
self.assertEqual(self.client.get_address([0, 1]), '1GnnT11aZeH6QZCtT7EjCvRF3EXHoY3owE') self.assertEqual(self.client.get_address('Bitcoin', [0, -1]), '1JVq66pzRBvqaBRFeU9SPVvg3er4ZDgoMs')
self.assertEqual(self.client.get_address([9, 0]), '1KeRRK74ARTxnby8dYsm2UreAx5tBGbbY7') self.assertEqual(self.client.get_address('Bitcoin', [-9, 0]), '1F4YdQdL9ZQwvcNTuy5mjyQxXkyCfMcP2P')
self.assertEqual(self.client.get_address([0, 9999999]), '1JeDAdRMxeuWCQ8ohWySCD5KEPoN2sEanK') self.assertEqual(self.client.get_address('Bitcoin', [0, 9999999]), '1GS8X3yc7ntzwGw9vXwj9wqmBWZkTFewBV')
def test_ltc(self): def test_ltc(self):
self.client.load_device(seed=self.mnemonic1, pin='') self.client.load_device_by_mnemonic(mnemonic=self.mnemonic1,
self.client.apply_settings(coin_shortcut='LTC') pin='',
passphrase_protection=False,
label='test',
language='english')
self.assertEqual(self.client.get_address([]), 'LaQAfo8jvZZcXCefdK2T96fMBYak5XomhR') self.assertEqual(self.client.get_address('Litecoin', []), 'LYtGrdDeqYUQnTkr5sHT2DKZLG7Hqg7HTK')
self.assertEqual(self.client.get_address([1]), 'LMWTgfT8yL8VVuc5GDdf8RshVzQUw9AoUK') self.assertEqual(self.client.get_address('Litecoin', [1]), 'LKRGNecThFP3Q6c5fosLVA53Z2hUDb1qnE')
self.assertEqual(self.client.get_address([0, 1]), 'Lb1jiDKQeJX9fMu3dFE2UwV1FStZwvijfE') self.assertEqual(self.client.get_address('Litecoin', [0, -1]), 'LcinMK8pVrAtpz7Qpc8jfWzSFsDLgLYfG6')
self.assertEqual(self.client.get_address([9, 0]), 'LdsNgXQtF5i23QfHogs4JVvQPATAFbfWYA') self.assertEqual(self.client.get_address('Litecoin', [-9, 0]), 'LZHVtcwAEDf1BR4d67551zUijyLUpDF9EX')
self.assertEqual(self.client.get_address([0, 9999999]), 'LcsARqjC3K9ZTCpxsexjUE95ScAeEPqR69') self.assertEqual(self.client.get_address('Litecoin', [0, 9999999]), 'Laf5nGHSCT94C5dK6fw2RxuXPiw2ZuRR9S')
def test_tbtc(self): def test_tbtc(self):
self.client.load_device(seed=self.mnemonic1, pin='') self.client.load_device_by_mnemonic(mnemonic=self.mnemonic1,
self.client.apply_settings(coin_shortcut='tBTC') 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__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -2,8 +2,8 @@ import time
import unittest import unittest
import common import common
from trezorlib.client import CallException, PinException from trezorlib.client import PinException
from trezorlib import proto # from trezorlib import messages_pb2 as proto
class TestProtectCall(common.TrezorTest): class TestProtectCall(common.TrezorTest):
def _some_protected_call(self): def _some_protected_call(self):
@ -13,13 +13,23 @@ class TestProtectCall(common.TrezorTest):
self.assertEqual(len(entropy), entropy_len) self.assertEqual(len(entropy), entropy_len)
def test_no_protection(self): 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.assertEqual(self.client.debuglink.read_pin()[0], '')
self._some_protected_call() self._some_protected_call()
def test_pin(self): 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.assertEqual(self.client.debuglink.read_pin()[0], self.pin2)
self._some_protected_call() self._some_protected_call()
@ -48,6 +58,7 @@ class TestProtectCall(common.TrezorTest):
self.assertRaises(PinException, self._some_protected_call) self.assertRaises(PinException, self._some_protected_call)
test_backoff(attempt, start) test_backoff(attempt, start)
'''
# Unplug Trezor now # Unplug Trezor now
self.client.debuglink.stop() self.client.debuglink.stop()
self.client.close() self.client.close()
@ -64,6 +75,7 @@ class TestProtectCall(common.TrezorTest):
print "Expected reboot time at least %s seconds" % expected print "Expected reboot time at least %s seconds" % expected
print "Rebooted in %s seconds" % took print "Rebooted in %s seconds" % took
self.assertLessEqual(expected, time.time() - start, "Bootup took %s seconds, expected %s seconds or more!" % (took, expected)) self.assertLessEqual(expected, time.time() - start, "Bootup took %s seconds, expected %s seconds or more!" % (took, expected))
'''
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()