From 6ee8d7d949aec6d947fcca43a2db1ecc236e2b0a Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Fri, 7 Feb 2014 11:31:12 +0100 Subject: [PATCH] and test_pings for combinations of input params --- tests/test_pings.py | 37 +++++++++++++++++++++++++++++++++++++ trezorlib/client.py | 3 +-- 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/test_pings.py diff --git a/tests/test_pings.py b/tests/test_pings.py new file mode 100644 index 0000000000..2dc72cc3f6 --- /dev/null +++ b/tests/test_pings.py @@ -0,0 +1,37 @@ +import time +import unittest +import common + +from trezorlib import messages_pb2 as proto +from trezorlib import types_pb2 as types + +class TestPing(common.TrezorTest): + + def test_ping(self): + + res = self.client.ping('random data') + self.assertEqual(res, 'random data') + + res = self.client.ping('random data', button_protection=True) + self.assertEqual(res, 'random data') + + res = self.client.ping('random data', pin_protection=True) + self.assertEqual(res, 'random data') + + res = self.client.ping('random data', passphrase_protection=True) + self.assertEqual(res, 'random data') + + res = self.client.ping('random data', button_protection=True, pin_protection=True) + self.assertEqual(res, 'random data') + + res = self.client.ping('random data', button_protection=True, passphrase_protection=True) + self.assertEqual(res, 'random data') + + res = self.client.ping('random data', pin_protection=True, passphrase_protection=True) + self.assertEqual(res, 'random data') + + res = self.client.ping('random data', button_protection=True, pin_protection=True, passphrase_protection=True) + self.assertEqual(res, 'random data') + +if __name__ == '__main__': + unittest.main() diff --git a/trezorlib/client.py b/trezorlib/client.py index f1a9083270..7f00d3fc90 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -111,12 +111,11 @@ class TrezorClient(object): def get_entropy(self, size): return self.call(proto.GetEntropy(size=size), proto.Entropy).entropy - def ping(self, msg, button_protection=True, pin_protection=True, passphrase_protection=True): + def ping(self, msg, button_protection=False, pin_protection=False, passphrase_protection=False): msg = proto.Ping(message=msg, button_protection=button_protection, pin_protection=pin_protection, passphrase_protection=passphrase_protection) - return self.call(msg, proto.Success).message def get_device_id(self):