1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 11:39:03 +00:00

Test of PIN cancel function

This commit is contained in:
slush0 2013-10-10 17:18:02 +02:00
parent 4e5c3740aa
commit b8ddd0279a
2 changed files with 9 additions and 2 deletions

View File

@ -26,6 +26,10 @@ class TestProtectCall(common.TrezorTest):
def test_incorrect_pin(self): def test_incorrect_pin(self):
self.client.setup_debuglink(button=True, pin_correct=False) self.client.setup_debuglink(button=True, pin_correct=False)
self.assertRaises(PinException, self._some_protected_call) self.assertRaises(PinException, self._some_protected_call)
def test_cancelled_pin(self):
self.client.setup_debuglink(button=True, pin_correct=-1) # PIN cancel
self.assertRaises(PinException, self._some_protected_call)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -102,11 +102,14 @@ class TrezorClient(object):
if isinstance(resp, proto.PinMatrixRequest): if isinstance(resp, proto.PinMatrixRequest):
if self.debuglink: if self.debuglink:
if self.debug_pin: if self.debug_pin == 1:
pin = self.debuglink.read_pin_encoded() pin = self.debuglink.read_pin_encoded()
msg2 = proto.PinMatrixAck(pin=pin) msg2 = proto.PinMatrixAck(pin=pin)
elif self.debug_pin == -1:
msg2 = proto.PinMatrixCancel()
else: else:
msg2 = proto.PinMatrixAck(pin='444444222222') msg2 = proto.PinMatrixAck(pin='444444222222')
else: else:
pin = self.pin_func("PIN required: ", resp.message) pin = self.pin_func("PIN required: ", resp.message)
msg2 = proto.PinMatrixAck(pin=pin) msg2 = proto.PinMatrixAck(pin=pin)
@ -118,7 +121,7 @@ class TrezorClient(object):
if isinstance(resp, proto.Failure): if isinstance(resp, proto.Failure):
self.message_func(resp.message) self.message_func(resp.message)
if resp.code == 4: if resp.code == 4:
raise CallException("Action cancelled by user") raise CallException("Action cancelled by user")