This document explains how to set up and run hardware tests for Trezor and Ledger devices.
- Trezor Device: Model T, One, or newer
- Trezor Bridge: Required for USB communication
- Node.js: Version 16.20.1 or higher
Use the provided setup script to automatically install dependencies and configure your environment:
# Run the automated setup script
./scripts/setup-hw-testing.shThis script will:
- Install Trezor Bridge automatically
- Set up udev rules (Linux only)
- Create necessary directories
- Make all scripts executable
Using the installation script:
./scripts/install-trezor-bridge.shOr manually:
macOS:
brew install trezor-suiteLinux:
# Download from https://suite.trezor.io/trezor-bridge
# Or use your package managerWindows:
- Download from Trezor Suite
# Start Trezor Bridge
trezord# Run tests with your physical Trezor device
yarn test:hw:trezor| Command | Description |
|---|---|
yarn test:hw:trezor |
Run Trezor hardware tests |
yarn test:hw:ledger |
Run Ledger hardware tests |
Hardware tests are located in:
test/hardware/trezor/- Trezor-specific teststest/hardware/ledger/- Ledger-specific tests
- Ensure Trezor Bridge is running:
trezord - Check device connection
- Verify device is unlocked
- Connect your Trezor device via USB
- Unlock the device using your PIN
- Ensure no other applications are using the device
- Unlock your Trezor device
- Close other applications using the device
- Try reconnecting the device
- Never use real hardware devices in CI/CD
- Physical devices should only be used in secure development environments
- Always verify device authenticity before use
- Create test files in
test/hardware/trezor/ortest/hardware/ledger/ - Use the existing test patterns
- Ensure tests work with physical devices
import { TrezorKeyAgent } from '@cardano-sdk/hardware-trezor';
describe('TrezorKeyAgent', () => {
it('should work with hardware device', async () => {
const keyAgent = await TrezorKeyAgent.createWithDevice({
chainId: Cardano.ChainIds.Preprod,
trezorConfig: {
communicationType: CommunicationType.Node,
manifest: {
appUrl: 'https://your-app.com',
email: 'contact@your-app.com'
}
}
}, dependencies);
// Test your functionality
});
});