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 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/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 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/" 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 diff --git a/test/python/test_input_robustness.py b/test/python/test_input_robustness.py index ac4b7237..489df277 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": "tz1YPjCVqgimTAPmxZX9egDeTFRCmrTRqmp9", "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() @@ -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)