trezor / python-trezor

:snake: Don't use this repo, use the new monorepo instead:
https://github.com/trezor/trezor-firmware
GNU Lesser General Public License v3.0
201 stars 194 forks source link

WIP: remove TextUiMixin, allow input flows for tests #314

Closed matejcik closed 5 years ago

matejcik commented 5 years ago

This implements #307 by moving the UI interaction into a separate module, separated by an actual API.

This change also lets me separate TrezorClientDebugLink better and add some useful features for the test suite, namely, input flow support.

In a test, you can write a function that yields to wait for interaction, and then performs the interaction. This is in contrast to the current behavior, where if you want to do anything more complicated than auto-clicking "yes" on every prompt, you need to write send/receive messages by hand, instead of using library functions.

Example usage is in test_msg_resetdevice_t2.py

In addition, reporting for un/expected messages is nicer.


This is work in progress, please do not merge

tsusanka commented 5 years ago

Example usage is in test_msg_resetdevice_t2.py

So, in a test I define a callable function (input_flow in this example) where I specify the confirms/interactions with trezor using yield and the debug link and I then give this callback to self.client.set_input_flow and run the test. Correct?

LGTM

matejcik commented 5 years ago

rebased & merged