Tests are powered by trezor-user-env which is daily built into a docker image providing all the necessary instrumentation required to run tests (bridge and emulators).
Tests are running in two environments:
SatoshiLabs GitLab CI NixOS runner
Test are running directly in trezor-user-env
docker image. All required variables are declared in gitlab-ci.yml config file.
Github Actions CI Ubuntu runner
Test are using run.sh script to spin up trezor-user-env
docker image and set all required variables.
Note: All paths below are relative to the root of trezor-connect repository.
Note: Running tests with custom firmware is not currently possible.
Note: As of now M1 Macs aren't supported. See this issue for detailed information.
Note: Running all test at once using Docker for Mac v20 may end up with unexpected EOF
error.
Note: Running test with graphical output from emulator may end up with device disconnected during action
error.
Note: Make sure that your default/local trezord
is disabled and all physical Trezor devices are disconnected.
Note: Running all test at once may take a while. It is recommended to narrow the subset using -i methodName
option.
Note: If you are running trezor-user-env
docker image as standalone process in terminal use -d
option.
- See available options
tests/run.sh -h
- Limit tests to subset of methods use
tests/run.sh -i getPublicKey,getAddress
- Run all tests
tests/run.sh
(may take some time)
- Create or modify file in
tests/__fixtures__
- Make sure it is imported in
tests/__fixtures__/index.js
- Make sure the method you are testing is listed in
.github/workflows/*.yml
and.gitlab-ci.yml
Bitcoin-like coins signTransaction
method require additional data about transactions referenced from used inputs.
Those data are automatically downloaded from backend defined in coins.json
by default if refTxs
param is not specified.
Note: Backends hosted on *.trezor.io
are limiting requests per min.
Too many requests from not whitelisted origins may be penalized with temporary ban. ("All backends are down" error)
Backend connection will be omitted in case of providing refTxs
so even coins without officially supported backends (like zcash testnet) may sign a transaction in "offline mode". see docs
To reduce network traffic Github Actions CI
is using cached (offline) mode and whitelisted GitLab CI
is using default (online) mode.
Caching is enabled by default. To disable it use tests/run.sh -c
option.
Cached transactions are stored in tests/__txcache__
directory in the same structure as in trezor-firmware repository.
Cached transactions are provided to test fixtures via TX_CACHE utility.
Missing tx json? use this tool to generate it.
Similar to transaction cache. If process.env.TESTS_USE_WS_CACHE
is set to true
then @trezor/blockchain-link
is conditionally connected to a local websocket server returning cached results from tests/__wscache__
.
WebSocketServer in Karma plugin
Testing ./build
directory in browser environment.
Run: ./tests/run.sh -s "yarn test:karma:production" -i getAddress