HWI/test
Andrew Chow 8d738ee31c
Merge #125: Test how the CLI deals with really big transactions
1a2b67d Test how a very large transaction is handled (Andrew Chow)
c69c0ee Add travis job for cli interface test (Andrew Chow)
e594a0b Allow specifiying a different interface for using HWI in tests (Andrew Chow)

Pull request description:

  It was mentioned in the #bitcoin-core-dev IRC channel a few days ago that really big transactions can cause problems if it was entered as an argument in the shell. This PR adds to the test suite the option to run the tests with different interfaces to allow us to test this. It can use the "library" interface which is what we currently do. This interface calls `process_commands` directly. The `cli` interface uses `subprocess` to run the `hwi` command in the shell to test the command line interface. This will emulate entering a command in the shell. This allows us to test the big transaction case which has been added. This case only tests the interface and not whether the transaction is signed. This test should pass when using the `library` interface but not when using the `cli`. Both interfaces will also be tested on travis as separate jobs.

Tree-SHA512: 47c85c3b4df66aaa552dc55028267024ea53a56f8028bc0e161fd390ea3e96166f3d9157f320bbf922c63fd5726f13c3918c75cbd3a1311c1536477c0605dcee
2019-02-28 21:47:56 -05:00
..
data Add scripts to run tests and prepare test environments 2018-12-04 10:32:23 -05:00
__init__.py Move tests to test subdir 2018-09-01 12:52:37 -04:00
README.md Document Keepkey emulator build instructions 2019-01-24 20:52:09 -05:00
run_tests.py Allow specifiying a different interface for using HWI in tests 2019-02-19 10:21:58 -05:00
setup_environment.sh travis: fix bitcoind update 2019-02-18 17:17:01 -05:00
test_bech32.py Update test_bech32.py shebang 2018-12-04 10:32:23 -05:00
test_coldcard.py Allow specifiying a different interface for using HWI in tests 2019-02-19 10:21:58 -05:00
test_descriptor.py Add descriptor checksums and tests 2019-02-17 17:41:45 -05:00
test_device.py Test how a very large transaction is handled 2019-02-19 10:21:58 -05:00
test_digitalbitbox.py Merge #125: Test how the CLI deals with really big transactions 2019-02-28 21:47:56 -05:00
test_keepkey.py Allow specifiying a different interface for using HWI in tests 2019-02-19 10:21:58 -05:00
test_ledger.py Allow specifiying a different interface for using HWI in tests 2019-02-19 10:21:58 -05:00
test_psbt.py Use HWWErrors instead of built-ins 2019-02-04 10:04:30 -05:00
test_trezor.py Allow specifiying a different interface for using HWI in tests 2019-02-19 10:21:58 -05:00

HWI Tests

Running the tests

This folder contains test cases for HWI. To run these tests, hwilib will need to be installed to your python system. You can install it by doing pip install -e .[tests] in the root directory.

setup_environment.sh will build the Trezor emulator, the Coldcard simulator, and the patched bitcoind. if run in the test/ directory, these will be built in work/test/trezor-mcu, work/test/firmware, and work/test/bitcoin respectively.

run_tests.py runs the tests. If run from the test/ directory, it will be able to find the Trezor emulator, Coldcard simulator, and bitcoind. Otherwise the paths to those will need to be specified on the command line. test_trezor.pyandtest_coldcard.py` can be disabled.

If you are building the Trezor emulator, the Coldcard simulator, and bitcoind without setup_environment.sh, then you will need to make work/ inside of test/.

$ cd test
$ mkdir -p work
$ cd work

Trezor emulator

Dependencies

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 gcc-multilib

The python packages can be installed with

pip install pipenv

Building

Clone the repository:

$ git clone https://github.com/trezor/trezor-mcu/

Build the emulator in headless mode:

$ cd trezor-mcu
$ export EMULATOR=1 TREZOR_TRANSPORT_V1=1 DEBUG_LINK=1 HEADLESS=1
$ script/setup
$ pipenv install
$ pipenv run script/cibuild

Coldcard simulator

Dependencies

In order to build the Coldcard simulator, the following packages will need to be installed:

build-essential git python3 python3-pip libudev-dev gcc-arm-none-eabi

After cloninig the Coldcard repo into this testing folder, the python packages can be installed with:

pip install -r ckcc_firmware/requirements.txt
pip install -r ckcc_firmware/unix/requirements.txt

Building

Clone the repository:

$ git clone https://github.com/coldcard/firmware

Build the emulator in headless mode:

$ cd firmware/unix
$ make setup
$ make

Bitbox Simulator

Dependencies

In order to build the Bitbox simulator, the following packages will need to be installed:

build-essential git cmake

Building

Clone the repository:

$ git clone https://github.com/digitalbitbox/mcu

Build the simulator:

$ cd mcu
$ mkdir -p build && cd build
$ cmake .. -DBUILD_TYPE=simulator
$ make

KeepKey emulator

Dependencies

In order to build the KeepKey emulator, the following packages will need to be installed:

build-essential git python2 python2-pip

The python packages can be installed with

pip install protobuf

Building

Clone the repository and dependencies:

$ git clone https://github.com/keepkey/keepkey-firmware.git
$ cd keepkey-firmware
$ git clone https://github.com/nanopb/nanopb.git -b nanopb-0.2.9.2

Build the emulator:

$ export PATH=$PATH:`pwd`/nanopb/generator
$ cmake -C cmake/caches/emulator.cmake . -DNANOPB_DIR=nanopb/ -DKK_HAVE_STRLCAT=OFF -DKK_HAVE_STRLCPY=OFF
$ make kkemu

Bitcoin Core

In order to build bitcoind, see Bitcoin Core's build documentation to get all of the dependencies installed and for instructions on how to build.