Fix various Linter issues and mispelling

This commit is contained in:
Charles-Edouard de la Vergne
2024-03-18 17:28:51 +01:00
parent 36ae183a1c
commit f5ea9c51c2
100 changed files with 229 additions and 220 deletions

View File

@@ -19,8 +19,8 @@ Describe your issue in as much detail as possible here.
## Steps to reproduce ## Steps to reproduce
* Tell us how to reproduce this issue <br /> * Tell us how to reproduce this issue
* Where the issue is, if you know <br /> * Where the issue is, if you know
* Which commands triggered the issue, if any * Which commands triggered the issue, if any
## Expected behaviour ## Expected behaviour
@@ -37,4 +37,5 @@ Please paste any logs here that demonstrate the issue, if they exist
## Proposed solution ## Proposed solution
If you have an idea of how to fix this issue, please write it down here, so we can begin discussing it If you have an idea of how to fix this issue, please write it down here,
so we can begin discussing it

View File

@@ -1,6 +1,6 @@
--- ---
name: Feature report name: Feature report
about: Suggest an idea for this project about: Suggest an idea for this project
title: 'Add [Subject of the issue]' title: 'Add [Subject of the issue]'
labels: 'enhancement' labels: 'enhancement'
assignees: '' assignees: ''

View File

@@ -1,6 +1,6 @@
--- ---
name: Network request name: Network request
about: Request of new chain or network about: Request of new chain or network
title: 'Add {NameChain} network ({SYMBOL})' title: 'Add {NameChain} network ({SYMBOL})'
labels: 'enhancement, chain/network' labels: 'enhancement, chain/network'
assignees: '' assignees: ''
@@ -8,12 +8,13 @@ assignees: ''
--- ---
## Description ## Description
- [ ] Symbol:
- [ ] ChainId: - [ ] Symbol:
- [ ] Website: - [ ] ChainId:
- [ ] Block-Explorer: - [ ] Website:
- [ ] [slip-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md) type: - [ ] Block-Explorer:
- [ ] [slip-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md) type:
## Additional comments ## Additional comments
Please post additional comments in this section if you have them, otherwise delete it. Please post additional comments in this section if you have them, otherwise delete it.

View File

@@ -1,6 +1,6 @@
## Description ## Description
Please provide a detailed description of what was done in this PR. Please provide a detailed description of what was done in this PR.
(And mentioned if linked to an issue [docs](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)) (And mentioned if linked to an issue [docs](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue))
## Changes include ## Changes include
@@ -18,4 +18,4 @@ Please complete this section if any breaking changes have been made, otherwise d
## Additional comments ## Additional comments
Please post additional comments in this section if you have them, otherwise delete it. Please post additional comments in this section if you have them, otherwise delete it.

6
.gitignore vendored
View File

@@ -1,10 +1,6 @@
# Compilation of Ledger's app # Compilation of Ledger's app
src/glyphs.c
src/glyphs.h
bin/ bin/
debug/ debug/
dep/
obj/
build/ build/
# Python # Python
@@ -20,4 +16,4 @@ tests/elfs/*
tests/snapshots-tmp tests/snapshots-tmp
.vscode .vscode
.idea .idea

View File

@@ -211,7 +211,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added ### Added
- Provide network ticker to plugins (especialy helpful for Paraswap plugin) - Provide network ticker to plugins (especially helpful for Paraswap plugin)
- Polygon variant - Polygon variant
## [1.9.10](https://github.com/ledgerhq/app-ethereum/compare/1.9.9...1.9.10) - 2021-10-08 ## [1.9.10](https://github.com/ledgerhq/app-ethereum/compare/1.9.9...1.9.10) - 2021-10-08

View File

@@ -38,9 +38,9 @@ APPVERSION_P = 1
APPVERSION = $(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)-dev APPVERSION = $(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)-dev
APP_LOAD_FLAGS = --appFlags 0xa40 --dep Ethereum:$(APPVERSION) APP_LOAD_FLAGS = --appFlags 0xa40 --dep Ethereum:$(APPVERSION)
########################### #########################
# Set Chain environnement # # Set Chain environment #
########################### #########################
ifeq ($(CHAIN),) ifeq ($(CHAIN),)
CHAIN = ethereum CHAIN = ethereum

View File

@@ -31,18 +31,17 @@
- [Running all tests](#running-all-tests) - [Running all tests](#running-all-tests)
- [With Makefile](#with-makefile) - [With Makefile](#with-makefile)
- [With yarn](#with-yarn) - [With yarn](#with-yarn)
- [Running a specific tests](#running-a-specific-tests) - [Running a specific test](#running-a-specific-test)
- [Adding tests](#adding-tests) - [Adding tests](#adding-tests)
- [Zemu](#zemu) - [Zemu](#zemu)
- [Update binaries](#update-binaries) - [Update binaries](#update-binaries)
- [Contributing](#contributing) - [Contributing](#contributing)
</details> </details>
## About the project ## About the project
Ethereum wallet application framework for Nano S, Nano S Plus and Nano X. Ethereum wallet application framework for Nano S, Nano S Plus and Nano X.
Ledger Blue is not maintained anymore, but the app can still be compiled for this target using the branch [`blue-final-release`](https://github.com/LedgerHQ/app-ethereum/tree/blue-final-release). Ledger Blue is not maintained anymore, but the app can still be compiled for this target using the branch [`blue-final-release`](https://github.com/LedgerHQ/app-ethereum/tree/blue-final-release).
## Documentation ## Documentation
@@ -53,8 +52,9 @@ To compile it and load it on a device, please check out our [developer portal](h
### Plugins ### Plugins
We have the concept of plugins in the ETH app. We have the concept of plugins in the ETH app.
Find the documentations here: Find the documentations here:
- [Blog Ethereum plugins](https://blog.ledger.com/ethereum-plugins/) - [Blog Ethereum plugins](https://blog.ledger.com/ethereum-plugins/)
- [Ethereum application Plugins : Technical Specifications](https://github.com/LedgerHQ/app-ethereum/blob/master/doc/ethapp_plugins.asc) - [Ethereum application Plugins : Technical Specifications](https://github.com/LedgerHQ/app-ethereum/blob/master/doc/ethapp_plugins.asc)
- [Plugin guide](https://hackmd.io/300Ukv5gSbCbVcp3cZuwRQ) - [Plugin guide](https://hackmd.io/300Ukv5gSbCbVcp3cZuwRQ)
@@ -68,48 +68,55 @@ Testing is done via the open-source framework [zemu](https://github.com/Zondax/z
- [nodeJS == 16](https://github.com/nvm-sh/nvm) - [nodeJS == 16](https://github.com/nvm-sh/nvm)
- [yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable) - [yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable)
- [build environnement](https://github.com/LedgerHQ/ledger-app-builder/blob/master/Dockerfile) - [build environment](https://github.com/LedgerHQ/ledger-app-builder/blob/master/Dockerfile)
#### Build the applications required by the test suite #### Build the applications required by the test suite
1. Add your BOLOS SDKs path to: 1. Add your BOLOS SDKs path to:
- `NANOS_SDK` and `NANOX_SDK`
`NANOS_SDK` and `NANOX_SDK`
2. Go to the `tests` folder and run `./build_local_test_elfs.sh` 2. Go to the `tests` folder and run `./build_local_test_elfs.sh`
- ```sh
cd tests ```sh
# This helper script will build the applications required by the test suite and move them at the right place. cd tests
yarn install # This helper script will build the applications required by the test suite and move them at the right place.
./build_local_test_elfs.sh yarn install
``` ./build_local_test_elfs.sh
```
### Running all tests ### Running all tests
#### With Makefile #### With Makefile
1. Then you can install and run tests by simply running on the `root` of the repo: 1. Then you can install and run tests by simply running on the `root` of the repo:
- ```sh
make test ```sh
``` make test
- This will run `make install_tests` and `make run_tests` # This will run `make install_tests` and `make run_tests`
```
#### With yarn #### With yarn
1. Go to the `tests` folder and run: 1. Go to the `tests` folder and run:
- ```sh
yarn test
```
### Running a specific tests ```sh
yarn test
```
1. Go to the `tests` folder and run: ### Running a specific test
- ```sh
yarn jest --runInBand --detectOpenHandles {YourTestFile}
```
2. For example with the `send test`:
- ```sh
yarn jest --runInBand --detectOpenHandles src/send.test.js
```
1. Go to the `tests` folder and run:
```sh
yarn jest --runInBand --detectOpenHandles {YourTestFile}
```
2. For example with the `send test`:
```sh
yarn jest --runInBand --detectOpenHandles src/send.test.js
```
### Adding tests ### Adding tests
@@ -128,7 +135,7 @@ Finally make sure you adapt the expected signature!
#### Update binaries #### Update binaries
Don't forget to update the binaries in the test folder. To do so, compile with those environement variables: Don't forget to update the binaries in the test folder. To do so, compile with those environment variables:
```sh ```sh
make DEBUG=1 ALLOW_DATA=1 make DEBUG=1 ALLOW_DATA=1
@@ -142,10 +149,9 @@ cp bin/app.elf tests/elfs/ethereum_nanos.elf
Repeat the operation for a binary compiled with nanoX SDK and change for `ethereum_nanox.elf`. Repeat the operation for a binary compiled with nanoX SDK and change for `ethereum_nanox.elf`.
## Contributing ## Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. Contributions are what makes the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag `enhancement`. If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag `enhancement`.

View File

@@ -48,4 +48,4 @@ Home = "https://github.com/LedgerHQ/app-ethereum"
ignore_missing_imports = true ignore_missing_imports = true
[tool.flake8] [tool.flake8]
max-line-length = 120 max-line-length = 120

View File

@@ -12,7 +12,7 @@ This document described how a specific device UI for a smart contract can be add
## Standard support ## Standard support
The applications already includes dedicated UI support for those specific contract calls : The application already includes dedicated UI support for those specific contract calls :
* ERC 20 approve(address, uint256) - implementation in *src_features/erc20_approval* * ERC 20 approve(address, uint256) - implementation in *src_features/erc20_approval*
* ERC 20 transfer(address, uint256) - implementation in *src_features/signTx* * ERC 20 transfer(address, uint256) - implementation in *src_features/signTx*
@@ -45,4 +45,3 @@ A UI implementation might want to convert an ERC 20 token contract address to a
2 tickers can be temporarily provisioned to the application by using the PROVIDE ERC 20 TOKEN INFORMATION APDU, described in *src_features/provideErc20TokenInformation* - the UI can then iterate on the provisioned tickers to display relevant information to the user 2 tickers can be temporarily provisioned to the application by using the PROVIDE ERC 20 TOKEN INFORMATION APDU, described in *src_features/provideErc20TokenInformation* - the UI can then iterate on the provisioned tickers to display relevant information to the user
The same mechanism will be extended to support well known contract addresses in the future The same mechanism will be extended to support well known contract addresses in the future

View File

@@ -801,7 +801,7 @@ None
This command provides a trusted way of deciding what information from the JSON data to show and replace some values by more meaningful ones. This command provides a trusted way of deciding what information from the JSON data to show and replace some values by more meaningful ones.
This mode can be overriden by the in-app setting to fully clear-sign EIP-712 messages. This mode can be overridden by the in-app setting to fully clear-sign EIP-712 messages.
For the signatures : For the signatures :

View File

@@ -59,7 +59,7 @@ if args.path == None:
domainHash = binascii.unhexlify(args.domainHash) domainHash = binascii.unhexlify(args.domainHash)
messageHash = binascii.unhexlify(args.messageHash) messageHash = binascii.unhexlify(args.messageHash)
encodedTx = domainHash + messageHash encodedTx = domainHash + messageHash
donglePath = parse_bip32_path(args.path) donglePath = parse_bip32_path(args.path)
apdu = bytearray.fromhex("e00c0000") apdu = bytearray.fromhex("e00c0000")

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/200625'" APP_LOAD_PARAMS += --path "44'/200625'"
TICKER = "AKA" TICKER = "AKA"
CHAIN_ID = 200625 CHAIN_ID = 200625
APPNAME = "Akroma" APPNAME = "Akroma"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/246529'" APP_LOAD_PARAMS += --path "44'/246529'"
TICKER = "ATS" TICKER = "ATS"
CHAIN_ID = 246529 CHAIN_ID = 246529
APPNAME = "ARTIS sigma1" APPNAME = "ARTIS sigma1"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/246785'" APP_LOAD_PARAMS += --path "44'/246785'"
TICKER = "ATS" TICKER = "ATS"
CHAIN_ID = 246785 CHAIN_ID = 246785
APPNAME = "ARTIS tau1" APPNAME = "ARTIS tau1"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/1620'" APP_LOAD_PARAMS += --path "44'/1620'"
TICKER = "ATH" TICKER = "ATH"
CHAIN_ID = 1620 CHAIN_ID = 1620
APPNAME = "Atheios" APPNAME = "Atheios"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "BNB" TICKER = "BNB"
CHAIN_ID = 56 CHAIN_ID = 56
APPNAME = "Binance Smart Chain" APPNAME = "Binance Smart Chain"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "BTT" TICKER = "BTT"
CHAIN_ID = 199 CHAIN_ID = 199
APPNAME = "BTTC" APPNAME = "BTTC"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/820'" APP_LOAD_PARAMS += --path "44'/820'"
TICKER = "CLO" TICKER = "CLO"
CHAIN_ID = 820 CHAIN_ID = 820
APPNAME = "Callisto" APPNAME = "Callisto"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "CFX" TICKER = "CFX"
CHAIN_ID = 1030 CHAIN_ID = 1030
APPNAME = "Conflux eSpace" APPNAME = "Conflux eSpace"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "CUBE" TICKER = "CUBE"
CHAIN_ID = 1818 CHAIN_ID = 1818
APPNAME = "Cube" APPNAME = "Cube"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/237'" APP_LOAD_PARAMS += --path "44'/237'"
TICKER = "DXN" TICKER = "DXN"
CHAIN_ID = 237 CHAIN_ID = 237
APPNAME = "DEXON" APPNAME = "DEXON"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/163'" APP_LOAD_PARAMS += --path "44'/163'"
TICKER = "ELLA" TICKER = "ELLA"
CHAIN_ID = 64 CHAIN_ID = 64
APPNAME = "Ellaism" APPNAME = "Ellaism"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/1313114'" APP_LOAD_PARAMS += --path "44'/1313114'"
TICKER = "ETHO" TICKER = "ETHO"
CHAIN_ID = 1313114 CHAIN_ID = 1313114
APPNAME = "Ether-1" APPNAME = "Ether-1"

View File

@@ -2,4 +2,4 @@
APP_LOAD_PARAMS += --path "44'/61'" --path "44'/60'" APP_LOAD_PARAMS += --path "44'/61'" --path "44'/60'"
TICKER = "ETC" TICKER = "ETC"
CHAIN_ID = 61 CHAIN_ID = 61
APPNAME = "Ethereum Classic" APPNAME = "Ethereum Classic"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/1987'" APP_LOAD_PARAMS += --path "44'/1987'"
TICKER = "EGEM" TICKER = "EGEM"
CHAIN_ID = 1987 CHAIN_ID = 1987
APPNAME = "EtherGem" APPNAME = "EtherGem"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/31102'" APP_LOAD_PARAMS += --path "44'/31102'"
TICKER = "ESN" TICKER = "ESN"
CHAIN_ID = 31102 CHAIN_ID = 31102
APPNAME = "Ethersocial" APPNAME = "Ethersocial"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/40'" APP_LOAD_PARAMS += --path "44'/40'"
TICKER = "EXP" TICKER = "EXP"
CHAIN_ID = 2 CHAIN_ID = 2
APPNAME = "Expanse" APPNAME = "Expanse"

View File

@@ -6,4 +6,4 @@ CHAIN_ID = 14
APP_LOAD_PARAMS += --tlvraw 9F:01 APP_LOAD_PARAMS += --tlvraw 9F:01
DEFINES += HAVE_PENDING_REVIEW_SCREEN DEFINES += HAVE_PENDING_REVIEW_SCREEN
APPNAME = "Flare" APPNAME = "Flare"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'" APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
TICKER = "FLR" TICKER = "FLR"
CHAIN_ID = 16 CHAIN_ID = 16
APPNAME = "Flare Coston" APPNAME = "Flare Coston"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/6060'" APP_LOAD_PARAMS += --path "44'/6060'"
TICKER = "GO" TICKER = "GO"
CHAIN_ID = 60 CHAIN_ID = 60
APPNAME = "GoChain" APPNAME = "GoChain"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/269'" APP_LOAD_PARAMS += --path "44'/269'"
TICKER = "HPB" TICKER = "HPB"
CHAIN_ID = 269 CHAIN_ID = 269
APPNAME = "HPB" APPNAME = "HPB"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "KAI" TICKER = "KAI"
CHAIN_ID = 24 CHAIN_ID = 24
APPNAME = "KardiaChain" APPNAME = "KardiaChain"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "MTR" TICKER = "MTR"
CHAIN_ID = 82 CHAIN_ID = 82
APPNAME = "Meter" APPNAME = "Meter"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/76'" APP_LOAD_PARAMS += --path "44'/76'"
TICKER = "MIX" TICKER = "MIX"
CHAIN_ID = 76 CHAIN_ID = 76
APPNAME = "Mix" APPNAME = "Mix"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" --path "44'/1284'" APP_LOAD_PARAMS += --path "44'/60'" --path "44'/1284'"
TICKER = "GLMR" TICKER = "GLMR"
CHAIN_ID = 1284 CHAIN_ID = 1284
APPNAME = "Moonbeam" APPNAME = "Moonbeam"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" --path "44'/1285'" APP_LOAD_PARAMS += --path "44'/60'" --path "44'/1285'"
TICKER = "MOVR" TICKER = "MOVR"
CHAIN_ID = 1285 CHAIN_ID = 1285
APPNAME = "Moonriver" APPNAME = "Moonriver"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/184'" APP_LOAD_PARAMS += --path "44'/184'"
TICKER = "MUSIC" TICKER = "MUSIC"
CHAIN_ID = 7762959 CHAIN_ID = 7762959
APPNAME = "Musicoin" APPNAME = "Musicoin"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "OKT" TICKER = "OKT"
CHAIN_ID = 66 CHAIN_ID = 66
APPNAME = "OKXChain" APPNAME = "OKXChain"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/164'" APP_LOAD_PARAMS += --path "44'/164'"
TICKER = "PIRL" TICKER = "PIRL"
CHAIN_ID = 3125659152 CHAIN_ID = 3125659152
APPNAME = "Pirl" APPNAME = "Pirl"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "POA" TICKER = "POA"
CHAIN_ID = 99 CHAIN_ID = 99
APPNAME = "POA" APPNAME = "POA"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "MATIC" TICKER = "MATIC"
CHAIN_ID = 137 CHAIN_ID = 137
APPNAME = "Polygon" APPNAME = "Polygon"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/2894'" APP_LOAD_PARAMS += --path "44'/2894'"
TICKER = "REOSC" TICKER = "REOSC"
CHAIN_ID = 2894 CHAIN_ID = 2894
APPNAME = "REOSC" APPNAME = "REOSC"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/137'" --path "44'/00'" APP_LOAD_PARAMS += --path "44'/137'" --path "44'/00'"
TICKER = "RBTC" TICKER = "RBTC"
CHAIN_ID = 30 CHAIN_ID = 30
APPNAME = "RSK" APPNAME = "RSK"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/37310'" APP_LOAD_PARAMS += --path "44'/37310'"
TICKER = "RBTC" TICKER = "RBTC"
CHAIN_ID = 31 CHAIN_ID = 31
APPNAME = "RSK Test" APPNAME = "RSK Test"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/60'" APP_LOAD_PARAMS += --path "44'/60'"
TICKER = "SHFT" TICKER = "SHFT"
CHAIN_ID = 7341 CHAIN_ID = 7341
APPNAME = "Shyft" APPNAME = "Shyft"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'" APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
TICKER = "SGB" TICKER = "SGB"
CHAIN_ID = 19 CHAIN_ID = 19
APPNAME = "Songbird" APPNAME = "Songbird"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'" APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
TICKER = "TCR" TICKER = "TCR"
CHAIN_ID = 20531812 CHAIN_ID = 20531812
APPNAME = "TecraCoin" APPNAME = "TecraCoin"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'" APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
TICKER = "TCR" TICKER = "TCR"
CHAIN_ID = 20531811 CHAIN_ID = 20531811
APPNAME = "TecraTestnet" APPNAME = "TecraTestnet"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/1001'" APP_LOAD_PARAMS += --path "44'/1001'"
TICKER = "TT" TICKER = "TT"
CHAIN_ID = 108 CHAIN_ID = 108
APPNAME = "ThunderCore" APPNAME = "ThunderCore"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/889'" APP_LOAD_PARAMS += --path "44'/889'"
TICKER = "TOMO" TICKER = "TOMO"
CHAIN_ID = 88 CHAIN_ID = 88
APPNAME = "TomoChain" APPNAME = "TomoChain"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/108'" APP_LOAD_PARAMS += --path "44'/108'"
TICKER = "UBQ" TICKER = "UBQ"
CHAIN_ID = 8 CHAIN_ID = 8
APPNAME = "Ubiq" APPNAME = "Ubiq"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/73799'" --path "44'/60'" APP_LOAD_PARAMS += --path "44'/73799'" --path "44'/60'"
TICKER = "VOLTA" TICKER = "VOLTA"
CHAIN_ID = 73799 CHAIN_ID = 73799
APPNAME = "Volta" APPNAME = "Volta"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/227'" APP_LOAD_PARAMS += --path "44'/227'"
TICKER = "WEB" TICKER = "WEB"
CHAIN_ID = 24484 CHAIN_ID = 24484
APPNAME = "Webchain" APPNAME = "Webchain"

View File

@@ -1,4 +1,4 @@
APP_LOAD_PARAMS += --path "44'/77777'" APP_LOAD_PARAMS += --path "44'/77777'"
TICKER = "ZYN" TICKER = "ZYN"
CHAIN_ID = 78 CHAIN_ID = 78
APPNAME = "Wethio" APPNAME = "Wethio"

View File

@@ -518,7 +518,7 @@ static parserStatus_e processTxInternal(txContext_t *context) {
PRINTF("parsing is done\n"); PRINTF("parsing is done\n");
return USTREAM_FINISHED; return USTREAM_FINISHED;
} }
// Old style transaction (pre EIP-155). Transations could just skip `v,r,s` so we needed to // Old style transaction (pre EIP-155). Transactions could just skip `v,r,s` so we needed to
// cut parsing here. commandLength == 0 could happen in two cases : // cut parsing here. commandLength == 0 could happen in two cases :
// 1. We are in an old style transaction : just return `USTREAM_FINISHED`. // 1. We are in an old style transaction : just return `USTREAM_FINISHED`.
// 2. We are at the end of an APDU in a multi-apdu process. This would make us return // 2. We are at the end of an APDU in a multi-apdu process. This would make us return

View File

@@ -412,7 +412,7 @@ void handleApdu(unsigned int *flags, unsigned int *tx) {
// If we are in swap mode and have validated a TX, we send it and immediately quit // If we are in swap mode and have validated a TX, we send it and immediately quit
if (quit_now) { if (quit_now) {
if (io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, *tx) == 0) { if (io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, *tx) == 0) {
// In case of success, the apdu is sent immediatly and eth exits // In case of success, the apdu is sent immediately and eth exits
// Reaching this code means we encountered an error // Reaching this code means we encountered an error
finalize_exchange_sign_transaction(false); finalize_exchange_sign_transaction(false);
} else { } else {

View File

@@ -13,7 +13,7 @@ typedef struct network_info_s {
static const char *unknown_ticker = "???"; static const char *unknown_ticker = "???";
// Mappping of chain ids to networks. // Mapping of chain ids to networks.
static const network_info_t NETWORK_MAPPING[] = { static const network_info_t NETWORK_MAPPING[] = {
{.chain_id = 1, .name = "Ethereum", .ticker = "ETH"}, {.chain_id = 1, .name = "Ethereum", .ticker = "ETH"},
{.chain_id = 3, .name = "Ropsten", .ticker = "ETH"}, {.chain_id = 3, .name = "Ropsten", .ticker = "ETH"},
@@ -153,7 +153,7 @@ const char *get_displayable_ticker(const uint64_t *chain_id, const chain_config_
} }
/** /**
* Checks wether the app can support the given chain ID * Checks whether the app can support the given chain ID
* *
* - If the given chain ID is the same as the app's one * - If the given chain ID is the same as the app's one
* - If both chain IDs are present in the array of Ethereum-compatible networks * - If both chain IDs are present in the array of Ethereum-compatible networks

View File

@@ -37,4 +37,4 @@ void plugin_ui_get_item(void) {
sizeof(strings.common.fullAddress), sizeof(strings.common.fullAddress),
strings.common.fullAmount, strings.common.fullAmount,
sizeof(strings.common.fullAmount)); sizeof(strings.common.fullAmount));
} }

View File

@@ -8,4 +8,4 @@ void plugin_ui_get_item_internal(uint8_t *title_buffer,
uint8_t *msg_buffer, uint8_t *msg_buffer,
size_t msg_buffer_size); size_t msg_buffer_size);
#endif // _PLUGIN_H_ #endif // _PLUGIN_H_

View File

@@ -3,7 +3,7 @@
// clang-format off // clang-format off
UX_STEP_NOCB( UX_STEP_NOCB(
ux_display_privacy_public_key_flow_1_step, ux_display_privacy_public_key_flow_1_step,
pnn, pnn,
{ {
&C_icon_eye, &C_icon_eye,
@@ -11,21 +11,21 @@ UX_STEP_NOCB(
"privacy key", "privacy key",
}); });
UX_STEP_NOCB( UX_STEP_NOCB(
ux_display_privacy_public_key_flow_2_step, ux_display_privacy_public_key_flow_2_step,
bnnn_paging, bnnn_paging,
{ {
.title = "Address", .title = "Address",
.text = strings.common.fullAddress, .text = strings.common.fullAddress,
}); });
UX_STEP_NOCB( UX_STEP_NOCB(
ux_display_privacy_public_key_flow_3_step, ux_display_privacy_public_key_flow_3_step,
bnnn_paging, bnnn_paging,
{ {
.title = "Key", .title = "Key",
.text = strings.common.fullAmount, .text = strings.common.fullAmount,
}); });
UX_STEP_CB( UX_STEP_CB(
ux_display_privacy_public_key_flow_4_step, ux_display_privacy_public_key_flow_4_step,
pb, pb,
io_seproxyhal_touch_privacy_ok(NULL), io_seproxyhal_touch_privacy_ok(NULL),
{ {
@@ -33,7 +33,7 @@ UX_STEP_CB(
"Approve", "Approve",
}); });
UX_STEP_CB( UX_STEP_CB(
ux_display_privacy_public_key_flow_5_step, ux_display_privacy_public_key_flow_5_step,
pb, pb,
io_seproxyhal_touch_privacy_cancel(NULL), io_seproxyhal_touch_privacy_cancel(NULL),
{ {

View File

@@ -46,4 +46,4 @@ void display_next_plugin_item(bool entering) {
} }
} }
} }
} }

View File

@@ -90,7 +90,7 @@ typedef struct ethPluginSharedRO_s {
// Plugin-only memory allocated by the Ethereum application and used by the plugin. // Plugin-only memory allocated by the Ethereum application and used by the plugin.
#define PLUGIN_CONTEXT_SIZE (5 * INT256_LENGTH) #define PLUGIN_CONTEXT_SIZE (5 * INT256_LENGTH)
// It is recommended to cast the raw uin8_t array to a structure meaningfull for your plugin // It is recommended to cast the raw uin8_t array to a structure meaningful for your plugin
// Helper to check that the actual plugin context structure is not bigger than the allocated memory // Helper to check that the actual plugin context structure is not bigger than the allocated memory
#define ASSERT_SIZEOF_PLUGIN_CONTEXT(s) \ #define ASSERT_SIZEOF_PLUGIN_CONTEXT(s) \
_Static_assert(sizeof(s) <= PLUGIN_CONTEXT_SIZE, "Plugin context structure is too big.") _Static_assert(sizeof(s) <= PLUGIN_CONTEXT_SIZE, "Plugin context structure is too big.")

View File

@@ -444,7 +444,7 @@ static bool check_found_tlv_tags(s_tlv_handler *handlers, int handler_count) {
// prevent missing or duplicated tags // prevent missing or duplicated tags
for (int idx = 0; idx < handler_count; ++idx) { for (int idx = 0; idx < handler_count; ++idx) {
if (handlers[idx].found != 1) { if (handlers[idx].found != 1) {
PRINTF("Found %u occurence(s) of tag 0x%x in TLV!\n", PRINTF("Found %u occurrence(s) of tag 0x%x in TLV!\n",
handlers[idx].found, handlers[idx].found,
handlers[idx].tag); handlers[idx].tag);
return false; return false;

View File

@@ -174,7 +174,7 @@ void handleProvideNFTInformation(uint8_t p1,
} }
uint8_t signatureLen = workBuffer[offset]; uint8_t signatureLen = workBuffer[offset];
PRINTF("Sigature len: %d\n", signatureLen); PRINTF("Signature len: %d\n", signatureLen);
if (signatureLen < MIN_DER_SIG_SIZE || signatureLen > MAX_DER_SIG_SIZE) { if (signatureLen < MIN_DER_SIG_SIZE || signatureLen > MAX_DER_SIG_SIZE) {
PRINTF("SignatureLen too big or too small. Must be between %d and %d, got %d\n", PRINTF("SignatureLen too big or too small. Must be between %d and %d, got %d\n",
MIN_DER_SIG_SIZE, MIN_DER_SIG_SIZE,

View File

@@ -58,7 +58,7 @@ typedef bool verificationAlgo(const cx_ecfp_public_key_t *,
// Returns the plugin type of a given plugin name. // Returns the plugin type of a given plugin name.
// If the plugin name is not a specific known internal plugin, this function default return value is // If the plugin name is not a specific known internal plugin, this function default return value is
// `EXERNAL`. // `EXTERNAL`.
static pluginType_t getPluginType(char *pluginName, uint8_t pluginNameLength) { static pluginType_t getPluginType(char *pluginName, uint8_t pluginNameLength) {
if (pluginNameLength == sizeof(ERC721_STR) - 1 && if (pluginNameLength == sizeof(ERC721_STR) - 1 &&
strncmp(pluginName, ERC721_STR, pluginNameLength) == 0) { strncmp(pluginName, ERC721_STR, pluginNameLength) == 0) {

View File

@@ -173,7 +173,7 @@ static void field_hash_feed_parent(e_type field_type, const uint8_t *const hash)
* @param[in] field_ptr pointer to the struct field definition * @param[in] field_ptr pointer to the struct field definition
* @param[in] data the field value * @param[in] data the field value
* @param[in] data_length the value length * @param[in] data_length the value length
* @return whether an error occured or not * @return whether an error occurred or not
*/ */
static bool field_hash_domain_special_fields(const void *const field_ptr, static bool field_hash_domain_special_fields(const void *const field_ptr,
const uint8_t *const data, const uint8_t *const data,
@@ -202,7 +202,7 @@ static bool field_hash_domain_special_fields(const void *const field_ptr,
* @param[in] field_ptr pointer to the struct field definition * @param[in] field_ptr pointer to the struct field definition
* @param[in] data the field value * @param[in] data the field value
* @param[in] data_length the value length * @param[in] data_length the value length
* @return whether an error occured or not * @return whether an error occurred or not
*/ */
static bool field_hash_finalize(const void *const field_ptr, static bool field_hash_finalize(const void *const field_ptr,
const uint8_t *const data, const uint8_t *const data,

View File

@@ -115,7 +115,7 @@ const void *path_get_field(void) {
/** /**
* Go down (add) a depth level. * Go down (add) a depth level.
* *
* @return whether the push was succesful * @return whether the push was successful
*/ */
static bool path_depth_list_push(void) { static bool path_depth_list_push(void) {
if (path_struct == NULL) { if (path_struct == NULL) {

View File

@@ -51,7 +51,7 @@ static bool encode_and_hash_type(const void *const struct_ptr) {
struct_name = get_struct_name(struct_ptr, &struct_name_length); struct_name = get_struct_name(struct_ptr, &struct_name_length);
hash_nbytes((uint8_t *) struct_name, struct_name_length, (cx_hash_t *) &global_sha3); hash_nbytes((uint8_t *) struct_name, struct_name_length, (cx_hash_t *) &global_sha3);
// opening struct parenthese // opening struct parentheses
hash_byte('(', (cx_hash_t *) &global_sha3); hash_byte('(', (cx_hash_t *) &global_sha3);
field_ptr = get_struct_fields_array(struct_ptr, &fields_count); field_ptr = get_struct_fields_array(struct_ptr, &fields_count);
@@ -67,7 +67,7 @@ static bool encode_and_hash_type(const void *const struct_ptr) {
field_ptr = get_next_struct_field(field_ptr); field_ptr = get_next_struct_field(field_ptr);
} }
// closing struct parenthese // closing struct parentheses
hash_byte(')', (cx_hash_t *) &global_sha3); hash_byte(')', (cx_hash_t *) &global_sha3);
return true; return true;
@@ -107,7 +107,7 @@ static void sort_dependencies(uint8_t deps_count, const void **deps) {
/** /**
* Find all the dependencies from a given structure * Find all the dependencies from a given structure
* *
* @param[out] deps_count count of how many struct dependencie pointers * @param[out] deps_count count of how many struct dependency pointers
* @param[in] first_dep pointer to the first dependency pointer * @param[in] first_dep pointer to the first dependency pointer
* @param[in] struct_ptr pointer to the struct we are getting the dependencies of * @param[in] struct_ptr pointer to the struct we are getting the dependencies of
* @return pointer to the first found dependency, \ref NULL otherwise * @return pointer to the first found dependency, \ref NULL otherwise

View File

@@ -48,7 +48,7 @@ static bool ui_712_field_shown(void) {
* @param[in] src_length source buffer size * @param[in] src_length source buffer size
* @param[in] dst destination buffer * @param[in] dst destination buffer
* @param[in] dst_length destination buffer length * @param[in] dst_length destination buffer length
* @param[in] explicit_trunc if truncation should be explicitely shown * @param[in] explicit_trunc if truncation should be explicitly shown
*/ */
static void ui_712_set_buf(const char *const src, static void ui_712_set_buf(const char *const src,
size_t src_length, size_t src_length,
@@ -194,7 +194,7 @@ static void ui_712_format_str(const uint8_t *const data, uint8_t length) {
static const char *get_address_token_ticker(const uint8_t *addr) { static const char *get_address_token_ticker(const uint8_t *addr) {
tokenDefinition_t *token; tokenDefinition_t *token;
// Loop over the received token informations // Loop over the received token information
for (uint8_t token_idx = 0; token_idx < MAX_ITEMS; ++token_idx) { for (uint8_t token_idx = 0; token_idx < MAX_ITEMS; ++token_idx) {
if (tmpCtx.transactionContext.tokenSet[token_idx] == 1) { if (tmpCtx.transactionContext.tokenSet[token_idx] == 1) {
token = &tmpCtx.transactionContext.extraInfo[token_idx].token; token = &tmpCtx.transactionContext.extraInfo[token_idx].token;

View File

@@ -296,7 +296,7 @@ static void get_public_key(uint8_t *out, uint8_t outLength) {
getEthAddressFromRawKey(raw_pubkey, out); getEthAddressFromRawKey(raw_pubkey, out);
} }
/* Local implmentation of strncasecmp, workaround of the segfaulting base implem /* Local implementation of strncasecmp, workaround of the segfaulting base implem
* Remove once strncasecmp is fixed * Remove once strncasecmp is fixed
*/ */
static int strcasecmp_workaround(const char *str1, const char *str2) { static int strcasecmp_workaround(const char *str1, const char *str2) {

View File

@@ -27,4 +27,4 @@ static void buildScreen(void) {
void ui_display_public_eth2(void) { void ui_display_public_eth2(void) {
buildScreen(); buildScreen();
} }

View File

@@ -22,4 +22,4 @@ pytestdebug.log
.mypy_cache .mypy_cache
.coverage .coverage
.coverage.* .coverage.*
coverage.xml coverage.xml

View File

@@ -8,6 +8,7 @@ These tests are implemented in Python with the `SpeculosClient` interface which
- [pip](https://pip.pypa.io/en/stable/installation/) - [pip](https://pip.pypa.io/en/stable/installation/)
### Dependencies ### Dependencies
Python dependencies are listed in [requirements.txt](requirements.txt) Python dependencies are listed in [requirements.txt](requirements.txt)
```shell ```shell
@@ -19,6 +20,7 @@ python3 -m pip install -r requirements.txt
### Compilation app ### Compilation app
Go to the root of the repository: Go to the root of the repository:
```sh ```sh
make DEBUG=1 NFT_TESTING_KEY=1 BOLOS_SDK=$NANOX_SDK make DEBUG=1 NFT_TESTING_KEY=1 BOLOS_SDK=$NANOX_SDK
mv bin/app.elf tests/speculos/<some name>.elf mv bin/app.elf tests/speculos/<some name>.elf
@@ -26,12 +28,13 @@ mv bin/app.elf tests/speculos/<some name>.elf
Given the requirements are installed, just do (by default command): Given the requirements are installed, just do (by default command):
``` ```shell
cd tests/speculos/ cd tests/speculos/
pytest pytest
``` ```
### Custom options ### Custom options
- **--model:** "nanos", "nanox", "nanosp" | default: "nanos" - **--model:** "nanos", "nanox", "nanosp" | default: "nanos"
- **--display:** "qt", "headless" | default: "qt" - **--display:** "qt", "headless" | default: "qt"
- **--path:** the path of the binary app | default: path of makefile compilation - **--path:** the path of the binary app | default: path of makefile compilation
@@ -39,6 +42,7 @@ pytest
## Example ## Example
With `nanox` binary app: With `nanox` binary app:
```sh ```sh
# the --path is variable to where you put your binary # the --path is variable to where you put your binary

View File

@@ -32,6 +32,7 @@
## Ethereum_client ## Ethereum_client
### Ethereum_cmd_builder ### Ethereum_cmd_builder
```py ```py
def chunked(size, source) def chunked(size, source)
@@ -49,6 +50,7 @@ class EthereumCommandBuilder:
``` ```
### Ethereum_cmd ### Ethereum_cmd
```py ```py
class EthereumCommand: class EthereumCommand:
# Sending apdu and parsing the response in the right form # Sending apdu and parsing the response in the right form
@@ -61,16 +63,14 @@ class EthereumCommand:
def simple_sign_tx(self, bip32_path: str, transaction: Transaction, result: List = list()) -> None: def simple_sign_tx(self, bip32_path: str, transaction: Transaction, result: List = list()) -> None:
def sign_eip712(self, bip32_path: str, transaction: EIP712, result: List = list()) -> None: def sign_eip712(self, bip32_path: str, transaction: EIP712, result: List = list()) -> None:
def personal_sign_tx(self, bip32_path: str, transaction: PersonalTransaction, result: List = list()) -> None: def personal_sign_tx(self, bip32_path: str, transaction: PersonalTransaction, result: List = list()) -> None:
# Allows to send an apdu without return of speculos # Allows to send an apdu without return of speculos
def send_apdu(self, apdu: bytes) -> bytes: def send_apdu(self, apdu: bytes) -> bytes:
# Allows to send an apdu with return of speculos # Allows to send an apdu with return of speculos
def send_apdu_context(self, apdu: bytes, result: List = list()) -> bytes: def send_apdu_context(self, apdu: bytes, result: List = list()) -> bytes:
``` ```
### Utils ### Utils
```py ```py
def save_screenshot(cmd, path: str): def save_screenshot(cmd, path: str):
def compare_screenshot(cmd, path: str): def compare_screenshot(cmd, path: str):
@@ -80,21 +80,23 @@ def packed_bip32_path_from_string(path: str) -> bytes:
def write_varint(n: int) -> bytes: def write_varint(n: int) -> bytes:
def read_varint(buf: BytesIO, prefix: Optional[bytes] = None) -> int: def read_varint(buf: BytesIO, prefix: Optional[bytes] = None) -> int:
def read(buf: BytesIO, size: int) -> bytes: def read(buf: BytesIO, size: int) -> bytes:
def read_uint(buf: BytesIO, def read_uint(buf: BytesIO, bit_len: int, byteorder: Literal['big', 'little'] = 'little') -> int:
``` ```
## Tests new apdu ## Tests new apdu
If a new instruction is programmed it will be necessary to create 2 new functions. If a new instruction is programmed it will be necessary to create 2 new functions.
one in `ethereum_cmd_builder` : one in `ethereum_cmd_builder`:
- Creation of the raw apdu you can find some examples in this same file - Creation of the raw apdu you can find some examples in this same file
and one in `ethereum_cmd`: and one in `ethereum_cmd`:
- Send the apdu to speculos and parse the answer in a `list` named result you can find some examples in this same file - Send the apdu to speculos and parse the answer in a `list` named result you can find some examples in this same file
## Example for write new tests ## Example for write new tests
To send several apdu and get the return To send several apdu and get the return
```py ```py
FIRST = bytes.fromhex("{YourAPDU}") FIRST = bytes.fromhex("{YourAPDU}")
@@ -130,4 +132,3 @@ def test_some_error(cmd):
pass pass
assert error.args[0] == '0x6a80' assert error.args[0] == '0x6a80'
``` ```

View File

@@ -22,7 +22,7 @@ class EthereumCommand:
self.builder = EthereumCommandBuilder(debug=debug) self.builder = EthereumCommandBuilder(debug=debug)
self.debug = debug self.debug = debug
self.model = model self.model = model
def get_configuration(self) -> Tuple[int, int, int, int]: def get_configuration(self) -> Tuple[int, int, int, int]:
try: try:
response = self.client._apdu_exchange( response = self.client._apdu_exchange(
@@ -46,7 +46,7 @@ class EthereumCommand:
self.client._apdu_exchange( self.client._apdu_exchange(
self.builder.set_plugin(plugin=plugin) self.builder.set_plugin(plugin=plugin)
) )
except ApduException as error: except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_SET_PLUGIN) raise DeviceException(error_code=error.sw, ins=InsType.INS_SET_PLUGIN)
@@ -79,7 +79,7 @@ class EthereumCommand:
data=chunk[5:]) as exchange: data=chunk[5:]) as exchange:
yield exchange yield exchange
response: bytes = exchange.receive() response: bytes = exchange.receive()
except ApduException as error: except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_GET_PUBLIC_KEY) raise DeviceException(error_code=error.sw, ins=InsType.INS_GET_PUBLIC_KEY)
@@ -94,17 +94,17 @@ class EthereumCommand:
uncompressed_addr_len: bytes = response[offset:offset + pub_key_len] uncompressed_addr_len: bytes = response[offset:offset + pub_key_len]
offset += pub_key_len offset += pub_key_len
eth_addr_len: int = response[offset] eth_addr_len: int = response[offset]
offset += 1 offset += 1
eth_addr: bytes = response[offset:offset + eth_addr_len] eth_addr: bytes = response[offset:offset + eth_addr_len]
offset += eth_addr_len offset += eth_addr_len
chain_code: bytes = response[offset:] chain_code: bytes = response[offset:]
assert len(response) == 1 + pub_key_len + 1 + eth_addr_len + 32 # 32 -> chain_code_len assert len(response) == 1 + pub_key_len + 1 + eth_addr_len + 32 # 32 -> chain_code_len
result.append(uncompressed_addr_len) result.append(uncompressed_addr_len)
result.append(eth_addr) result.append(eth_addr)
result.append(chain_code) result.append(chain_code)
@@ -120,7 +120,7 @@ class EthereumCommand:
data=chunk[5:]) as exchange: data=chunk[5:]) as exchange:
yield exchange yield exchange
response: bytes = exchange.receive() response: bytes = exchange.receive()
except ApduException as error: except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_PERFORM_PRIVACY_OPERATION) raise DeviceException(error_code=error.sw, ins=InsType.INS_PERFORM_PRIVACY_OPERATION)
@@ -146,7 +146,7 @@ class EthereumCommand:
data=apdu[5:]) as exchange: data=apdu[5:]) as exchange:
yield exchange yield exchange
result.append(exchange.receive()) result.append(exchange.receive())
except ApduException as error: except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_SIGN_TX) raise DeviceException(error_code=error.sw, ins=InsType.INS_SIGN_TX)
@@ -162,14 +162,14 @@ class EthereumCommand:
data=chunk[5:]) as exchange: data=chunk[5:]) as exchange:
yield exchange yield exchange
response: bytes = exchange.receive() response: bytes = exchange.receive()
except ApduException as error: except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_SIGN_TX) raise DeviceException(error_code=error.sw, ins=InsType.INS_SIGN_TX)
# response = V (1) || R (32) || S (32) # response = V (1) || R (32) || S (32)
assert len(response) == 65 assert len(response) == 65
v, r, s = parse_sign_response(response) v, r, s = parse_sign_response(response)
result.append(v) result.append(v)
result.append(r) result.append(r)
result.append(s) result.append(s)
@@ -185,14 +185,14 @@ class EthereumCommand:
data=chunk[5:]) as exchange: data=chunk[5:]) as exchange:
yield exchange yield exchange
response: bytes = exchange.receive() response: bytes = exchange.receive()
except ApduException as error: except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_SIGN_EIP712) raise DeviceException(error_code=error.sw, ins=InsType.INS_SIGN_EIP712)
# response = V (1) || R (32) || S (32) # response = V (1) || R (32) || S (32)
assert len(response) == 65 assert len(response) == 65
v, r, s = parse_sign_response(response) v, r, s = parse_sign_response(response)
result.append(v) result.append(v)
result.append(r) result.append(r)
result.append(s) result.append(s)
@@ -211,16 +211,13 @@ class EthereumCommand:
response: bytes = exchange.receive() response: bytes = exchange.receive()
else: else:
self.send_apdu(apdu) self.send_apdu(apdu)
except ApduException as error: except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_SIGN_TX) raise DeviceException(error_code=error.sw, ins=InsType.INS_SIGN_TX)
# response = V (1) || R (32) || S (32) # response = V (1) || R (32) || S (32)
v, r, s = parse_sign_response(response) v, r, s = parse_sign_response(response)
result.append(v) result.append(v)
result.append(r) result.append(r)
result.append(s) result.append(s)

View File

@@ -156,7 +156,7 @@ class EthereumCommandBuilder:
""" """
cdata = packed_bip32_path_from_string(bip32_path) cdata = packed_bip32_path_from_string(bip32_path)
return self.serialize(cla=self.CLA, return self.serialize(cla=self.CLA,
ins=InsType.INS_GET_PUBLIC_KEY, ins=InsType.INS_GET_PUBLIC_KEY,
p1=0x01 if display else 0x00, p1=0x01 if display else 0x00,
@@ -171,11 +171,11 @@ class EthereumCommandBuilder:
bip32_path : str bip32_path : str
String representation of BIP32 path. String representation of BIP32 path.
Third party public key on Curve25519 : 32 bytes Third party public key on Curve25519 : 32 bytes
Optionnal if returning the shared secret Optional if returning the shared secret
""" """
cdata = packed_bip32_path_from_string(bip32_path) cdata = packed_bip32_path_from_string(bip32_path)
return self.serialize(cla=self.CLA, return self.serialize(cla=self.CLA,
ins=InsType.INS_PERFORM_PRIVACY_OPERATION, ins=InsType.INS_PERFORM_PRIVACY_OPERATION,
p1=0x01 if display else 0x00, p1=0x01 if display else 0x00,
@@ -200,7 +200,7 @@ class EthereumCommandBuilder:
""" """
cdata = packed_bip32_path_from_string(bip32_path) cdata = packed_bip32_path_from_string(bip32_path)
tx: bytes = transaction.serialize() tx: bytes = transaction.serialize()
cdata = cdata + tx cdata = cdata + tx
@@ -230,7 +230,7 @@ class EthereumCommandBuilder:
""" """
cdata = packed_bip32_path_from_string(bip32_path) cdata = packed_bip32_path_from_string(bip32_path)
tx: bytes = transaction.serialize() tx: bytes = transaction.serialize()
cdata = cdata + tx cdata = cdata + tx
@@ -259,12 +259,12 @@ class EthereumCommandBuilder:
""" """
cdata = packed_bip32_path_from_string(bip32_path) cdata = packed_bip32_path_from_string(bip32_path)
tx: bytes = transaction.serialize() tx: bytes = transaction.serialize()
cdata = cdata + tx cdata = cdata + tx
last_chunk = len(cdata) // MAX_APDU_LEN last_chunk = len(cdata) // MAX_APDU_LEN
# The generator allows to send apdu frames because we can't send an apdu > 255 # The generator allows to send apdu frames because we can't send an apdu > 255
for i, (chunk) in enumerate(chunked(MAX_APDU_LEN, cdata)): for i, (chunk) in enumerate(chunked(MAX_APDU_LEN, cdata)):
if i == 0 and i == last_chunk: if i == 0 and i == last_chunk:
@@ -290,4 +290,4 @@ class EthereumCommandBuilder:
ins=InsType.INS_SIGN_PERSONAL_TX, ins=InsType.INS_SIGN_PERSONAL_TX,
p1=0x80, p1=0x80,
p2=0x00, p2=0x00,
cdata=chunk) cdata=chunk)

View File

@@ -10,7 +10,7 @@ class ERC20Information:
self.nb_decimals: int = nb_decimals self.nb_decimals: int = nb_decimals
self.chainID: int = chainID self.chainID: int = chainID
self.sign: bytes = bytes.fromhex(sign) self.sign: bytes = bytes.fromhex(sign)
def serialize(self) -> bytes: def serialize(self) -> bytes:
return b"".join([ return b"".join([
write_varint(len(self.erc20_ticker)), write_varint(len(self.erc20_ticker)),
@@ -67,4 +67,4 @@ class Plugin:
write_varint(len(self.sign)), write_varint(len(self.sign)),
self.sign, self.sign,
]) ])

View File

@@ -88,9 +88,9 @@ class EIP712:
def __init__(self, domain_hash: str, msg_hash: str) -> None: def __init__(self, domain_hash: str, msg_hash: str) -> None:
self.domain_hash = bytes.fromhex(domain_hash) self.domain_hash = bytes.fromhex(domain_hash)
self.msg_hash = bytes.fromhex(msg_hash) self.msg_hash = bytes.fromhex(msg_hash)
def serialize(self) -> bytes: def serialize(self) -> bytes:
return b"".join([ return b"".join([
self.domain_hash, self.domain_hash,
self.msg_hash self.msg_hash
]) ])

View File

@@ -54,7 +54,7 @@ def bip32_path_from_string(path: str) -> List[bytes]:
def packed_bip32_path_from_string(path: str) -> bytes: def packed_bip32_path_from_string(path: str) -> bytes:
bip32_paths = bip32_path_from_string(path) bip32_paths = bip32_path_from_string(path)
return b"".join([ return b"".join([
len(bip32_paths).to_bytes(1, byteorder="big"), len(bip32_paths).to_bytes(1, byteorder="big"),
*bip32_paths *bip32_paths
@@ -98,7 +98,7 @@ def read(buf: BytesIO, size: int) -> bytes:
b: bytes = buf.read(size) b: bytes = buf.read(size)
if len(b) < size: if len(b) < size:
raise ValueError(f"Cant read {size} bytes in buffer!") raise ValueError(f"Can't read {size} bytes in buffer!")
return b return b

View File

@@ -16,7 +16,7 @@ def test_personal_sign_metamask(cmd):
with cmd.personal_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex: with cmd.personal_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5) sleep(0.5)
if cmd.model == "nanos": if cmd.model == "nanos":
# Sign message # Sign message
compare_screenshot(cmd, f"screenshots/eip191/{PATH_IMG[cmd.model]}/personal_sign_metamask/00000.png") compare_screenshot(cmd, f"screenshots/eip191/{PATH_IMG[cmd.model]}/personal_sign_metamask/00000.png")
@@ -49,7 +49,7 @@ def test_personal_sign_metamask(cmd):
assert v == 0x1c # 28 assert v == 0x1c # 28
assert r.hex() == "916099cf0d9c21911c85f0770a47a9696a8189e78c259cf099749748c507baae" assert r.hex() == "916099cf0d9c21911c85f0770a47a9696a8189e78c259cf099749748c507baae"
assert s.hex() == "0d72234bc0ac2e94c5f7a5f4f9cd8610a52be4ea55515a85b9703f1bb158415c" assert s.hex() == "0d72234bc0ac2e94c5f7a5f4f9cd8610a52be4ea55515a85b9703f1bb158415c"
def test_personal_sign_reject(cmd): def test_personal_sign_reject(cmd):
result: list = [] result: list = []
@@ -109,7 +109,7 @@ def test_personal_sign_non_ascii(cmd):
with cmd.personal_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex: with cmd.personal_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5) sleep(0.5)
if cmd.model == "nanos": if cmd.model == "nanos":
# Sign message # Sign message
compare_screenshot(cmd, f"screenshots/eip191/{PATH_IMG[cmd.model]}/personal_sign_non_ascii/00000.png") compare_screenshot(cmd, f"screenshots/eip191/{PATH_IMG[cmd.model]}/personal_sign_non_ascii/00000.png")
@@ -159,7 +159,7 @@ def test_personal_sign_opensea(cmd):
with cmd.personal_sign_tx(bip32_path, transaction, result) as ex: with cmd.personal_sign_tx(bip32_path, transaction, result) as ex:
sleep(0.5) sleep(0.5)
if cmd.model == "nanos": if cmd.model == "nanos":
# Sign message # Sign message
compare_screenshot(cmd, f"screenshots/eip191/{PATH_IMG[cmd.model]}/personal_sign_opensea/00000.png") compare_screenshot(cmd, f"screenshots/eip191/{PATH_IMG[cmd.model]}/personal_sign_opensea/00000.png")

View File

@@ -9,7 +9,7 @@ def test_sign_eip_1559(cmd):
with cmd.send_apdu_context(apdu_sign_eip_1559, result) as ex: with cmd.send_apdu_context(apdu_sign_eip_1559, result) as ex:
sleep(0.5) sleep(0.5)
if cmd.model == "nanos": if cmd.model == "nanos":
# Review transaction # Review transaction
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00000.png") compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00000.png")
@@ -47,7 +47,7 @@ def test_sign_eip_1559(cmd):
# Address # Address
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00002.png") compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00002.png")
cmd.client.press_and_release('right') cmd.client.press_and_release('right')
# Max Fees # Max Fees
compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00003.png") compare_screenshot(cmd, f"screenshots/eip1559/{PATH_IMG[cmd.model]}/sign_eip_1559/00003.png")
cmd.client.press_and_release('right') cmd.client.press_and_release('right')

View File

@@ -176,4 +176,4 @@ def test_sign_eip_712_bad_msg(cmd):
with cmd.sign_eip712(bip32_path=bip32_path, transaction=transaction, result=result) as ex: with cmd.sign_eip712(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
pass pass
assert error.args[0] == '0x6a80' assert error.args[0] == '0x6a80'

View File

@@ -38,7 +38,7 @@ def test_transfer_erc1155(cmd):
if cmd.model == "nanox" or cmd.model == "nanosp": if cmd.model == "nanox" or cmd.model == "nanosp":
cmd.set_plugin(plugin=PLUGIN) cmd.set_plugin(plugin=PLUGIN)
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION) cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
cmd.send_apdu(SIGN_FIRST) cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex: with cmd.send_apdu_context(SIGN_MORE, result) as ex:
@@ -46,8 +46,8 @@ def test_transfer_erc1155(cmd):
# Review transaction # Review transaction
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00000.png") compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00000.png")
cmd.client.press_and_release('right') cmd.client.press_and_release('right')
# NFT Transfert # NFT Transfer
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00001.png") compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00001.png")
cmd.client.press_and_release('right') cmd.client.press_and_release('right')
@@ -98,7 +98,7 @@ def test_transfer_erc1155_without_nft_provide_info(cmd):
cmd.set_plugin(plugin=PLUGIN) cmd.set_plugin(plugin=PLUGIN)
cmd.send_apdu(SIGN_FIRST) cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex: with cmd.send_apdu_context(SIGN_MORE, result) as ex:
@@ -114,7 +114,7 @@ def test_transfer_erc1155_without_set_plugin(cmd):
with pytest.raises(ethereum_client.exception.errors.DenyError) as error: with pytest.raises(ethereum_client.exception.errors.DenyError) as error:
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION) cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
cmd.send_apdu(SIGN_FIRST) cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex: with cmd.send_apdu_context(SIGN_MORE, result) as ex:
@@ -161,7 +161,7 @@ def test_transfer_batch_erc1155(cmd):
if cmd.model == "nanox" or cmd.model == "nanosp": if cmd.model == "nanox" or cmd.model == "nanosp":
cmd.set_plugin(plugin=PLUGIN_BATCH) cmd.set_plugin(plugin=PLUGIN_BATCH)
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION_BATCH) cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION_BATCH)
cmd.send_apdu(SIGN_FIRST_BATCH) cmd.send_apdu(SIGN_FIRST_BATCH)
cmd.send_apdu(SIGN_MORE_1_BATCH) cmd.send_apdu(SIGN_MORE_1_BATCH)
cmd.send_apdu(SIGN_MORE_2_BATCH) cmd.send_apdu(SIGN_MORE_2_BATCH)

View File

@@ -28,4 +28,4 @@ def test_provide_erc20_token_error(cmd):
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error: with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
cmd.provide_erc20_token_information(info=erc20_info) cmd.provide_erc20_token_information(info=erc20_info)
assert error.args[0] == '0x6a80' assert error.args[0] == '0x6a80'

View File

@@ -38,7 +38,7 @@ def test_transfer_erc721(cmd):
if cmd.model == "nanox" or cmd.model == "nanosp": if cmd.model == "nanox" or cmd.model == "nanosp":
cmd.set_plugin(plugin=PLUGIN) cmd.set_plugin(plugin=PLUGIN)
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION) cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
cmd.send_apdu(SIGN_FIRST) cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex: with cmd.send_apdu_context(SIGN_MORE, result) as ex:
@@ -46,7 +46,7 @@ def test_transfer_erc721(cmd):
# Review transaction # Review transaction
compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00000.png") compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00000.png")
cmd.client.press_and_release('right') cmd.client.press_and_release('right')
# NFT Transfer # NFT Transfer
compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00001.png") compare_screenshot(cmd, f"screenshots/erc721/{PATH_IMG[cmd.model]}/transfer_erc721/00001.png")
cmd.client.press_and_release('right') cmd.client.press_and_release('right')
@@ -97,7 +97,7 @@ def test_transfer_erc721_without_nft_provide_info(cmd):
pass pass
assert error.args[0] == '0x6a80' assert error.args[0] == '0x6a80'
def test_transfer_erc721_without_set_plugin(cmd): def test_transfer_erc721_without_set_plugin(cmd):
@@ -106,10 +106,10 @@ def test_transfer_erc721_without_set_plugin(cmd):
if cmd.model == "nanox" or cmd.model == "nanosp": if cmd.model == "nanox" or cmd.model == "nanosp":
with pytest.raises(ethereum_client.exception.errors.DenyError) as error: with pytest.raises(ethereum_client.exception.errors.DenyError) as error:
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION) cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
cmd.send_apdu(SIGN_FIRST) cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex: with cmd.send_apdu_context(SIGN_MORE, result) as ex:
pass pass
assert error.args[0] == '0x6985' assert error.args[0] == '0x6985'

View File

@@ -92,11 +92,11 @@ def test_reject_get_public_key(cmd):
# Approve # Approve
compare_screenshot(cmd, f"screenshots/pubkey/{PATH_IMG[cmd.model]}/reject_get_public_key/00004.png") compare_screenshot(cmd, f"screenshots/pubkey/{PATH_IMG[cmd.model]}/reject_get_public_key/00004.png")
cmd.client.press_and_release('right') cmd.client.press_and_release('right')
# Reject # Reject
compare_screenshot(cmd, f"screenshots/pubkey/{PATH_IMG[cmd.model]}/reject_get_public_key/00005.png") compare_screenshot(cmd, f"screenshots/pubkey/{PATH_IMG[cmd.model]}/reject_get_public_key/00005.png")
cmd.client.press_and_release('both') cmd.client.press_and_release('both')
if cmd.model == "nanox" or cmd.model == "nanosp": if cmd.model == "nanox" or cmd.model == "nanosp":
# Verify address # Verify address
compare_screenshot(cmd, f"screenshots/pubkey/{PATH_IMG[cmd.model]}/reject_get_public_key/00000.png") compare_screenshot(cmd, f"screenshots/pubkey/{PATH_IMG[cmd.model]}/reject_get_public_key/00000.png")

View File

@@ -27,7 +27,7 @@ def test_sign_simple(cmd):
with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex: with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5) sleep(0.5)
if cmd.model == "nanos": if cmd.model == "nanos":
# Review transaction # Review transaction
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/simple/00000.png") compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/simple/00000.png")
@@ -87,7 +87,7 @@ def test_sign_simple(cmd):
def test_sign_reject(cmd): def test_sign_reject(cmd):
result: list = [] result: list = []
# Ether coin type # Ether coin type
bip32_path="44'/60'/1'/0/0" bip32_path="44'/60'/1'/0/0"
@@ -134,7 +134,7 @@ def test_sign_reject(cmd):
# Accept and send # Accept and send
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/reject/00008.png") compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/reject/00008.png")
cmd.client.press_and_release('right') cmd.client.press_and_release('right')
# Reject # Reject
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/reject/00009.png") compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/reject/00009.png")
cmd.client.press_and_release('both') cmd.client.press_and_release('both')
@@ -169,7 +169,7 @@ def test_sign_reject(cmd):
def test_sign_limit_nonce(cmd): def test_sign_limit_nonce(cmd):
result: list = [] result: list = []
# Ether coin type # Ether coin type
bip32_path="44'/60'/1'/0/0" bip32_path="44'/60'/1'/0/0"
@@ -246,7 +246,7 @@ def test_sign_limit_nonce(cmd):
def test_sign_error_transaction_type(cmd): def test_sign_error_transaction_type(cmd):
result: list = [] result: list = []
# Ether coin type # Ether coin type
bip32_path="44'/60'/1'/0/0" bip32_path="44'/60'/1'/0/0"
@@ -311,7 +311,7 @@ def test_sign_nonce_display(cmd):
with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex: with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5) sleep(0.5)
if cmd.model == "nanos": if cmd.model == "nanos":
# Review transaction # Review transaction
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/nonce_display/00000.png") compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/nonce_display/00000.png")
@@ -413,7 +413,7 @@ def test_sign_blind_simple(cmd):
with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex: with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5) sleep(0.5)
if cmd.model == "nanos": if cmd.model == "nanos":
# Review transaction # Review transaction
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/blind_simple/00000.png") compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/blind_simple/00000.png")
@@ -546,7 +546,7 @@ def test_sign_blind_and_nonce_display(cmd):
with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex: with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5) sleep(0.5)
if cmd.model == "nanos": if cmd.model == "nanos":
# Review transaction # Review transaction
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/blind_and_nonce_display/00000.png") compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/blind_and_nonce_display/00000.png")

View File

@@ -19,4 +19,4 @@ build/
# Coverage file # Coverage file
coverage.info coverage.info
coverage coverage

View File

@@ -62,4 +62,4 @@ add_library(demo SHARED ./demo_tu.c)
target_link_libraries(test_demo PUBLIC cmocka gcov demo) target_link_libraries(test_demo PUBLIC cmocka gcov demo)
add_test(test_demo test_demo) add_test(test_demo test_demo)

View File

@@ -39,4 +39,4 @@ clean:
@if [ -d coverage ]; then $(ECHO) -e "${RED}[ RM ]${RESET}" coverage && $(RM) -r coverage ; fi; @if [ -d coverage ]; then $(ECHO) -e "${RED}[ RM ]${RESET}" coverage && $(RM) -r coverage ; fi;
@if [ -f coverage.info ]; then $(ECHO) -e "${RED}[ RM ]${RESET}" coverage.info && $(RM) -r coverage.info ; fi; @if [ -f coverage.info ]; then $(ECHO) -e "${RED}[ RM ]${RESET}" coverage.info && $(RM) -r coverage.info ; fi;
.PHONY: all coverage clean .PHONY: all coverage clean

View File

@@ -1,7 +1,7 @@
# Unit tests # Unit tests
It is important to unit test your functions. It is important to unit test your functions.
This also allows you to document how your functions work. This also allows you to document how your functions work.
We use the library [**cmocka**](https://cmocka.org/#features) We use the library [**cmocka**](https://cmocka.org/#features)
## Requirement ## Requirement
@@ -9,11 +9,12 @@ We use the library [**cmocka**](https://cmocka.org/#features)
- [CMake >= 3.10](https://cmake.org/download/) - [CMake >= 3.10](https://cmake.org/download/)
- [lcov >= 1.14](http://ltp.sourceforge.net/coverage/lcov.php) - [lcov >= 1.14](http://ltp.sourceforge.net/coverage/lcov.php)
Don't worry, you don't necessarily need to install the `cmocka library` because the **cmakelist automatically fetches** the library Don't worry, you don't necessarily need to install the `cmocka library`
because the **cmakelist automatically fetches** the library
## Add new test ## Add new test
Create new file into `tests` folder and follow [this initiation](https://cmocka.org/talks/cmocka_unit_testing_and_mocking.pdf) Create new file into `tests` folder and follow [this initiation](https://cmocka.org/talks/cmocka_unit_testing_and_mocking.pdf)
Now go to the `CMakeLists.txt` file and add your test with the specific file you want to test. Now go to the `CMakeLists.txt` file and add your test with the specific file you want to test.
@@ -27,12 +28,15 @@ The `default rules` of makefile will compile the tests and run them.
make make
``` ```
The `coverage rule` will launch the default rules and generate the coverage and you will be **automatically redirected** to the generated .html The `coverage rule` will launch the default rules and generate the coverage
and you will be **automatically redirected** to the generated .html
```sh ```sh
make coverage make coverage
``` ```
The `clean rule` will delete the folders and files generated The `clean rule` will delete the folders and files generated
```sh ```sh
make clean make clean
``` ```

View File

@@ -9,4 +9,4 @@ int local_strchr_demo(char *string, char ch) {
} }
} }
return -1; return -1;
} }

View File

@@ -15,4 +15,4 @@ int main(void) {
cmocka_unit_test(null_test_success), cmocka_unit_test(null_test_success),
}; };
return cmocka_run_group_tests(tests, NULL, NULL); return cmocka_run_group_tests(tests, NULL, NULL);
} }

View File

@@ -1,4 +1,4 @@
/node_modules /node_modules
/snapshots-tmp /snapshots-tmp
/elfs /elfs
/lib /lib

View File

@@ -5,4 +5,4 @@ all:
yarn install yarn install
yarn test yarn test
.PHONY: all .PHONY: all

View File

@@ -14,4 +14,4 @@ module.exports = async () => {
await Zemu.checkAndPullImage(); await Zemu.checkAndPullImage();
await Zemu.stopAllEmuContainers(); await Zemu.stopAllEmuContainers();
fsExtra.emptyDirSync("snapshots/tmp") fsExtra.emptyDirSync("snapshots/tmp")
}; };

View File

@@ -34,6 +34,6 @@ module.exports = {
// Path of the file where tests can be """decorated""" // Path of the file where tests can be """decorated"""
setupFilesAfterEnv: ['<rootDir>/setupTests.js'], setupFilesAfterEnv: ['<rootDir>/setupTests.js'],
// Stop immediatly when a test fail // Stop immediately when a test fail
bail: true, bail: true,
}; };

View File

@@ -19,4 +19,4 @@ export const sim_options_x = {
export const Resolve = require("path").resolve; export const Resolve = require("path").resolve;
export const NANOS_ELF_PATH = Resolve("elfs/ethereum_nanos.elf"); export const NANOS_ELF_PATH = Resolve("elfs/ethereum_nanos.elf");
export const NANOX_ELF_PATH = Resolve("elfs/ethereum_nanox.elf"); export const NANOX_ELF_PATH = Resolve("elfs/ethereum_nanox.elf");

View File

@@ -16,4 +16,4 @@ expect.extend({
} }
} }
}, },
}); });