diff --git a/tests/config.py b/tests/config.py new file mode 100644 index 0000000..f4ded94 --- /dev/null +++ b/tests/config.py @@ -0,0 +1,10 @@ +import sys +sys.path = ['../',] + sys.path + +from bitkeylib.transport_pipe import PipeTransport + +TRANSPORT = PipeTransport +TRANSPORT_ARGS = ('../../bitkey-python/device.socket', False) + +DEBUG_TRANSPORT = PipeTransport +DEBUG_TRANSPORT_ARGS = ('../../bitkey-python/device.socket.debug', False) \ No newline at end of file diff --git a/tests/run.sh b/tests/run.sh new file mode 100755 index 0000000..5936b79 --- /dev/null +++ b/tests/run.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +python -m unittest discover diff --git a/tests/test.py b/tests/test.py index c09b44b..a9a5b26 100755 --- a/tests/test.py +++ b/tests/test.py @@ -1,20 +1,37 @@ #!/usr/bin/python +''' import sys sys.path = ['../',] + sys.path import time +ENABLE_DEBUG_LINK = True + from bitkeylib.transport_pipe import PipeTransport from bitkeylib.transport_serial import SerialTransport -import bitkeylib.bitkey_pb2 as proto +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('../../bitkey-python/device.socket', debug=True) -bitkey.open() -bitkey.call(proto.Ping(message='ahoj!')) -bitkey.call(proto.SetMaxFeeKb(maxfee_kb=200000)) -bitkey.close() +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) diff --git a/tests/test_basic.py b/tests/test_basic.py new file mode 100644 index 0000000..da31929 --- /dev/null +++ b/tests/test_basic.py @@ -0,0 +1,19 @@ +import unittest +import config + +from bitkeylib.client import BitkeyClient +from bitkeylib import proto + +class TestBasic(unittest.TestCase): + + def setUp(self): + self.debuglink = config.DEBUG_TRANSPORT(*config.DEBUG_TRANSPORT_ARGS) + self.transport = config.TRANSPORT(*config.TRANSPORT_ARGS) + self.bitkey = BitkeyClient(self.transport, self.debuglink) + + def tearDown(self): + self.debuglink.close() + self.transport.close() + + def test_basic(self): + self.assertEqual(self.bitkey.call(proto.Ping(message='ahoj!')), proto.Success(message='ahoj!')) \ No newline at end of file