Add tests and fixes for invalid paths

This commit is contained in:
Andrew Chow 2019-02-04 17:47:43 -05:00
parent a7d0121c7b
commit 5c54c0f6ee
3 changed files with 13 additions and 8 deletions

View File

@ -118,13 +118,10 @@ class ColdcardClient(HardwareWalletClient):
keypath = keypath.replace('h', '\'')
keypath = keypath.replace('H', '\'')
try:
ok = self.device.send_recv(CCProtocolPacker.sign_message(message.encode(), keypath, AF_CLASSIC), timeout=None)
assert ok == None
if self.device.is_simulator:
self.device.send_recv(CCProtocolPacker.sim_keypress(b'y'))
except CCProtoError as e:
raise DeviceFailureError(str(e))
ok = self.device.send_recv(CCProtocolPacker.sign_message(message.encode(), keypath, AF_CLASSIC), timeout=None)
assert ok == None
if self.device.is_simulator:
self.device.send_recv(CCProtocolPacker.sim_keypress(b'y'))
while 1:
time.sleep(0.250)

View File

@ -48,6 +48,7 @@ bad_args = [
411, # Filenames limited to alphanumeric values, hyphens, and underscores.
412, # Please provide an encryption key.
112, # Device password matches reset password. Disabling reset password.
251, # Could not generate key.
]
device_failures = [
@ -55,7 +56,6 @@ device_failures = [
107, # Output buffer overflow.
200, # Seed creation requires an SD card for automatic encrypted backup of the seed.
250, # Master key not present.
251, # Could not generate key.
252, # Could not generate ECDH secret.
303, # Could not sign.
400, # Please insert SD card.

View File

@ -401,6 +401,10 @@ class TestDisplayAddress(DeviceTestCase):
process_commands(self.dev_args + ['displayaddress', '--sh_wpkh', 'm/49h/1h/0h/0/0'])
process_commands(self.dev_args + ['displayaddress', '--wpkh', 'm/84h/1h/0h/0/0'])
def test_bad_path(self):
result = process_commands(self.dev_args + ['displayaddress', 'f'])
self.assertEquals(result['code'], -7)
class TestSignMessage(DeviceTestCase):
def setUp(self):
self.emulator.start()
@ -410,3 +414,7 @@ class TestSignMessage(DeviceTestCase):
def test_sign_msg(self):
process_commands(self.dev_args + ['signmessage', 'Message signing test', 'm/44h/1h/0h/0/0'])
def test_bad_path(self):
result = process_commands(self.dev_args + ['signmessage', 'Message signing test', 'f'])
self.assertEquals(result['code'], -7)