app-bitcoin icon indicating copy to clipboard operation
app-bitcoin copied to clipboard

LVFM-488: Major rewrite of the Bitcoin app APDU-level tests, using a in-house transaction parser

Open hcleonis opened this issue 5 years ago • 0 comments

UPDATE: some remark taken into account (code style & quick wins), others related to structural changes compiled in the "Next steps" section of the tests/README.md file. PR can be merged IMO.

The previous version of the BTC tests used error-prone and difficult-to-maintain offset calculations to get the various parts of a raw tx. This version uses an in-house transaction parser TxParse that is simply a dataclass with a from_raw() method which identify each element of the tx named attributes. The tests have also been rewritten to isolate the raw tx data into the file conftest.py and use fixtures to pass them to the tests. Using trusted inputs or not by a same test is achieved with the use_trusted_inputs pytest parameter, resulting in shorter test files.

Note: each test repeats the same APDU sequence so it can be envisaged in the future to isolate that sequence into a method of class BaseTestBtc. This way, adding new nominal tests would be done by simply providing some raw tx data and calling that method.

Note 2: Some work on adding click/event automation was started but not finished.

hcleonis avatar Jul 05 '20 13:07 hcleonis