From bf126896f9494371e25bcb99b1385cf9a6fe0664 Mon Sep 17 00:00:00 2001 From: Salvatore Ingala <6681844+bigspider@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:55:19 +0100 Subject: [PATCH 1/2] Add the bitcoin_client to the requirements.txt for the test suites, instead of modifying the system PATH --- .github/workflows/ci-workflow.yml | 15 ++++++++++++--- bitcoin_client/tests/requirements.txt | 9 --------- requirements.txt | 14 ++++++++++++++ test_utils/requirements.txt | 2 -- tests/README.md | 2 +- tests/conftest.py | 9 +-------- tests/requirements.txt | 12 ++---------- tests_mainnet/README.md | 2 +- tests_mainnet/requirements.txt | 9 --------- tests_perf/README.md | 2 +- tests_perf/conftest.py | 10 ---------- tests_perf/requirements.txt | 8 -------- 12 files changed, 32 insertions(+), 62 deletions(-) delete mode 100644 bitcoin_client/tests/requirements.txt create mode 100644 requirements.txt delete mode 100644 test_utils/requirements.txt delete mode 100644 tests_mainnet/requirements.txt delete mode 100644 tests_perf/requirements.txt diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 66feefd13..571bb841a 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -156,10 +156,13 @@ jobs: name: bitcoin-app-${{matrix.model}} path: bin + - name: Install build dependencies + run: apt update && apt install -y build-essential + - name: Run tests run: | - cd tests_mainnet pip install -r requirements.txt + cd tests_mainnet PYTHONPATH=$PYTHONPATH:/speculos pytest --headless --model=${{ matrix.model }} --timeout=300 job_test_python_lib_legacyapp: @@ -182,10 +185,13 @@ jobs: - name: Clone uses: actions/checkout@v4 + - name: Install build dependencies + run: apt update && apt install -y build-essential + - name: Run tests run: | - cd bitcoin_client/tests pip install -r requirements.txt + cd bitcoin_client/tests PYTHONPATH=$PYTHONPATH:/speculos pytest --headless --timeout=300 --model=nanos job_perftests: @@ -215,10 +221,13 @@ jobs: name: bitcoin-testnet-perftest-app-nanosp path: bin + - name: Install build dependencies + run: apt update && apt install -y build-essential + - name: Run tests run: | - cd tests_perf pip install -r requirements.txt + cd tests_perf PYTHONPATH=$PYTHONPATH:/speculos pytest --headless --model=nanosp --benchmark-json=benchmarks.json - name: Upload benchmarks summary uses: actions/upload-artifact@v4 diff --git a/bitcoin_client/tests/requirements.txt b/bitcoin_client/tests/requirements.txt deleted file mode 100644 index e7c7ab739..000000000 --- a/bitcoin_client/tests/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -bip32>=3.4,<4.0 -ledgercomm>=1.1.0,<1.2.0 -ecdsa>=0.16.1,<0.17.0 -embit>=0.7.0,<0.8.0 -mnemonic==0.20 -pytest>=6.1.1,<7.0.0 -pytest-timeout>=2.1.0,<3.0.0 -speculos>=0.12.0,<0.13.0 -typing-extensions>=3.7,<4.0 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..322f4798f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,14 @@ +# requirements for the various test suites + +pytest>=6.1.1,<7.0.0 +pytest-benchmark>=4.0.0,<5.0.0 +pytest-timeout>=2.1.0,<3.0.0 +ledgercomm>=1.1.0,<1.2.0 +ecdsa>=0.16.1,<0.17.0 +typing-extensions>=3.7,<4.0 +embit>=0.7.0,<0.8.0 +mnemonic==0.20 +bip32>=3.4,<4.0 +speculos>=0.12.0,<0.13.0 +ragger[speculos, ledgerwallet]>=1.6.0 +-e ./bitcoin_client # path relative to the current working directory; assume it's the root of the repo diff --git a/test_utils/requirements.txt b/test_utils/requirements.txt deleted file mode 100644 index c06bc9eb3..000000000 --- a/test_utils/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -mnemonic==0.20 -bip32>=3.4,<4.0 \ No newline at end of file diff --git a/tests/README.md b/tests/README.md index af47c7e34..3d1fb6bfa 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,7 +4,7 @@ These tests are implemented in Python and can be executed either using the [Spec All the commands in this folder are meant to be ran from the `tests` folder, not from the root. -Python dependencies are listed in [requirements.txt](requirements.txt), install them using [pip](https://pypi.org/project/pip/) +Python dependencies are listed in [requirements.txt](../requirements.txt), install them using [pip](https://pypi.org/project/pip/) from the root of the repository: ``` pip install -r requirements.txt diff --git a/tests/conftest.py b/tests/conftest.py index ab40a51e7..4b896b91d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,12 +1,5 @@ -import sys # noqa: E402 -import os # noqa: E402 - -absolute_path = os.path.dirname(os.path.abspath(__file__)) # noqa: E402 -relative_bitcoin_path = ('../bitcoin_client') # noqa: E402 -absolute_bitcoin_client_path = os.path.join( - os.path.dirname(os.path.abspath(__file__)), '../') # noqa: E402 -sys.path.append(os.path.join(absolute_path, relative_bitcoin_path)) # noqa: E402 +import os from ragger_bitcoin import createRaggerClient, RaggerClient from ragger.backend import RaisePolicy diff --git a/tests/requirements.txt b/tests/requirements.txt index 9fa0510eb..4c4900149 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,10 +1,2 @@ -pytest>=6.1.1,<7.0.0 -pytest-timeout>=2.1.0,<3.0.0 -ledgercomm>=1.1.0,<1.2.0 -ecdsa>=0.16.1,<0.17.0 -typing-extensions>=3.7,<4.0 -embit>=0.7.0,<0.8.0 -mnemonic==0.20 -bip32>=3.4,<4.0 -speculos>=0.12.0,<0.13.0 -ragger[speculos, ledgerwallet]>=1.6.0 +# The reusable ragger workflow expects a requirements.txt file in the tests directory, but we want to just use the one in the repository's root. +-r ../requirements.txt diff --git a/tests_mainnet/README.md b/tests_mainnet/README.md index c6d7d1656..f37eae2f5 100644 --- a/tests_mainnet/README.md +++ b/tests_mainnet/README.md @@ -4,7 +4,7 @@ These tests are implemented in Python and can be executed either using the [Spec All the commands in this folder are meant to be ran from the `tests` folder, not from the root. -Python dependencies are listed in [requirements.txt](requirements.txt), install them using [pip](https://pypi.org/project/pip/) +Python dependencies are listed in [requirements.txt](../requirements.txt), install them using [pip](https://pypi.org/project/pip/) from the root of the repository: ``` pip install -r requirements.txt diff --git a/tests_mainnet/requirements.txt b/tests_mainnet/requirements.txt deleted file mode 100644 index e7c7ab739..000000000 --- a/tests_mainnet/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -bip32>=3.4,<4.0 -ledgercomm>=1.1.0,<1.2.0 -ecdsa>=0.16.1,<0.17.0 -embit>=0.7.0,<0.8.0 -mnemonic==0.20 -pytest>=6.1.1,<7.0.0 -pytest-timeout>=2.1.0,<3.0.0 -speculos>=0.12.0,<0.13.0 -typing-extensions>=3.7,<4.0 diff --git a/tests_perf/README.md b/tests_perf/README.md index bb75f6f93..87d05adfc 100644 --- a/tests_perf/README.md +++ b/tests_perf/README.md @@ -4,7 +4,7 @@ The tests in this folder are meant to measure the performance of various app ope These tests are implemented in Python and can be executed either using the [Speculos](https://github.com/LedgerHQ/speculos) emulator or a Ledger Nano S+, Nano X, or Stax. -Python dependencies are listed in [requirements.txt](requirements.txt), install them using [pip](https://pypi.org/project/pip/) +Python dependencies are listed in [requirements.txt](requirements.txt), install them using [pip](https://pypi.org/project/pip/) from the root of the repository: ``` pip install -r requirements.txt diff --git a/tests_perf/conftest.py b/tests_perf/conftest.py index 577e6475c..32c78def0 100644 --- a/tests_perf/conftest.py +++ b/tests_perf/conftest.py @@ -2,16 +2,6 @@ from pathlib import Path from test_utils.fixtures import * import random -import sys -import os - -absolute_path = os.path.dirname(os.path.abspath(__file__)) -relative_bitcoin_path = ('../bitcoin_client') -absolute_bitcoin_client_path = os.path.join( - os.path.dirname(os.path.abspath(__file__)), '../') -sys.path.append(os.path.join(absolute_path, relative_bitcoin_path)) - -from ledger_bitcoin import Chain # noqa: E402 TESTS_ROOT_DIR = Path(__file__).parent diff --git a/tests_perf/requirements.txt b/tests_perf/requirements.txt deleted file mode 100644 index 4b2d380ac..000000000 --- a/tests_perf/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -bip32>=3.4,<4.0 -embit>=0.8.0,<0.9.0 -ledgercomm>=1.2.1,<2.0.0 -mnemonic==0.20 -pytest>=8.2.2,<9.0.0 -pytest-benchmark>=4.0.0,<5.0.0 -speculos>=0.12.0,<0.13.0 -typing-extensions>=3.7,<4.0 From d0f8d3a0246a4f90c5c26550e336acb8d3c9e422 Mon Sep 17 00:00:00 2001 From: Salvatore Ingala <6681844+bigspider@users.noreply.github.com> Date: Mon, 6 Jan 2025 11:07:02 +0100 Subject: [PATCH 2/2] Update tests_perf/README.md Co-authored-by: lpascal-ledger --- tests_perf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_perf/README.md b/tests_perf/README.md index 87d05adfc..8f3ccd548 100644 --- a/tests_perf/README.md +++ b/tests_perf/README.md @@ -4,7 +4,7 @@ The tests in this folder are meant to measure the performance of various app ope These tests are implemented in Python and can be executed either using the [Speculos](https://github.com/LedgerHQ/speculos) emulator or a Ledger Nano S+, Nano X, or Stax. -Python dependencies are listed in [requirements.txt](requirements.txt), install them using [pip](https://pypi.org/project/pip/) from the root of the repository: +Python dependencies are listed in [requirements.txt](../requirements.txt), install them using [pip](https://pypi.org/project/pip/) from the root of the repository: ``` pip install -r requirements.txt