Skip to content

Commit d52c81e

Browse files
author
slush
committed
Refactored tests, added common.BitkeyTest
1 parent e1d328e commit d52c81e

3 files changed

Lines changed: 37 additions & 49 deletions

File tree

‎tests/common.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import unittest
2+
import config
3+
4+
from bitkeylib.client import BitkeyClient
5+
from bitkeylib.debuglink import DebugLink
6+
from bitkeylib import proto
7+
8+
class BitkeyTest(unittest.TestCase):
9+
def setUp(self):
10+
self.debug_transport = config.DEBUG_TRANSPORT(*config.DEBUG_TRANSPORT_ARGS)
11+
self.transport = config.TRANSPORT(*config.TRANSPORT_ARGS)
12+
self.bitkey = BitkeyClient(self.transport, DebugLink(self.debug_transport), algo=proto.ELECTRUM, debug=True)
13+
14+
self.bitkey.setup_debuglink(button=True, pin_correct=True, otp_correct=True)
15+
16+
self.bitkey.load_device(seed='beyond neighbor scratch swirl embarrass doll cause also stick softly physical nice',
17+
otp=True, pin='1234', spv=True)
18+
19+
print "Setup finished"
20+
print "--------------"
21+
22+
def tearDown(self):
23+
self.debug_transport.close()
24+
self.transport.close()

‎tests/test_basic.py‎

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import unittest
2-
import config
2+
import common
33

4-
from bitkeylib.client import BitkeyClient
5-
from bitkeylib.debuglink import DebugLink
64
from bitkeylib import proto
75

86
'''
@@ -14,25 +12,7 @@
1412
1513
'''
1614

17-
class TestBasic(unittest.TestCase):
18-
19-
def setUp(self):
20-
self.debug_transport = config.DEBUG_TRANSPORT(*config.DEBUG_TRANSPORT_ARGS)
21-
self.transport = config.TRANSPORT(*config.TRANSPORT_ARGS)
22-
self.bitkey = BitkeyClient(self.transport, DebugLink(self.debug_transport), algo=proto.ELECTRUM, debug=True)
23-
24-
self.bitkey.setup_debuglink(button=True, pin_correct=True, otp_correct=True)
25-
26-
self.bitkey.load_device(seed='beyond neighbor scratch swirl embarrass doll cause also stick softly physical nice',
27-
otp=True, pin='1234', spv=True)
28-
29-
print "Setup finished"
30-
print "--------------"
31-
32-
def tearDown(self):
33-
self.debug_transport.close()
34-
self.transport.close()
35-
15+
class TestBasic(common.BitkeyTest):
3616
def test_features(self):
3717
features = self.bitkey.call(proto.Initialize(session_id=self.bitkey.session_id))
3818

@@ -50,7 +30,10 @@ def test_uuid(self):
5030
uuid2 = self.bitkey.get_uuid()
5131

5232
# UUID must be longer than 10 characters
53-
self.assertGreater(len(uuid1.UUID), 10)
33+
self.assertGreater(len(uuid1), 10)
5434

5535
# Every resulf of UUID must be the same
5636
self.assertEqual(uuid1, uuid2)
37+
38+
if __name__ == '__main__':
39+
unittest.main()

‎tests/test_signtx.py‎

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
11
import unittest
2-
import config
2+
import common
33

4-
from bitkeylib.client import BitkeyClient
5-
from bitkeylib.debuglink import DebugLink
6-
from bitkeylib import proto
7-
8-
class TestSignTx(unittest.TestCase):
9-
10-
def setUp(self):
11-
self.debug_transport = config.DEBUG_TRANSPORT(*config.DEBUG_TRANSPORT_ARGS)
12-
self.transport = config.TRANSPORT(*config.TRANSPORT_ARGS)
13-
self.bitkey = BitkeyClient(self.transport, DebugLink(self.debug_transport), algo=proto.ELECTRUM)
14-
15-
self.bitkey.setup_debuglink(pin_correct=True, otp_correct=True)
16-
17-
self.bitkey.load_device(seed='beyond neighbor scratch swirl embarrass doll cause also stick softly physical nice',
18-
otp=True, pin='1234', spv=True, button=True)
19-
20-
print "Setup finished"
21-
print "--------------"
22-
23-
def tearDown(self):
24-
self.debug_transport.close()
25-
self.transport.close()
26-
27-
'''
4+
class TestSignTx(common.BitkeyTest):
5+
'''
286
def test_signtx(self):
297
print self.bitkey.sign_tx([], [])
30-
'''
8+
'''
9+
10+
if __name__ == '__main__':
11+
unittest.main()

0 commit comments

Comments
 (0)