Skip to content

Commit

Permalink
Run pytests inside Ledger docker containers for consistent environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinkyaraj-23 committed Apr 23, 2024
1 parent 1662b6d commit 82ff398
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,26 +142,23 @@ BOLOS_SDK=$NANOS_SDK make DEBUG=1
You can replace `NANOS` with `NANOSP`, `NANOX`, `STAX` for the other devices in BOLOS_SDK environmental variable.

### Testing
To test the application you need to enable python virtual environment and some dependencies. On any operating system, create a python virtual environment and activate it.
The application tests are run using same docker container used for building. Inside the docker container run following script,
```
$ sudo apt-get update && sudo apt-get install -y qemu-user-static tesseract-ocr libtesseract-dev python3-pip libgmp-dev libsodium-dev git
$ python3 -m venv env
$ source env/bin/activate
```
Inside the virtualenv, load the requirements.txt file.
```
(env)$ pip install -r test/requirements.txt
$ apk add gmp-dev curl jq libsodium-dev git xxd procps;
$ python3 -m venv tezos_test_env --system-site-package;
$ source ./tezos_test_env/bin/activate;
(tezos_test_env)$ python3 -m pip install -r tests/requirements.txt -q ;
```
Now you can run ragger tests for any perticular ledger device. Please make sure you have built the app.elf files for that perticular device first. Then run following command:
```
(env)$ pytest test --device nanosp
(tezos_test_env)$ python3 -m pytest test --device nanosp
```
Replace nanosp with any of the following for respective device: nanos, nanosp, nanox , stax.

These tests are run on Ledger emulator called speculos which emulates the actual ledger device. To run theese test on actual device you have to choose a backend. Run following commands to run these test on device:
```
(env)$ pip install ragger[all_backends]
(env)$ pytest test --device nanosp --backend ledgercomm -s
(tezos_test_env)$ python3 -m pip install ragger[all_backends]
(tezos_test_env)$ python3 -m pytest test --device nanosp --backend ledgercomm -s
```
Note the `-s` flag which is required when running interactive tests with pytest. You can also choose `ledgerwallet` backend to run tests on device.

Expand Down
3 changes: 1 addition & 2 deletions test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
base58
bip32
GitPython
pytezos
ragger[tests,speculos]
pytezos>=3.11.3

0 comments on commit 82ff398

Please sign in to comment.