Fix various Linter issues and mispelling
This commit is contained in:
7
.github/ISSUE_TEMPLATE/bug_report.md
vendored
7
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -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
|
||||||
|
|||||||
1
.github/ISSUE_TEMPLATE/network_request.md
vendored
1
.github/ISSUE_TEMPLATE/network_request.md
vendored
@@ -8,6 +8,7 @@ assignees: ''
|
|||||||
---
|
---
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
- [ ] Symbol:
|
- [ ] Symbol:
|
||||||
- [ ] ChainId:
|
- [ ] ChainId:
|
||||||
- [ ] Website:
|
- [ ] Website:
|
||||||
|
|||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -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
|
||||||
|
|||||||
64
README.md
64
README.md
@@ -31,13 +31,12 @@
|
|||||||
- [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
|
||||||
@@ -55,6 +54,7 @@ To compile it and load it on a device, please check out our [developer portal](h
|
|||||||
|
|
||||||
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`.
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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 :
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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.")
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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,16 +80,18 @@ 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
|
||||||
@@ -130,4 +132,3 @@ def test_some_error(cmd):
|
|||||||
pass
|
pass
|
||||||
assert error.args[0] == '0x6a80'
|
assert error.args[0] == '0x6a80'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -221,6 +221,3 @@ class EthereumCommand:
|
|||||||
result.append(v)
|
result.append(v)
|
||||||
result.append(r)
|
result.append(r)
|
||||||
result.append(s)
|
result.append(s)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ 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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ def test_transfer_erc1155(cmd):
|
|||||||
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')
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ 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
|
||||||
|
|
||||||
@@ -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
|
||||||
```
|
```
|
||||||
@@ -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,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user