[Python-modules-commits] [python-trezor] 01/07: Import python-trezor_0.7.16.orig.tar.gz

Tristan Seligmann mithrandi at moszumanska.debian.org
Tue Dec 12 07:50:20 UTC 2017


This is an automated email from the git hooks/post-receive script.

mithrandi pushed a commit to branch master
in repository python-trezor.

commit c52e25930910981695d7e159b1e6b6540a445a50
Author: Tristan Seligmann <mithrandi at mithrandi.net>
Date:   Mon Dec 11 07:32:52 2017 +0200

    Import python-trezor_0.7.16.orig.tar.gz
---
 COPYING                                            | 165 +++++
 MANIFEST.in                                        |   4 +-
 PKG-INFO                                           |   8 +-
 README.rst                                         |  26 +-
 bash_completion.d/trezorctl.sh                     |  14 +
 setup.cfg                                          |   1 -
 setup.py                                           |  21 +-
 tests/common.py                                    |  45 --
 tests/config.py                                    |  35 -
 tests/device_tests/common.py                       | 102 +++
 tests/device_tests/config.py                       |  85 +++
 tests/{ => device_tests}/run-separate.sh           |   0
 tests/{ => device_tests}/run.sh                    |   0
 tests/{ => device_tests}/test_basic.py             |  20 +
 tests/{ => device_tests}/test_bip32_speed.py       |  21 +-
 tests/{ => device_tests}/test_debuglink.py         |  24 +-
 tests/{ => device_tests}/test_msg_applysettings.py |  37 +-
 tests/{ => device_tests}/test_msg_changepin.py     |  22 +-
 .../{ => device_tests}/test_msg_cipherkeyvalue.py  |  20 +-
 tests/{ => device_tests}/test_msg_clearsession.py  |  21 +-
 tests/device_tests/test_msg_estimatetxsize.py      |  54 ++
 tests/device_tests/test_msg_ethereum_getaddress.py |  36 +
 tests/device_tests/test_msg_ethereum_signtx.py     | 250 +++++++
 tests/{ => device_tests}/test_msg_getaddress.py    |  20 +
 tests/device_tests/test_msg_getaddress_segwit.py   |  44 ++
 .../test_msg_getaddress_segwit_native.py           |  47 ++
 .../{ => device_tests}/test_msg_getaddress_show.py |  43 +-
 tests/{ => device_tests}/test_msg_getentropy.py    |  25 +-
 tests/{ => device_tests}/test_msg_getpublickey.py  |  20 +
 tests/{ => device_tests}/test_msg_loaddevice.py    |  40 +-
 tests/device_tests/test_msg_loaddevice_xprv.py     |  47 ++
 tests/{ => device_tests}/test_msg_ping.py          |  21 +-
 .../{ => device_tests}/test_msg_recoverydevice.py  |  21 +
 .../device_tests/test_msg_recoverydevice_dryrun.py |  75 ++
 tests/{ => device_tests}/test_msg_resetdevice.py   | 109 +--
 .../test_msg_resetdevice_skipbackup.py             |  98 +++
 tests/{ => device_tests}/test_msg_signidentity.py  |  38 +-
 tests/{ => device_tests}/test_msg_signmessage.py   |  20 +-
 tests/{ => device_tests}/test_msg_signtx.py        | 525 +++++++-------
 tests/device_tests/test_msg_signtx_segwit.py       | 162 +++++
 .../device_tests/test_msg_signtx_segwit_native.py  | 482 +++++++++++++
 tests/device_tests/test_msg_signtx_zcash.py        |  75 ++
 tests/{ => device_tests}/test_msg_verifymessage.py |  20 +-
 tests/{ => device_tests}/test_msg_wipedevice.py    |  21 +
 tests/{ => device_tests}/test_multisig.py          | 178 +++--
 tests/{ => device_tests}/test_multisig_change.py   | 384 ++++++-----
 tests/{ => device_tests}/test_op_return.py         |  93 ++-
 tests/{ => device_tests}/test_protect_call.py      |  33 +-
 tests/{ => device_tests}/test_protection_levels.py | 139 ++--
 tests/{ => device_tests}/test_zerosig.py           |  71 +-
 tests/test_msg_estimatetxsize.py                   |  34 -
 tests/test_msg_ethereum_getaddress.py              |  17 -
 tests/test_msg_ethereum_signtx.py                  | 139 ----
 tests/test_msg_signtx_zcash.py                     |  55 --
 ...d5e6909e37d8fdd874301f7cc87e547e509cb1caa6.json |   1 +
 ...66fb251ef753e0912223a83d1dcb009111d28265e5.json |   1 +
 ...6e53dffc526d68c0eb5c00547e323b2c32382dfba3.json |   1 +
 ...88d23087071103e5bf855f4c1c44e5c8d9d82ca46e.json |   1 +
 ...aa1ef04ffce7e609448446d3a8d6f483c634ef5315.json |   1 +
 ...a753a53081b40738cc87e38f1d9b23ab57d9ad4396.json |   1 +
 ...9a6e58ae11e703eacd7954f588ed4b9cdefc4dba52.json |   1 +
 ...613fbc4bcb37df6cd49b4c96143e99580a472f79fb.json |   1 +
 ...b013e12f74159e69574ffea21581dad115572e031c.json |   1 +
 ...8e9885a252632086fa6be53301521d05253ce8a73d.json |   1 +
 ...e4bbf2d7382021b871bd8867ef8fa525ef50864882.json |   1 +
 ...6fe11c66612e8f73c6b00c69c7027213b84d259be3.json |   1 +
 ...445b20e3684e948709c5cdcaf12da3bb079c99448a.json |   1 +
 ...d0fdac8cb4fc301961c5988cba56902d8ffb61c337.json |   1 +
 ...7a16d5bad0b561ad1dfc047d0a7fbb8814668f91e5.json |   1 +
 ...d77c86c5a7f19bf66b1b1253c2c51cb4ae5f0c017b.json |   1 +
 ...56ef3fe34128dbde30daa9c0639a898f9977299d54.json |   1 +
 ...56465c8dc83bb553bf386a3f478ae65b5c021002be.json |   1 +
 ...a0b4806b0398646b91acf314da028c3f03dd0179fc.json |   1 +
 ...631d062c9ae918a0254f7c6c22de8e8cb7fd5b8236.json |   1 +
 ...18d13aa665125464547db5c7a6cd28f21639fe1228.json |   1 +
 tests/unit_tests/common.py                         |  26 +
 tests/unit_tests/test_ckd_public.py                |  39 ++
 tests/unit_tests/test_protobuf_json.py             |  36 +
 tests/unit_tests/test_tx_api.py                    |  45 ++
 trezor.egg-info/PKG-INFO                           |   8 +-
 trezor.egg-info/SOURCES.txt                        | 102 ++-
 trezor.egg-info/requires.txt                       |   7 +-
 trezorctl                                          | 224 +++---
 trezorlib/ckd_public.py                            |  33 +-
 trezorlib/client.py                                | 305 +++++++--
 trezorlib/debuglink.py                             |  27 +-
 trezorlib/mapping.py                               |  22 +
 trezorlib/messages_pb2.py                          | 755 ++++++++++++++-------
 trezorlib/protobuf_json.py                         |  86 ++-
 trezorlib/qt/pinmatrix.py                          |  43 +-
 trezorlib/tools.py                                 |  37 +-
 trezorlib/transport.py                             |  33 +-
 trezorlib/transport_bridge.py                      |  28 +-
 trezorlib/transport_hid.py                         |  40 +-
 trezorlib/transport_pipe.py                        |  35 +-
 trezorlib/transport_udp.py                         |  21 +-
 trezorlib/tx_api.py                                | 248 ++++---
 trezorlib/types_pb2.py                             | 198 ++++--
 98 files changed, 4829 insertions(+), 1697 deletions(-)

diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..65c5ca8
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,165 @@
+                   GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions.
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version.
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/MANIFEST.in b/MANIFEST.in
index dcb861c..9791eb6 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1 +1,3 @@
-recursive-include tests *.py *.sh
+recursive-include tests *.py *.sh *.json
+recursive-include bash_completion.d *.sh
+include COPYING
diff --git a/PKG-INFO b/PKG-INFO
index 8868774..5f607aa 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,10 +1,10 @@
 Metadata-Version: 1.1
 Name: trezor
-Version: 0.7.6
-Summary: Python library for communicating with TREZOR Bitcoin Hardware Wallet
+Version: 0.7.16
+Summary: Python library for communicating with TREZOR Hardware Wallet
 Home-page: https://github.com/trezor/python-trezor
-Author: Bitcoin TREZOR
-Author-email: info at bitcointrezor.com
+Author: TREZOR
+Author-email: info at trezor.io
 License: UNKNOWN
 Description: UNKNOWN
 Platform: UNKNOWN
diff --git a/README.rst b/README.rst
index 9ec4a01..2cefac9 100644
--- a/README.rst
+++ b/README.rst
@@ -7,9 +7,9 @@ python-trezor
 .. image:: https://badges.gitter.im/trezor/community.svg
     :target: https://gitter.im/trezor/community
 
-Client side implementation for TREZOR-compatible Bitcoin hardware wallets.
+Python library for communicating with TREZOR Hardware Wallet
 
-See http://bitcointrezor.com for more information.
+See https://trezor.io for more information
 
 Install
 -------
@@ -23,9 +23,29 @@ Install
 On Linux you might need to run these commands first:
 
 .. code::
+
   sudo apt-get install python-dev cython libusb-1.0-0-dev libudev-dev git
   sudo pip install setuptools
 
+Usage
+-----
+
+There is a command line tool called ``trezorctl`` which can perform various tasks. Use the following to learn about its commands:
+
+.. code::
+
+  trezorctl --help
+
+or to learn options of a particular command:
+
+.. code::
+
+  trezorctl commands --help
+
+or visit `usage <USAGE.rst>`_ page for more info.
+
+To use the library in your application look at the following example.
+
 Example
 -------
 
@@ -57,7 +77,7 @@ also found in ``tools/helloworld.py``
       print(client.features)
 
       # Get the first address of first BIP44 account
-      # (should be the same address as shown in mytrezor.com)
+      # (should be the same address as shown in wallet.trezor.io)
       bip32_path = client.expand_path("44'/0'/0'/0/0")
       address = client.get_address('Bitcoin', bip32_path)
       print('Bitcoin address:', address)
diff --git a/bash_completion.d/trezorctl.sh b/bash_completion.d/trezorctl.sh
new file mode 100644
index 0000000..ec1b30e
--- /dev/null
+++ b/bash_completion.d/trezorctl.sh
@@ -0,0 +1,14 @@
+_trezorctl()
+{
+    local cur prev cmds base
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+    cmds=$(trezorctl --help | grep -A 1 'Available commands:' | tail -n 1 | tr '{},' '   ')
+
+    COMPREPLY=($(compgen -W "${cmds}" -- ${cur}))
+    return 0
+}
+
+complete -F _trezorctl trezorctl
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..8bfd5a1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,4 @@
 [egg_info]
 tag_build = 
 tag_date = 0
-tag_svn_revision = 0
 
diff --git a/setup.py b/setup.py
index ebe56ff..c57bb9a 100755
--- a/setup.py
+++ b/setup.py
@@ -1,20 +1,26 @@
 #!/usr/bin/env python
 from setuptools import setup
 
-install_requires = ['ecdsa>=0.9', 'protobuf>=2.6.1', 'mnemonic>=0.8', 'setuptools>=19.0']
+install_requires = [
+    'ecdsa>=0.9',
+    'protobuf>=3.1.0',
+    'mnemonic>=0.17',
+    'setuptools>=19.0',
+    'requests>=2.4.0',
+]
 
 import sys
 if '--disable-hidapi' in sys.argv:
     sys.argv.remove('--disable-hidapi')
 else:
-    install_requires.append('hidapi>=0.7.99')
+    install_requires.append('hidapi>=0.7.99.post20')
 
 setup(
     name='trezor',
-    version='0.7.6',
-    author='Bitcoin TREZOR',
-    author_email='info at bitcointrezor.com',
-    description='Python library for communicating with TREZOR Bitcoin Hardware Wallet',
+    version='0.7.16',
+    author='TREZOR',
+    author_email='info at trezor.io',
+    description='Python library for communicating with TREZOR Hardware Wallet',
     url='https://github.com/trezor/python-trezor',
     py_modules=[
         'trezorlib.ckd_public',
@@ -33,8 +39,7 @@ setup(
         'trezorlib.tx_api',
         'trezorlib.types_pb2',
     ],
-    scripts = ['trezorctl'],
-    test_suite='tests',
+    scripts=['trezorctl'],
     install_requires=install_requires,
     include_package_data=True,
     zip_safe=False,
diff --git a/tests/common.py b/tests/common.py
deleted file mode 100644
index 16dac14..0000000
--- a/tests/common.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from __future__ import print_function
-
-import unittest
-from trezorlib.client import TrezorDebugClient
-from trezorlib.tx_api import TXAPIBitcoin
-import config
-
-class TrezorTest(unittest.TestCase):
-    def setUp(self):
-        self.debug_transport = config.DEBUG_TRANSPORT(*config.DEBUG_TRANSPORT_ARGS, **config.DEBUG_TRANSPORT_KWARGS)
-        self.transport = config.TRANSPORT(*config.TRANSPORT_ARGS, **config.TRANSPORT_KWARGS)
-        self.client = TrezorDebugClient(self.transport)
-        self.client.set_debuglink(self.debug_transport)
-        self.client.set_tx_api(TXAPIBitcoin())
-        # self.client.set_buttonwait(3)
-
-        #                     1      2     3    4      5      6      7     8      9    10    11    12
-        self.mnemonic12 = 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle'
-        self.mnemonic18 = 'owner little vague addict embark decide pink prosper true fork panda embody mixture exchange choose canoe electric jewel'
-        self.mnemonic24 = 'dignity pass list indicate nasty swamp pool script soccer toe leaf photo multiply desk host tomato cradle drill spread actor shine dismiss champion exotic'
-        self.mnemonic_all = ' '.join(['all'] * 12)
-
-        self.pin4 = '1234'
-        self.pin6 = '789456'
-        self.pin8 = '45678978'
-
-        self.client.wipe_device()
-
-        print("Setup finished")
-        print("--------------")
-
-    def setup_mnemonic_allallall(self):
-        self.client.load_device_by_mnemonic(mnemonic=self.mnemonic_all, pin='', passphrase_protection=False, label='test', language='english')
-
-    def setup_mnemonic_nopin_nopassphrase(self):
-        self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12, pin='', passphrase_protection=False, label='test', language='english')
-
-    def setup_mnemonic_pin_nopassphrase(self):
-        self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12, pin=self.pin4, passphrase_protection=False, label='test', language='english')
-
-    def setup_mnemonic_pin_passphrase(self):
-        self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12, pin=self.pin4, passphrase_protection=True, label='test', language='english')
-
-    def tearDown(self):
-        self.client.close()
diff --git a/tests/config.py b/tests/config.py
deleted file mode 100644
index 35df62f..0000000
--- a/tests/config.py
+++ /dev/null
@@ -1,35 +0,0 @@
-from __future__ import print_function
-
-import sys
-sys.path = ['../',] + sys.path
-
-from trezorlib.transport_pipe import PipeTransport
-from trezorlib.transport_hid import HidTransport
-
-devices = HidTransport.enumerate()
-
-if len(devices) > 0:
-    if devices[0][1] != None:
-        print('Using TREZOR')
-        TRANSPORT = HidTransport
-        TRANSPORT_ARGS = (devices[0],)
-        TRANSPORT_KWARGS = {'debug_link': False}
-        DEBUG_TRANSPORT = HidTransport
-        DEBUG_TRANSPORT_ARGS = (devices[0],)
-        DEBUG_TRANSPORT_KWARGS = {'debug_link': True}
-    else:
-        print('Using Raspberry Pi')
-        TRANSPORT = HidTransport
-        TRANSPORT_ARGS = (devices[0],)
-        TRANSPORT_KWARGS = {'debug_link': False}
-        DEBUG_TRANSPORT = SocketTransportClient
-        DEBUG_TRANSPORT_ARGS = ('trezor.bo:2000',)
-        DEBUG_TRANSPORT_KWARGS = {}
-else:
-    print('Using Emulator')
-    TRANSPORT = PipeTransport
-    TRANSPORT_ARGS = ('/tmp/pipe.trezor', False)
-    TRANSPORT_KWARGS = {}
-    DEBUG_TRANSPORT = PipeTransport
-    DEBUG_TRANSPORT_ARGS = ('/tmp/pipe.trezor_debug', False)
-    DEBUG_TRANSPORT_KWARGS = {}
diff --git a/tests/device_tests/common.py b/tests/device_tests/common.py
new file mode 100644
index 0000000..24fe344
--- /dev/null
+++ b/tests/device_tests/common.py
@@ -0,0 +1,102 @@
+# This file is part of the TREZOR project.
+#
+# Copyright (C) 2012-2016 Marek Palatinus <slush at satoshilabs.com>
+# Copyright (C) 2012-2016 Pavol Rusnak <stick at satoshilabs.com>
+#
+# This library is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library.  If not, see <http://www.gnu.org/licenses/>.
+
+from __future__ import print_function
+
+import unittest
+import hashlib
+
+from trezorlib.client import TrezorClient, TrezorDebugClient
+from trezorlib import tx_api
+import config
+
+
+tx_api.cache_dir = '../txcache'
+
+
+class TrezorTest(unittest.TestCase):
+
+    def setUp(self):
+        transport = config.TRANSPORT(*config.TRANSPORT_ARGS, **config.TRANSPORT_KWARGS)
+        if hasattr(config, 'DEBUG_TRANSPORT'):
+            debug_transport = config.DEBUG_TRANSPORT(*config.DEBUG_TRANSPORT_ARGS, **config.DEBUG_TRANSPORT_KWARGS)
+            self.client = TrezorDebugClient(transport)
+            self.client.set_debuglink(debug_transport)
+        else:
+            self.client = TrezorClient(transport)
+        self.client.set_tx_api(tx_api.TxApiBitcoin)
+        # self.client.set_buttonwait(3)
+
+        #                     1      2     3    4      5      6      7     8      9    10    11    12
+        self.mnemonic12 = 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle'
+        self.mnemonic18 = 'owner little vague addict embark decide pink prosper true fork panda embody mixture exchange choose canoe electric jewel'
+        self.mnemonic24 = 'dignity pass list indicate nasty swamp pool script soccer toe leaf photo multiply desk host tomato cradle drill spread actor shine dismiss champion exotic'
+        self.mnemonic_all = ' '.join(['all'] * 12)
+
+        self.pin4 = '1234'
+        self.pin6 = '789456'
+        self.pin8 = '45678978'
+
+        self.client.wipe_device()
+
+        print("Setup finished")
+        print("--------------")
+
+    def setup_mnemonic_allallall(self):
+        self.client.load_device_by_mnemonic(mnemonic=self.mnemonic_all, pin='', passphrase_protection=False, label='test', language='english')
+
+    def setup_mnemonic_nopin_nopassphrase(self):
+        self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12, pin='', passphrase_protection=False, label='test', language='english')
+
+    def setup_mnemonic_pin_nopassphrase(self):
+        self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12, pin=self.pin4, passphrase_protection=False, label='test', language='english')
+
+    def setup_mnemonic_pin_passphrase(self):
+        self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12, pin=self.pin4, passphrase_protection=True, label='test', language='english')
+
+    def tearDown(self):
+        self.client.close()
+
+
+def generate_entropy(strength, internal_entropy, external_entropy):
+    '''
+    strength - length of produced seed. One of 128, 192, 256
+    random - binary stream of random data from external HRNG
+    '''
+    if strength not in (128, 192, 256):
+        raise Exception("Invalid strength")
+
+    if not internal_entropy:
+        raise Exception("Internal entropy is not provided")
+
+    if len(internal_entropy) < 32:
+        raise Exception("Internal entropy too short")
+
+    if not external_entropy:
+        raise Exception("External entropy is not provided")
+
+    if len(external_entropy) < 32:
+        raise Exception("External entropy too short")
+
+    entropy = hashlib.sha256(internal_entropy + external_entropy).digest()
+    entropy_stripped = entropy[:strength // 8]
+
+    if len(entropy_stripped) * 8 != strength:
+        raise Exception("Entropy length mismatch")
+
+    return entropy_stripped
diff --git a/tests/device_tests/config.py b/tests/device_tests/config.py
new file mode 100644
index 0000000..ae7a2e6
--- /dev/null
+++ b/tests/device_tests/config.py
@@ -0,0 +1,85 @@
+# This file is part of the TREZOR project.
+#
+# Copyright (C) 2012-2016 Marek Palatinus <slush at satoshilabs.com>
+# Copyright (C) 2012-2016 Pavol Rusnak <stick at satoshilabs.com>
+#
+# This library is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library.  If not, see <http://www.gnu.org/licenses/>.
+
+from __future__ import print_function
+
+import sys
+sys.path = ['../../'] + sys.path
+
+
+try:
+    from trezorlib.transport_hid import HidTransport
+    HID_ENABLED = True
+except Exception as e:
+    print('HID transport disabled:', e.message, e.args)
+    HID_ENABLED = False
+
+try:
+    from trezorlib.transport_pipe import PipeTransport
+    PIPE_ENABLED = True
+except Exception as e:
+    print('PIPE transport disabled:', e.message, e.args)
+    PIPE_ENABLED = False
+
+try:
+    from trezorlib.transport_udp import UdpTransport
+    UDP_ENABLED = True
+except Exception as e:
+    print('UDP transport disabled:', e.message, e.args)
+    UDP_ENABLED = False
+
+
+def pipe_exists(path):
+    import os
+    import stat
+    try:
+        return stat.S_ISFIFO(os.stat(path).st_mode)
+    except:
+        return False
+
+
+if HID_ENABLED and len(HidTransport.enumerate()) > 0:
+
+    devices = HidTransport.enumerate()
+    print('Using TREZOR')
+    TRANSPORT = HidTransport
+    TRANSPORT_ARGS = (devices[0],)
+    TRANSPORT_KWARGS = {'debug_link': False}
+    DEBUG_TRANSPORT = HidTransport
+    DEBUG_TRANSPORT_ARGS = (devices[0],)
+    DEBUG_TRANSPORT_KWARGS = {'debug_link': True}
+
+elif PIPE_ENABLED and pipe_exists('/tmp/pipe.trezor.to'):
+
+    print('Using Emulator (v1=pipe)')
+    TRANSPORT = PipeTransport
+    TRANSPORT_ARGS = ('/tmp/pipe.trezor', False)
+    TRANSPORT_KWARGS = {}
+    DEBUG_TRANSPORT = PipeTransport
+    DEBUG_TRANSPORT_ARGS = ('/tmp/pipe.trezor_debug', False)
+    DEBUG_TRANSPORT_KWARGS = {}
+
+elif UDP_ENABLED:
+
+    print('Using Emulator (v2=udp)')
+    TRANSPORT = UdpTransport
+    TRANSPORT_ARGS = ('', )
+    TRANSPORT_KWARGS = {}
+    DEBUG_TRANSPORT = UdpTransport
+    DEBUG_TRANSPORT_ARGS = ('', )
+    DEBUG_TRANSPORT_KWARGS = {}
diff --git a/tests/run-separate.sh b/tests/device_tests/run-separate.sh
similarity index 100%
rename from tests/run-separate.sh
rename to tests/device_tests/run-separate.sh
diff --git a/tests/run.sh b/tests/device_tests/run.sh
similarity index 100%
rename from tests/run.sh
rename to tests/device_tests/run.sh
diff --git a/tests/test_basic.py b/tests/device_tests/test_basic.py
similarity index 55%
rename from tests/test_basic.py
rename to tests/device_tests/test_basic.py
index 4d25819..a5d79b5 100644
--- a/tests/test_basic.py
+++ b/tests/device_tests/test_basic.py
@@ -1,8 +1,27 @@
+# This file is part of the TREZOR project.
+#
+# Copyright (C) 2012-2016 Marek Palatinus <slush at satoshilabs.com>
+# Copyright (C) 2012-2016 Pavol Rusnak <stick at satoshilabs.com>
+#
+# This library is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library.  If not, see <http://www.gnu.org/licenses/>.
+
 import unittest
 import common
 
 from trezorlib import messages_pb2 as messages
 
+
 class TestBasic(common.TrezorTest):
 
     def test_features(self):
@@ -32,5 +51,6 @@ class TestBasic(common.TrezorTest):
         # Device ID must be fresh after every reset
         self.assertNotEqual(id1, id2)
 
+
 if __name__ == '__main__':
     unittest.main()
diff --git a/tests/test_bip32_speed.py b/tests/device_tests/test_bip32_speed.py
similarity index 68%
rename from tests/test_bip32_speed.py
rename to tests/device_tests/test_bip32_speed.py
index 8c8fa11..ce6d424 100644
--- a/tests/test_bip32_speed.py
+++ b/tests/device_tests/test_bip32_speed.py
@@ -1,9 +1,27 @@
+# This file is part of the TREZOR project.
+#
+# Copyright (C) 2012-2016 Marek Palatinus <slush at satoshilabs.com>
+# Copyright (C) 2012-2016 Pavol Rusnak <stick at satoshilabs.com>
+#
+# This library is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library.  If not, see <http://www.gnu.org/licenses/>.
+
 from __future__ import print_function
 
 import unittest
 import common
 import time
-from trezorlib import tools
+
 
 class TestBip32Speed(common.TrezorTest):
 
@@ -52,5 +70,6 @@ class TestBip32Speed(common.TrezorTest):
         # Cached time expected to be at least 2x faster
         self.assertLessEqual(cache_time, nocache_time / 2.)
 
+
 if __name__ == '__main__':
     unittest.main()
diff --git a/tests/test_debuglink.py b/tests/device_tests/test_debuglink.py
similarity index 58%
rename from tests/test_debuglink.py
rename to tests/device_tests/test_debuglink.py
index 3ad8044..df41b3a 100644
--- a/tests/test_debuglink.py
+++ b/tests/device_tests/test_debuglink.py
@@ -1,11 +1,26 @@
-import time
+# This file is part of the TREZOR project.
+#
+# Copyright (C) 2012-2016 Marek Palatinus <slush at satoshilabs.com>
+# Copyright (C) 2012-2016 Pavol Rusnak <stick at satoshilabs.com>
+#
+# This library is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library.  If not, see <http://www.gnu.org/licenses/>.
+
 import unittest
 import common
-import binascii
 
 from trezorlib import messages_pb2 as proto
-from trezorlib import types_pb2 as types
-from trezorlib.client import PinException
+
 
 class TestDebugLink(common.TrezorTest):
 
@@ -38,5 +53,6 @@ class TestDebugLink(common.TrezorTest):
         resp = self.client.call_raw(proto.PinMatrixAck(pin=pin_encoded))
         self.assertIsInstance(resp, proto.Success)
 
+
 if __name__ == '__main__':
     unittest.main()
diff --git a/tests/test_msg_applysettings.py b/tests/device_tests/test_msg_applysettings.py
similarity index 81%
rename from tests/test_msg_applysettings.py
rename to tests/device_tests/test_msg_applysettings.py
index 5b85f54..83ee6ce 100644
--- a/tests/test_msg_applysettings.py
+++ b/tests/device_tests/test_msg_applysettings.py
@@ -1,9 +1,27 @@
-import time
+# This file is part of the TREZOR project.
+#
+# Copyright (C) 2012-2016 Marek Palatinus <slush at satoshilabs.com>
+# Copyright (C) 2012-2016 Pavol Rusnak <stick at satoshilabs.com>
+#
+# This library is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library.  If not, see <http://www.gnu.org/licenses/>.
+
 import unittest
 import common
 
 from trezorlib import messages_pb2 as proto
 
+
 class TestMsgApplysettings(common.TrezorTest):
 
     def test_apply_settings(self):
@@ -11,8 +29,8 @@ class TestMsgApplysettings(common.TrezorTest):
         self.assertEqual(self.client.features.label, 'test')
 
         with self.client:
-            self.client.set_expected_responses([proto.ButtonRequest(),
-                                                proto.PinMatrixRequest(),
+            self.client.set_expected_responses([proto.PinMatrixRequest(),
+                                                proto.ButtonRequest(),
                                                 proto.Success(),
                                                 proto.Features()])
             self.client.apply_settings(label='new label')
@@ -24,8 +42,8 @@ class TestMsgApplysettings(common.TrezorTest):
         self.assertEqual(self.client.features.language, 'english')
 
         with self.client:
-            self.client.set_expected_responses([proto.ButtonRequest(),
-                                                proto.PinMatrixRequest(),
+            self.client.set_expected_responses([proto.PinMatrixRequest(),
+                                                proto.ButtonRequest(),
                                                 proto.Success(),
                                                 proto.Features()])
             self.client.apply_settings(language='nonexistent')
@@ -38,8 +56,8 @@ class TestMsgApplysettings(common.TrezorTest):
         self.assertEqual(self.client.features.passphrase_protection, False)
 
         with self.client:
-            self.client.set_expected_responses([proto.ButtonRequest(),
-                                                proto.PinMatrixRequest(),
+            self.client.set_expected_responses([proto.PinMatrixRequest(),
+                                                proto.ButtonRequest(),
                                                 proto.Success(),
                                                 proto.Features()])
             self.client.apply_settings(use_passphrase=True)
@@ -68,11 +86,12 @@ class TestMsgApplysettings(common.TrezorTest):
         img = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\x04\x80\x00\x00\x00\x00\x00\x00\x00\x00\x04\x88\x02\x00\x00\x00\x02\x91\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x90@\x00\x11@\x00\x00\x00\x00\x00\x00\x08\x00\x10\x92\x12\x04\x00\x00\x05\x12D\x00\x00\x00\x00\x00 \x00\x00\x08\x00Q\x00\x00\x02\xc0\x00\x00\x00\x00\x00\x00\x00\x10\x02 \x01\x04J\x00)$\x00\x00\x00\x00\x80\x00\x00\x00\x00\x08\x10\xa1\x00\x00\x02\x [...]
 
         with self.client:
-            self.client.set_expected_responses([proto.ButtonRequest(),
-                                                proto.PinMatrixRequest(),
+            self.client.set_expected_responses([proto.PinMatrixRequest(),
+                                                proto.ButtonRequest(),
                                                 proto.Success(),
                                                 proto.Features()])
             self.client.apply_settings(homescreen=img)
 
+
 if __name__ == '__main__':
     unittest.main()
diff --git a/tests/test_msg_changepin.py b/tests/device_tests/test_msg_changepin.py
similarity index 90%
rename from tests/test_msg_changepin.py
rename to tests/device_tests/test_msg_changepin.py
index 3a0756a..fbb3310 100644
--- a/tests/test_msg_changepin.py
+++ b/tests/device_tests/test_msg_changepin.py
@@ -1,9 +1,26 @@
-import time
+# This file is part of the TREZOR project.
+#
+# Copyright (C) 2012-2016 Marek Palatinus <slush at satoshilabs.com>
+# Copyright (C) 2012-2016 Pavol Rusnak <stick at satoshilabs.com>
+#
+# This library is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library.  If not, see <http://www.gnu.org/licenses/>.
+
 import unittest
 import common
 
 from trezorlib import messages_pb2 as proto
-from trezorlib import types_pb2 as proto_types
+
 
 class TestMsgChangepin(common.TrezorTest):
 
@@ -200,5 +217,6 @@ class TestMsgChangepin(common.TrezorTest):
         self.assertTrue(features.pin_protection)
         self.assertEqual(self.client.debug.read_pin()[0], self.pin4)
 
+
 if __name__ == '__main__':
     unittest.main()
diff --git a/tests/test_msg_cipherkeyvalue.py b/tests/device_tests/test_msg_cipherkeyvalue.py
similarity index 82%
rename from tests/test_msg_cipherkeyvalue.py
rename to tests/device_tests/test_msg_cipherkeyvalue.py
index d985321..c2156ff 100644
--- a/tests/test_msg_cipherkeyvalue.py
+++ b/tests/device_tests/test_msg_cipherkeyvalue.py
... 9602 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-trezor.git



More information about the Python-modules-commits mailing list