From 2bd6a67525de2aaec1407156114eecb739e5091e Mon Sep 17 00:00:00 2001 From: Charles-Edouard de la Vergne Date: Mon, 2 Sep 2024 15:37:30 +0200 Subject: [PATCH 1/6] Clarify ragger tests usage --- README.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 85cf9fa8..19de9abf 100644 --- a/README.md +++ b/README.md @@ -23,18 +23,37 @@ make delete ## Testing +### Ragger tests + +The `./test/python` directory contains files for testing the app and its interactions with other apps. It does not contain the binaries used to test the app. + +The sideloaded applications binaries need to be generated in their respective repositories and placed in the `tests/python/library_binaries` directory. +The binaries need to be generated with specific flags: + +```shell script +make DEBUG=1 TEST_PUBLIC_KEY=1 +``` + +Tests can be run with a command like: + +```shell script +pytest -v --tb=short --device nanox -k eth +``` + +### Legacy Zemu tests + The `./test` directory contains files for testing the app and its interactions with other apps. It does not contain the binaries used to test the app. The binaries need to be generated and put in `test/elfs/` before launching the tests. The exchange binaries need to be generated with the following flags. -``` +```shell script make TESTING=1 TEST_PUBLIC_KEY=1 ``` Then the application must be placed in the `test/elfs/` directory, under the name `exchange_nanos.elf`, `exchange_nanox.elf`, or `exchange_nanosp.elf` depending on the SDK: -``` +```shell script // Choose one // cp bin/app.elf test/elfs/exchange_nanos.elf // cp bin/app.elf test/elfs/exchange_nanox.elf @@ -43,7 +62,8 @@ Then the application must be placed in the `test/elfs/` directory, under the nam The sideloaded applications binaries need to be generated in their respective repositories and placed in the `test/elfs/` directory. For the entire test collection to pass, the following binaries must be present -``` + +```shell script bitcoin_nanos.elf bitcoin_nanosp.elf bitcoin_nanox.elf From 423eafd93d9c3bd2ab683e73f391b274c6518b5f Mon Sep 17 00:00:00 2001 From: Charles-Edouard de la Vergne Date: Mon, 2 Sep 2024 15:37:48 +0200 Subject: [PATCH 2/6] Add use cases for test in manifest --- ledger_app.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ledger_app.toml b/ledger_app.toml index e7eb565a..9fc89d3e 100644 --- a/ledger_app.toml +++ b/ledger_app.toml @@ -3,5 +3,9 @@ build_directory = "./" sdk = "C" devices = ["nanos", "nanox", "nanos+", "stax"] +[use_cases] +use_test_keys = "TEST_PUBLIC_KEY=1" +dbg_use_test_keys = "DEBUG=1 TEST_PUBLIC_KEY=1" + [tests] pytest_directory = "./test/python/" From b9320a2e13f07328ea35a7d6d4b1c2470b9e8587 Mon Sep 17 00:00:00 2001 From: Charles-Edouard de la Vergne Date: Mon, 2 Sep 2024 15:36:29 +0200 Subject: [PATCH 3/6] Replace 'bsc' by 'tezos' in TestAliasAppname --- test/python/test_input_robustness.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/python/test_input_robustness.py b/test/python/test_input_robustness.py index ac4b7237..bc97d0fa 100644 --- a/test/python/test_input_robustness.py +++ b/test/python/test_input_robustness.py @@ -4,6 +4,7 @@ from .apps.exchange import ExchangeClient, Rate, SubCommand, Errors, Command from .apps.exchange_transaction_builder import get_partner_curve, craft_and_sign_tx from .apps.signing_authority import SigningAuthority, LEDGER_SIGNER +from .apps.tezos import encode_address from .apps import cal as cal CURRENCY_FROM = cal.XLM_CURRENCY_CONFIGURATION @@ -241,19 +242,18 @@ def test_currency_alias(self, backend): "payin_extra_id": b"", "refund_address": b"0xDad77910DbDFdE764fC21FCD4E74D71bBACA6D8D", "refund_extra_id": b"", - "payout_address": b"0xDad77910DbDFdE764fC21FCD4E74D71bBACA6D8D", + "payout_address": encode_address("e6330795ffe18f873b83cb13662442b87bd98c22"), "payout_extra_id": b"", "currency_from": "ETH", - "currency_to": "BNB", + "currency_to": "XTZ", "amount_to_provider": int.to_bytes(1000, length=8, byteorder='big'), "amount_to_wallet": b"\246\333t\233+\330\000", } fees = 100 - bsc_conf = cal.BNB_CURRENCY_CONFIGURATION.conf # "Binance Smart Chain" - bsc_conf_alias_1 = create_currency_config("BNB", "bsc", ("BNB", 18)) - bsc_conf_alias_2 = create_currency_config("BNB", "Bsc", ("BNB", 18)) - for conf in bsc_conf, bsc_conf_alias_1, bsc_conf_alias_2: + xtz_conf = cal.XTZ_CURRENCY_CONFIGURATION.conf # "Tezos" + xtz_conf_alias = create_currency_config("XTZ", "Tezos Wallet") + for conf in xtz_conf, xtz_conf_alias: ex = ExchangeClient(backend, Rate.FIXED, SubCommand.SWAP) transaction_id = ex.init_transaction().data backend.wait_for_home_screen() From a0a3cc879cb7ef43da3a73f62c862f6e8e6916ac Mon Sep 17 00:00:00 2001 From: Francois Beutin Date: Wed, 4 Sep 2024 11:06:55 +0200 Subject: [PATCH 4/6] Fix wrong derivation path being used and use actual device address --- test/python/test_input_robustness.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/python/test_input_robustness.py b/test/python/test_input_robustness.py index bc97d0fa..489df277 100644 --- a/test/python/test_input_robustness.py +++ b/test/python/test_input_robustness.py @@ -242,7 +242,7 @@ def test_currency_alias(self, backend): "payin_extra_id": b"", "refund_address": b"0xDad77910DbDFdE764fC21FCD4E74D71bBACA6D8D", "refund_extra_id": b"", - "payout_address": encode_address("e6330795ffe18f873b83cb13662442b87bd98c22"), + "payout_address": "tz1YPjCVqgimTAPmxZX9egDeTFRCmrTRqmp9", "payout_extra_id": b"", "currency_from": "ETH", "currency_to": "XTZ", @@ -264,5 +264,5 @@ def test_currency_alias(self, backend): ex.check_transaction_signature(tx_signature) # If the alias does not work, CHECK_PAYOUT_ADDRESS will crash - payload = prefix_with_len(conf) + LEDGER_SIGNER.sign(conf) + prefix_with_len(CURRENCY_TO.packed_derivation_path) + payload = prefix_with_len(conf) + LEDGER_SIGNER.sign(conf) + prefix_with_len(cal.XTZ_CURRENCY_CONFIGURATION.packed_derivation_path) ex._exchange(Command.CHECK_PAYOUT_ADDRESS, payload=payload) From ea4ae9ede251b236c5995ee9c75b0a25a45984ec Mon Sep 17 00:00:00 2001 From: Charles-Edouard de la Vergne Date: Fri, 30 Aug 2024 17:29:36 +0200 Subject: [PATCH 5/6] Remove useless BSC tests: - Remove sideloaded app - Remove chain - Remove BSCLegacyTests --- .github/workflows/reusable_swap_functional_tests.yml | 3 --- test/python/conftest.py | 1 - test/python/test_ethereum.py | 12 ------------ 3 files changed, 16 deletions(-) diff --git a/.github/workflows/reusable_swap_functional_tests.yml b/.github/workflows/reusable_swap_functional_tests.yml index 2e8f661c..2b03df87 100644 --- a/.github/workflows/reusable_swap_functional_tests.yml +++ b/.github/workflows/reusable_swap_functional_tests.yml @@ -135,9 +135,6 @@ jobs: - name: solana repo: ${{ inputs.repo_for_solana }} branch: ${{ inputs.branch_for_solana }} - - name: bsc - repo: ${{ inputs.repo_for_ethereum }} - branch: ${{ inputs.branch_for_ethereum }} - name: DOT repo: ${{ inputs.repo_for_polkadot }} branch: ${{ inputs.branch_for_polkadot }} diff --git a/test/python/conftest.py b/test/python/conftest.py index ce2a03c5..df123d5a 100644 --- a/test/python/conftest.py +++ b/test/python/conftest.py @@ -23,7 +23,6 @@ "litecoin": "Litecoin", "stellar": "Stellar", "solana": "Solana", - "bsc": "Binance Smart Chain", "DOT": "Polkadot", "tron": "Tron", } diff --git a/test/python/test_ethereum.py b/test/python/test_ethereum.py index 172a5cf6..1d02bde8 100644 --- a/test/python/test_ethereum.py +++ b/test/python/test_ethereum.py @@ -110,18 +110,6 @@ def test_bsc(self, backend, exchange_navigation_helper, test_to_run): -# ExchangeTestRunner implementation for BSC on BNB application -class BSCLegacyTests(GenericEthereumNetworkTests): - chain_id = 56 - currency_configuration = cal.BNB_LEGACY_CURRENCY_CONFIGURATION - -class TestsBSCLegacy: - @pytest.mark.parametrize('test_to_run', ALL_TESTS_EXCEPT_MEMO_AND_THORSWAP) - def test_bsc_legacy(self, backend, exchange_navigation_helper, test_to_run): - BSCLegacyTests(backend, exchange_navigation_helper).run_test(test_to_run) - - - # ExchangeTestRunner implementation for Eth token DAI class DAITests(GenericEthereumNetworkTests): currency_configuration = cal.DAI_CURRENCY_CONFIGURATION From c892168381fc1f724d3130262ef4597af35d7dcb Mon Sep 17 00:00:00 2001 From: Francois Beutin Date: Wed, 4 Sep 2024 11:18:18 +0200 Subject: [PATCH 6/6] Use reusable lint --- .github/workflows/lint-workflow.yml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/lint-workflow.yml b/.github/workflows/lint-workflow.yml index abc49c79..fd45533d 100644 --- a/.github/workflows/lint-workflow.yml +++ b/.github/workflows/lint-workflow.yml @@ -9,17 +9,10 @@ on: pull_request: jobs: - job_lint: - name: Lint - runs-on: ubuntu-latest - - steps: - - name: Clone - uses: actions/checkout@v4 - - - name: Lint - uses: DoozyX/clang-format-lint-action@v0.13 - with: - source: './src' - extensions: 'h,c' - clangFormatVersion: 12 + check_linting: + name: Check linting using the reusable workflow + uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_lint.yml@v1 + with: + source: './' + extensions: 'h,c' + version: 12