Skip to content

Commit

Permalink
Merge pull request #28 from vacuumlabs/merging-with-onflow-latest-dev…
Browse files Browse the repository at this point in the history
…elopment-branch (B2CA-1709)

Large flow app update
  • Loading branch information
tdejoigny-ledger authored Jun 26, 2024
2 parents 5ac1290 + 0c12067 commit 24ba23a
Show file tree
Hide file tree
Showing 9,978 changed files with 63,335 additions and 3,807 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
22 changes: 22 additions & 0 deletions .github/workflows/js_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Javascript tests

on:
workflow_dispatch:
push:
branches:
- master
- main
- develop
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- run: cd js && yarn install && yarn build && yarn test

2 changes: 1 addition & 1 deletion .github/workflows/misspellings_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
with:
builtin: clear,rare
check_filenames: true
skip: ./deps/jsmn/test/tests.c
skip: ./deps/jsmn/test/tests.c, ./transaction_metadata/manifest.mainnet.json, ./transaction_metadata/manifest.testnet.json,
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ jobs:
files: ./unit-tests/coverage.info
flags: unittests
name: codecov-app-flow
fail_ci_if_error: true
fail_ci_if_error: false
verbose: true
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ include $(BOLOS_SDK)/Makefile.defines
APPNAME = "Flow"

APPVERSION_M=0
APPVERSION_N=12
APPVERSION_N=13
APPVERSION_P=0
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

Expand Down Expand Up @@ -122,7 +122,15 @@ DEFINES += HAVE_BOLOS_APP_STACK_CANARY
DEFINES += LEDGER_SPECIFIC

ifeq ($(TARGET_NAME),TARGET_NANOS)
APP_STACK_SIZE:=2480
APP_STACK_MIN_SIZE:=2480
endif

########################################
# Unit tests and misc #
########################################

ifeq ($(DEBUG),1)
DEFINES += ZEMU_LOGGING
endif

#########################
Expand Down
93 changes: 88 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,85 @@ Please:
_Once the app is approved by Ledger, it will be available in their app store (Ledger Live).
The builds generated by this repository are for development purposes. THESE ARE UNVETTED DEVELOPMENT RELEASES._

## Quick start guide
## Quick start guide

#### Docker

Install and run [Docker](https://www.docker.com/products/docker-desktop/).

#### Compilation

We develop on Ubuntu. On different system slight adjustment of the commands may be necessary (see documentation below).

He recommended way to compile the app is:
1. Pull the latest docker container.
```shell
sudo docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest
```
2. Start terminal within the container.
```shell
sudo docker run --rm -ti --user "$(id -u):$(id -g)" --privileged -v "/dev/bus/usb:/dev/bus/usb" -v "$(realpath .):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest
```
3. Compile the app
```shell
make clean
make
make BOLOS_SDK=$NANOX_SDK
make BOLOS_SDK=$NANOSP_SDK
make BOLOS_SDK=$STAX_SDK
```

Stax app can be compiled in DEBUG mode for debugging purposes
```shell
make BOLOS_SDK=$STAX_SDK DEBUG=1
```
Note, that it is possible (although unlikely) for ledger to make a braking change in ledger-app-dev-tools:latest.

#### Tests

##### Speculos integration tests

These are the main test. These end to end test cover all app features.
To run them you should compile the app in ledger-app-dev-tools:latest container. And then (in container) run

```shell
pytest tests/ --tb=short -v --device nanos
pytest tests/ --tb=short -v --device nanox
pytest tests/ --tb=short -v --device nanosp
pytest tests/ --tb=short -v --device stax
```

Note that in case ledger-app-dev-tools:latest is updated there is a chance that slight changes in gui happen. In that case it is necessary to re-generate the snapshots, e.g.
```shell
pytest tests/ --tb=short -v --device nanos –golden_run
```
and review the changes in test/snapshots directory

##### Unit tests

As we want to test as close as possible to the production environment, the focus is on end to end integration test. However, certain complex parts of code, where test coverage with integration tests may be insufficient, are also tested using unit tests.

```shell
cd unit-tests/
cmake -Bbuild -H. && make -C build
CTEST_OUTPUT_ON_FAILURE=1 make -C build test
```

#### Scan build

We use scan build in ledger-app-dev-tools container (see Compilation section).

```shell
make clean
make scan-build
make scan-build BOLOS_SDK=$NANOX_SDK
make scan-build BOLOS_SDK=$NANOSP_SDK
make scan-build BOLOS_SDK=$STAX_SDK
```

## Further information

_Warning_: This is standard documentation for ledger app provided by ledger developers. As we do not use all the options, we do no guarantee that everything is up to date.

### General configuration

Expand Down Expand Up @@ -55,7 +133,7 @@ It will allow you, whether you are developing on macOS, Windows or Linux to quic

### With a terminal

#### Using the `ledger-app-dev-tools` docker container
#### Using the `ledger-app-dev-tools` docker container (recommended)

The [ledger-app-dev-tools](https://github.com/LedgerHQ/ledger-app-builder/pkgs/container/ledger-app-builder%2Fledger-app-dev-tools) docker image contains all the required tools and libraries to **build**, **test** and **load** an application.

Expand All @@ -67,7 +145,7 @@ sudo docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

You can then enter this development environment by executing the following command from the directory of the application `git` repository:

##### Linux (Ubuntu)
##### Linux (Ubuntu) (recommended)

```shell
sudo docker run --rm -ti --user "$(id -u):$(id -g)" --privileged -v "/dev/bus/usb:/dev/bus/usb" -v "$(realpath .):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest
Expand Down Expand Up @@ -116,7 +194,7 @@ Setup a compilation environment by following the [shell with docker approach](#w
From inside the container, use the following command to build the app :

```shell
make DEBUG=1 # compile optionally with PRINTF
make
```

You can choose which device to compile and load for by setting the `BOLOS_SDK` environment variable to the following values :
Expand All @@ -126,6 +204,11 @@ You can choose which device to compile and load for by setting the `BOLOS_SDK` e
- `BOLOS_SDK=$NANOSP_SDK`
- `BOLOS_SDK=$STAX_SDK`

For Stax device you can compile
```shell
make BOLOS_SDK=$STAX_SDK DEBUG=1 # compile optionally with PRINTF
```

### Loading on a physical device

This step will vary slightly depending on your platform.
Expand Down Expand Up @@ -175,7 +258,7 @@ python3 -m ledgerblue.runScript --scp --fileName bin/app.apdu --elfFile bin/app.

The flow app comes with functional tests implemented with Ledger's [Ragger](https://github.com/LedgerHQ/ragger) test framework.

### Linux (Ubuntu)
### Linux (Ubuntu) (recommended)

On Linux, you can use [Ledger's VS Code extension](#with-vscode) to run the tests. If you prefer not to, open a terminal and follow the steps below.

Expand Down
1 change: 0 additions & 1 deletion deps/ledger-zxlib
Submodule ledger-zxlib deleted from ca7780
16 changes: 16 additions & 0 deletions deps/ledger-zxlib/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# top-most EditorConfig file
root = true

[*]
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true

[*.{c,h,cpp,hpp}]
indent_style = space
indent_size = 4

[*.{yml,sh}]
indent_style = space
indent_size = 2
59 changes: 59 additions & 0 deletions deps/ledger-zxlib/.github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "Main workflow"
on: push

jobs:
configure:
runs-on: ubuntu-latest
outputs:
uid_gid: ${{ steps.get-user.outputs.uid_gid }}
steps:
- id: get-user
run: echo "uid_gid=$(id -u):$(id -g)" >> $GITHUB_OUTPUT

build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- run: cmake -DCMAKE_BUILD_TYPE=Debug . && make

check_version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
exists: ${{ steps.get-version.outputs.exists }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- id: get-version
name: Get zxlib version
run: echo "version=$(./scripts/get_version.sh)" >> $GITHUB_OUTPUT
- id: tag-exists
name: Check if version exists
run: |
if git rev-parse ${{ steps.get-version.outputs.version }} >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Fail if tag exists
if: ${{ steps.tag-exists.outputs.exists == 'true' }}
run: exit 1

tag:
runs-on: ubuntu-latest
needs:
- build
- check_version
if: ${{ needs.check_version.outputs.exists != 'true' && github.ref == 'refs/heads/main' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.check_version.outputs.version }}
4 changes: 4 additions & 0 deletions deps/ledger-zxlib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

\.idea/
\.vscode/
cmake-build-debug/
57 changes: 57 additions & 0 deletions deps/ledger-zxlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#*******************************************************************************
#* (c) 2018 Zondax GmbH
#*
#* Licensed under the Apache License, Version 2.0 (the "License");
#* you may not use this file except in compliance with the License.
#* You may obtain a copy of the License at
#*
#* http://www.apache.org/licenses/LICENSE-2.0
#*
#* Unless required by applicable law or agreed to in writing, software
#* distributed under the License is distributed on an "AS IS" BASIS,
#* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#* See the License for the specific language governing permissions and
#* limitations under the License.
#********************************************************************************
cmake_minimum_required(VERSION 3.0)
project(ledger-zxlib)

set(CMAKE_CXX_STANDARD 11)

add_subdirectory(cmake/gtest)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
)

###############

file(GLOB_RECURSE ZXLIB_SRC
${CMAKE_CURRENT_SOURCE_DIR}/src/*.c
)

file(GLOB_RECURSE TESTS_SRC
${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cpp
)

###############
set(BUILD_TESTS OFF CACHE BOOL "Enables tests")

add_library(zxlib STATIC ${ZXLIB_SRC})
target_include_directories(zxlib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)

enable_testing()

add_executable(zxlib_tests
${TESTS_SRC}
)

target_include_directories(zxlib_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${gtest_SOURCE_DIR}/include
${gmock_SOURCE_DIR}/include
)

target_link_libraries(zxlib_tests gtest_main zxlib)

add_test(ZXLIB_TESTS zxlib_tests)
Loading

0 comments on commit 24ba23a

Please sign in to comment.