1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 13:38:12 +00:00
Commit Graph

42 Commits

Author SHA1 Message Date
matejcik
42583eaceb debuglink: allow clearing input_flow function 2019-02-01 14:27:52 +01:00
matejcik
68da6881b5 debuglink: add null debuglink, allow running tests interactively
run with:
INTERACT=1 pytest <your options here>
2019-01-31 15:30:05 +01:00
matejcik
bfb6a196c0 tests: limit number of reported expected responses
so that our test logs are not spammed, esp. in that one test that has
20k messages
2018-12-13 14:10:44 +01:00
matejcik
ed473e2e42 trezorlib: add licence headers where missing 2018-11-12 12:22:32 +01:00
matejcik
85b85c67b3 trezorlib: reentrant session handling
This fixes the breakage introduced by transport reshuffles.
It's still not great and I'd love to see context manager based sessions.
But it's good enough for now.
2018-11-12 12:22:32 +01:00
matejcik
aac7726824 trezorlib: transport/protocol reshuffle
This commit breaks session handling (which matters with Bridge) and
regresses Bridge to an older code state. Both of these issues will be
rectified in subsequent commits.

Explanation of this big API reshuffle follows:

* protocols are moved to trezorlib.transport, and to a single common file.
* there is a cleaner definition of Transport and Protocol API (see below)
* fully valid mypy type hinting
* session handle counters and open handle counters mostly went away. Transports
  and Protocols are meant to be "raw" APIs; TrezorClient will implement
  context-handler-based sessions, session tracking, etc.

I'm calling this a "reshuffle" because it involved very small number of
code changes. Most of it is moving things around where they sit better.

The API changes are as follows.

Transport is now a thing that can:
* open and close sessions
* read and write protobuf messages
* enumerate and find devices

Some transports (all except bridge) are technically bytes-based and need
a separate protocol implementation (because we have two existing protocols,
although only the first one is actually used). Hence a protocol superclass.

Protocol is a thing that *also* can:
* open and close sessions
* read and write protobuf messages
For that, it requires a `handle`.

Handle is a physical layer for a protocol. It can:
* open and close some sort of device connection
  (this is distinct from session! Connection is a channel over which you can
  send data. Session is a logical arrangement on top of that; you can have
  multiple sessions on a single connection.)
* read and write 64-byte chunks of data

With that, we introduce ProtocolBasedTransport, which simply delegates
the appropriate Transport functionality to respective Protocol methods.

hid and webusb transports are ProtocolBasedTransport-s that provide separate
device handles. HidHandle and WebUsbHandle existed before, but the distinction
of functionality between a Transport and its Handle was unclear. Some methods
were moved and now the handles implement the Handle API, while the transports
provide the enumeration parts of the Transport API, as well as glue between
the respective Protocols and Handles.

udp transport is also a ProtocolBasedTransport, but it acts as its own handle.
(That might be changed. For now, I went with the pre-existing structure.)

In addition, session_begin/end is renamed to begin/end_session to keep
consistent verb_noun naming.
2018-11-12 12:22:26 +01:00
matejcik
1233feb358 style: fix imports 2018-11-06 13:36:25 +01:00
matejcik
3239d53bc0 debuglink: add support for arbitrary message filters
(this replaces `debug_processor` from sign_tx)
2018-11-06 13:36:25 +01:00
matejcik
1d3fa77ab6 debuglink: allow with-block without expected_responses 2018-10-10 13:15:28 +02:00
matejcik
ffff11a462 style: isort & autopep 2018-10-10 13:15:28 +02:00
matejcik
c37bc9c38e debug: improve infrastructure and expected message reporting 2018-10-10 13:15:28 +02:00
matejcik
06927e003e trezorlib: get rid of TextUIMixin
This also moves DebugLinkMixin to debuglink.py and converts the mixin to
a subclass of TrezorClient (which is finally becoming a
reasonable-looking class). This takes advantage of the new UI protocol
and is ready for further improvements, namely, queuing input for tests
that require swipes.

The ui.py module contains a Click-based implementation of the UI
protocol. Use of callback_* methods has been limited and will probably
be cleaned up further (The contract has changed so we'll try to make
third party code fail noisily. It is unclear whether a backwards
compatible approach will be possible).

Furthermore, device.recovery() now takes a callback as an argument. This
way we can get rid of WordRequest callbacks, which are only used in the
recovery flow.
2018-10-10 13:15:28 +02:00
Pavol Rusnak
4a0ca873eb trezorlib+tools: remove usage of binascii 2018-09-27 16:52:28 +02:00
Pavol Rusnak
434f279069
use implicit encoding in encode/decode 2018-09-06 16:22:38 +02:00
matejcik
3d3e9b67b4 style: apply black/isort 2018-08-13 18:22:19 +02:00
matejcik
6029a98414 debuglink: fix bug in self_test bootloader detection 2018-08-10 15:18:34 +02:00
matejcik
d5dee0c897 trezorlib: move mostly-debug methods from device to debuglink 2018-08-10 13:33:14 +02:00
matejcik
54f1599a5a regenerate license headers
This clarifies the intent: the project is licenced under terms
of LGPL version 3 only, but the standard headers cover only "3 or later",
so we had to rewrite them.

In the same step, we removed author information from individual files
in favor of "SatoshiLabs and contributors", and include an AUTHORS
file that lists the contributors.

Apologies to those whose names are missing; please contact us if you wish
to add your info to the AUTHORS file.
2018-06-21 16:49:13 +02:00
matejcik
0b6ec27064 logging: get rid of pprint and VerboseWireMixin
(and also TrezorClientVerbose)
2018-05-11 15:29:38 +02:00
Jan Pochyla
3e65761395 debuglink: add new fields 2018-03-20 16:47:11 +01:00
slush
a27217811b Rework from Google's protobuf to pure-python protobuf implementation 2017-12-17 02:19:16 +01:00
Jan Pochyla
bc42eb68d6 transports: refactor, split protocol code 2017-08-24 14:29:27 +02:00
Pavol Rusnak
33f274d145
style: use flake8 2017-06-23 21:52:53 +02:00
Pavol Rusnak
0bba092741
add LGPLv3 headers to sources files 2016-11-25 22:53:55 +01:00
Jan Pochyla
737200c7ef debuglink: fix debuglink for V2 2016-11-15 13:46:00 +01:00
Jochen Hoenicke
c388d0837c
New debug messages 2016-06-28 00:53:46 +02:00
Pavol Rusnak
3a108ee8a5
fix pylint warnings 2016-05-26 17:20:44 +02:00
Pavol Rusnak
54c8bfd1d4
import print function from future 2016-05-20 22:27:20 +02:00
Pavol Rusnak
f7cc1cd3a1
remove FIXME :) 2016-05-20 13:55:43 +02:00
slush0
64fadde3e0
Passes first unit tests (against trezor-emu over transport_pipe).
WIP: Issue with console printing of protobuf messages (probably bug in protobuf for python3 itself).
WIP: Disabled Bridge transport because of json_protobuf incompatibility with python3.
WIP: Broken expectations of returned objects in unit tests
2016-05-20 13:46:51 +02:00
slush0
6ec2ff3eac
Preparation for python3 support (WIP) 2016-05-20 13:46:51 +02:00
Pavol Rusnak
fc1b12d80d
fix whitespace 2016-01-13 00:17:38 +01:00
Pavol Rusnak
4fc8868589 rename word variables in DebugLinkState message 2014-03-07 17:38:38 +01:00
slush0
4b9cc6cb78 Added debug printing to debuglink communication 2014-02-25 19:31:31 +01:00
slush0
dfeb6de331 Test for Reset Device 2014-02-20 19:15:43 +01:00
Pavol Rusnak
b63418c8b8 add read_passphrase_protection to debuglink 2014-02-17 02:16:43 +01:00
slush0
558f61e635 Heavily refactored TrezorClient 2014-02-13 16:47:52 +01:00
Pavol Rusnak
49cecb563d add test_debuglink test 2014-02-06 23:34:13 +01:00
slush0
ca6ab18ae5 Fixes DebugLinkGetState 2014-01-12 16:17:22 +01:00
Pavol Rusnak
d3df313442 cleanup protobuf mess 2013-12-16 17:40:25 +01:00
slush0
121e189643 Implemented test of pin exponential backoff 2013-10-11 03:51:45 +02:00
slush0
98bb17299b Module renamed to trezorlib 2013-09-13 05:37:23 +02:00