Testing

Testing a plugin is very similar to that of a standalone app, with the Ragger framework (opens in a new tab) and Speculos (opens in a new tab). There are however a few differences :

Ethereum Ragger client

It is a Python module (opens in a new tab) that abstracts the APDU crafting and response parsing. It comes from the Ethereum app itself and is what's used to test it in its CI but also has everything needed for testing plugins. It also comes with test signing keys so that APDUs that are signed by either the CAL (opens in a new tab) or a Ledger backend in production can be signed during the test and verified by the Ethereum app.

ABIs

The Ethereum Ragger client relies on Web3.py (opens in a new tab) for transaction crafting, it can also leverage a smart contract's ABI (Application Binary Interface) which is obtainable from a website like Etherscan (opens in a new tab). It makes it really easy to craft a function call which greatly helps tests readability.

Signature verification

The Ragger client can also easily verify a transaction's signature by recovering (opens in a new tab) the Ethereum address of the wallet that signed the transaction. Testing the UI is crucial but so is testing the signatures we produce.

Ethereum app dependency

The plugins rely on the Ethereum app (opens in a new tab) so in order to run the tests the application needs to be compiled and placed in the required folder (opens in a new tab).

The easiest way and what we recommend is using Visual Studio Code with the official Ledger Extension (opens in a new tab) which takes care of this automatically.

Ledger
Copyright © Ledger SAS. All rights reserved. Ledger, Ledger Nano S, Ledger Vault, Bolos are registered trademarks of Ledger SAS