Skip to content

Conversation

@achow101
Copy link
Member

This PR is based on top of #66. It adds two test cases for the Trezor and Coldcard implementations by using their respective emulators/simulators. test_bip32.py was removed as the BIP 32 implementation was removed and no longer needed. Additionally a test running (run_tests.py), a script for building the Trezor emulator, Coldcard simulator, and bitcoind, and instructions for running the tests were all added. Lastly a Travis config has been added and travis builds for this branch are available at https://travis-ci.org/achow101/HWI

@achow101 achow101 force-pushed the api-test branch 3 times, most recently from b98654b to 48a8758 Compare November 28, 2018 20:56
@achow101
Copy link
Member Author

I've updated setup_environment.sh so that it can make better use of the caching the travis is setup to do.

@achow101 achow101 force-pushed the api-test branch 5 times, most recently from 67a3930 to 8e998f5 Compare November 28, 2018 22:33
Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I wasn't able to get the Trezor simulator to work on macOS. Maybe it's better to (also) support the more modern Trezor Core emulator?

Can you replace #!/usr/bin/python3 with #! /usr/bin/env python3 in the bech32 test?

Trezor test throws ModuleNotFoundError: No module named 'bitcoinrpc', so maybe that's missing from the installer? I had to run pip3 install python-bitcoinrpc.

It also tests usage with `bitcoind`, so the [patched Bitcoin Core](../docs/bitcoin-core-usage.md#bitcoin-core) is required.
- `test_coldcard.py` tests the command line interface and Coldcard implementation.
It uses the [Coldcard simulator](https://github.com/Coldcard/firmware/tree/master/unix#coldcard-desktop-simulator).
It also tests usage with `bitcoind`, so the [patched Bitcoin Core](../docs/bitcoin-core-usage.md#bitcoin-core) is required.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

test/README.md Outdated
In order to build the Trezor emulator, the following packages will need to be installed:

```
build-essential curl git python3 python3-pip libsdl2-dev libsdl2-image-dev gcc-arm-none-eabi libnewlib-arm-none-eabi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which Homebrew equivalents?

So far I have:

brew install curl git python3 sdl2 sdl2_image`
brew tap ArmMbed/homebrew-formulae
brew install brew install arm-none-eabi-gcc

I forget how I installed pip. I think build-essential is covered by the Xcode dev tools, which should be present if bitcoind is compiled from source.

However that still ended with compiler errors for pipenv run script/cibuild.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the packages defined in their .travis.yml: build-essential gcc-arm-none-eabi gcc-multilib libnewlib-arm-none-eabi python3.6 python3.6-venv python3.6-dev. I think you are missing gcc-multilib? I'll add that to the README.

```
pipenv
```

Copy link
Member

@Sjors Sjors Nov 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./build.sh EMU builds the emulator. Point out that you need Docker. (or do you, I'm confused)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can build it without docker, unless you want to use ./build.sh. AFAIK, build.sh does not build the emulator in headless mode, so there's a GUI and such. For automated testing on Travis, we need headless mode so we build it through the pipenv commands rather than build.sh.

@achow101
Copy link
Member Author

I can add another test that uses the Trezor Core emulator.

I've updated the README significantly with more detailed instructions for building. I've also updated the shebang for test_bech32.py.

setup.py will install python-bitcoinrpc if you install the tests extra.

@Sjors
Copy link
Member

Sjors commented Nov 29, 2018

@achow101 might as well add those Trezor Core tests in a next PR. I can always look at Travis logs to see if I broke a test.

Using the trezor emulator, test the  enumerate, getxpub,
getmasterxpub, getkeypool, and signtx commands.
Also tests fingerprint autodetect and device type only specified.
Using the coldcard simulator, test the  enumerate, getxpub,
getmasterxpub, and getkeypool commands. Signtx is tested if the
simulator is in non-headless mode as it requires user input.
Also tests fingerprint autodetect and device type only specified.
Sort items before serializing so that the same psbt will always be
serialized the same way.
Add a run_tests.py script which runs all of the tests.

Add a setup_environment.sh script which will download and build the Trezor
emulator, Coldcard simulator, and bitcoind.
Adds an extra_requires for the tests which has the dependencies
needed for running the tests (besides emulator/simulator deps).
@achow101 achow101 merged commit fd19704 into master Dec 10, 2018
achow101 added a commit that referenced this pull request Dec 10, 2018
…ravis CI

fd19704 Travis config (Andrew Chow)
ced3087 Document tests and how to run them (Andrew Chow)
ddcf842 extra for tests dependencies (Andrew Chow)
8aa0471 Add scripts to run tests and prepare test environments (Andrew Chow)
993b6e8 Update test_bech32.py shebang (Andrew Chow)
a277ac2 Fix psbt serializations to always be consistent (Andrew Chow)
d01cbae Add tests for Coldcard using Coldcard simulator (Andrew Chow)
2272428 Add tests for trezor using the emulator (Andrew Chow)
ccd5f2a Use the DebugLink for the Trezor emulator in order to have tests (Andrew Chow)
64816cb Remove unneeded BIP 32 test (Andrew Chow)

Pull request description:

  This PR is based on top of #66. It adds two test cases for the Trezor and Coldcard implementations by using their respective emulators/simulators. `test_bip32.py` was removed as the BIP 32 implementation was removed and no longer needed. Additionally a test running (`run_tests.py`), a script for building the Trezor emulator, Coldcard simulator, and bitcoind, and instructions for running the tests were all added. Lastly a Travis config has been added and travis builds for this branch are available at https://travis-ci.org/achow101/HWI

Tree-SHA512: 71da24ee39bd845a822d48e83d4c6980cda741544e6cdf04d257db116bc1f7133b3370e235100a66b4fe7c69ecbd0298a4df7879733b75cebeb6a88467f4bf5f
@achow101 achow101 deleted the api-test branch December 10, 2018 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants