mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-20 06:28:09 +00:00
Fixed some tests
This commit is contained in:
parent
60e6064d4e
commit
a437ae1022
@ -9,6 +9,7 @@ class TrezorTest(unittest.TestCase):
|
||||
self.debug_transport = config.DEBUG_TRANSPORT(*config.DEBUG_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, debug=False)
|
||||
|
||||
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'
|
||||
|
@ -1,5 +1,8 @@
|
||||
#!/usr/bin/python
|
||||
'''
|
||||
|
||||
TODO:
|
||||
|
||||
* ApplySettings workflow, zistit cez Features ci sa zmeny aplikovali
|
||||
* WipeDevice workflow, zistit cez Features ci to prebehlo
|
||||
* LoadDevice workflow, zistit cez Features ci to prebehlo
|
||||
@ -17,61 +20,9 @@
|
||||
* VerifyMessage workflow
|
||||
|
||||
* otestovat session handling (tento test bude zrejme failovat na RPi)
|
||||
|
||||
* Features reflects all variations of LoadDevice
|
||||
* Maxfee settings
|
||||
* Client requires OTP
|
||||
* Client requires PIN
|
||||
'''
|
||||
|
||||
|
||||
'''
|
||||
import sys
|
||||
sys.path = ['../',] + sys.path
|
||||
|
||||
import time
|
||||
|
||||
ENABLE_DEBUG_LINK = True
|
||||
|
||||
from bitkeylib.transport_pipe import PipeTransport
|
||||
from bitkeylib.transport_serial import SerialTransport
|
||||
from bitkeylib.transport_fake import FakeTransport
|
||||
from bitkeylib import proto
|
||||
|
||||
from bitkeylib.client import BitkeyClient
|
||||
from bitkeylib.debuglink import DebugLink
|
||||
|
||||
transport = PipeTransport('../../bitkey-python/device.socket', is_device=False)
|
||||
|
||||
if ENABLE_DEBUG_LINK:
|
||||
debug_transport = PipeTransport('../../bitkey-python/device.socket.debug', is_device=False)
|
||||
debuglink = DebugLink(debug_transport)
|
||||
else:
|
||||
debuglink = None
|
||||
|
||||
bitkey = BitkeyClient(transport, debuglink)
|
||||
|
||||
print bitkey.call(proto.Initialize())
|
||||
#bitkey.call(proto.Ping(message='ahoj!'))
|
||||
#bitkey.call(proto.GetUUID())
|
||||
|
||||
print bitkey.call(proto.GetEntropy(size=10), button=True)
|
||||
bitkey.call(proto.SetMaxFeeKb(maxfee_kb=100000), button=True, pin_correct=False)
|
||||
'''
|
||||
|
||||
'''
|
||||
d = PipeTransport('../bitkey-python/device.socket', is_device=False)
|
||||
#d = SerialTransport('../../bitkey-python/COM9')
|
||||
|
||||
#start = time.time()
|
||||
|
||||
#for x in range(1000):
|
||||
|
||||
call(proto.Initialize())
|
||||
call(proto.Ping())
|
||||
call(proto.GetUUID())
|
||||
#call(proto.GetEntropy(size=10))
|
||||
#call(proto.LoadDevice(seed='beyond neighbor scratch swirl embarrass doll cause also stick softly physical nice',
|
||||
# otp=True, pin='1234', spv=True))
|
||||
|
||||
#call(proto.ResetDevice())
|
||||
call(proto.GetMasterPublicKey(algo=proto.ELECTRUM))
|
||||
#call(proto.ResetDevice())
|
||||
'''
|
||||
|
||||
#print 10000 / (time.time() - start)
|
||||
|
@ -3,15 +3,6 @@ import common
|
||||
|
||||
from trezorlib import messages_pb2 as messages
|
||||
|
||||
'''
|
||||
TODO:
|
||||
* Features reflects all variations of LoadDevice
|
||||
* Maxfee settings
|
||||
* Client requires OTP
|
||||
* Client requires PIN
|
||||
|
||||
'''
|
||||
|
||||
class TestBasic(common.TrezorTest):
|
||||
def test_features(self):
|
||||
features = self.client.call(messages.Initialize())
|
||||
|
@ -3,16 +3,17 @@ import unittest
|
||||
import common
|
||||
|
||||
from trezorlib.client import PinException
|
||||
# from trezorlib import messages_pb2 as proto
|
||||
|
||||
# FIXME TODO Add passphrase tests
|
||||
|
||||
class TestProtectCall(common.TrezorTest):
|
||||
def _some_protected_call(self):
|
||||
# This method perform any call which have protection in the device
|
||||
entropy_len = 10
|
||||
entropy = self.client.get_entropy(entropy_len)
|
||||
self.assertEqual(len(entropy), entropy_len)
|
||||
res = self.client.ping('random data', pin_protection=True, passphrase_protection=True)
|
||||
self.assertEqual(res, 'random data')
|
||||
|
||||
def test_no_protection(self):
|
||||
self.client.wipe_device()
|
||||
self.client.load_device_by_mnemonic(
|
||||
mnemonic=self.mnemonic1,
|
||||
pin='',
|
||||
@ -25,6 +26,7 @@ class TestProtectCall(common.TrezorTest):
|
||||
self._some_protected_call()
|
||||
|
||||
def test_pin(self):
|
||||
self.client.wipe_device()
|
||||
self.client.load_device_by_mnemonic(mnemonic=self.mnemonic1,
|
||||
pin=self.pin2,
|
||||
passphrase_protection=False,
|
||||
@ -53,7 +55,7 @@ class TestProtectCall(common.TrezorTest):
|
||||
print msg
|
||||
self.assertLessEqual(expected, got, msg)
|
||||
|
||||
for attempt in range(1, 6):
|
||||
for attempt in range(1, 4):
|
||||
start = time.time()
|
||||
self.assertRaises(PinException, self._some_protected_call)
|
||||
test_backoff(attempt, start)
|
||||
|
@ -25,6 +25,27 @@ class TestSignTx(common.TrezorTest):
|
||||
tx = self.client.simple_sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
self.assertEqual(binascii.hexlify(tx.serialized_tx), '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b4830450221009a0b7be0d4ed3146ee262b42202841834698bb3ee39c24e7437df208b8b7077102202b79ab1e7736219387dffe8d615bbdba87e11477104b867ef47afed1a5ede7810121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0160cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000')
|
||||
|
||||
'''
|
||||
def test_fee_too_high(self):
|
||||
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
|
||||
# input 0: 0.0039 BTC
|
||||
|
||||
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 - 50000,
|
||||
script_type=proto_types.PAYTOADDRESS,
|
||||
)
|
||||
|
||||
tx = self.client.simple_sign_tx('Bitcoin', [inp1, ], [out1, ])
|
||||
# FIXME - Check if "Fee too high" appeared on display
|
||||
'''
|
||||
|
||||
|
||||
def test_estimate_size(self):
|
||||
inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
|
||||
# amount=390000,
|
||||
|
Loading…
Reference in New Issue
Block a user