Skip to content

Commit

Permalink
Merge pull request #247 from trilitech/palmer@functori@flex-support
Browse files Browse the repository at this point in the history
Flex support
  • Loading branch information
ajinkyaraj-23 authored Jul 16, 2024
2 parents e624d29 + 0aa45bb commit 361f1f4
Show file tree
Hide file tree
Showing 265 changed files with 232 additions and 124 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Build application
strategy:
matrix:
device: [nanos, nanosp, nanox, stax]
device: [nanos, nanosp, nanox, stax, flex]
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
strategy:
fail-fast: false
matrix:
device: [nanos, nanosp, nanox, stax]
device: [nanos, nanosp, nanox, stax, flex]
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

Expand All @@ -82,9 +82,9 @@ jobs:

- name: Run test
run: |
if [ "${{ matrix.device }}" = "stax" ]; then
if [ "${{ matrix.device }}" = "stax" ] || [ "${{ matrix.device }}" = "flex" ]; then
./tests/integration/run_test_local.sh -F -m ${{ matrix.device }} \
./tests/integration/${{ matrix.device }}
./tests/integration/touch
else
apk add gmp-dev curl jq libsodium-dev git xxd procps
python3 -m venv tezos_test_env --system-site-package
Expand All @@ -99,14 +99,14 @@ jobs:
- name: Upload Stax results
uses: actions/upload-artifact@v4
if: always() && matrix.device == 'stax'
if: always() && (matrix.device == 'stax' || matrix.device == 'flex')
with:
name: integration_tests_${{ matrix.device }}.json
path: ./integration_tests.json

- name: Upload Nano results
uses: actions/upload-artifact@v4
if: always() && matrix.device != 'stax'
if: always() && (matrix.device != 'stax' && matrix.device != 'flex')
with:
name: integration_tests_log_${{ matrix.device }}
path: ./integration_tests_log
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Analyse
strategy:
matrix:
sdk: [ "$NANOS_SDK", "$NANOX_SDK", "$NANOSP_SDK", "$STAX_SDK" ]
sdk: [ "$NANOS_SDK", "$NANOX_SDK", "$NANOSP_SDK", "$STAX_SDK", "$FLEX_SDK" ]
#'cpp' covers C and C++
language: [ 'cpp' ]
runs-on: ubuntu-latest
Expand Down
30 changes: 23 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
# Makefile
#

all: app_nanos.tgz app_nanosp.tgz app_nanox.tgz
debug: app_nanos_dbg.tgz app_nanosp_dbg.tgz app_nanox_dbg.tgz
all: app_nanos.tgz \
app_nanosp.tgz \
app_nanox.tgz \
app_stax.tgz \
app_flex.tgz
debug: app_nanos_dbg.tgz \
app_nanosp_dbg.tgz \
app_nanox_dbg.tgz \
app_stax_dbg.tgz \
app_flex_dbg.tgz

.PHONY: clean all debug format integration_tests unit_tests scan-build% \
integration_tests_basic integration_tests_basic_% docker_%
Expand Down Expand Up @@ -49,7 +57,7 @@ scan-build-%:
"BOLOS_SDK=\$$$$SDK make -C app scan-build"

scan-build: scan-build-nanos scan-build-nanosp \
scan-build-nanox scan-build-stax
scan-build-nanox scan-build-stax scan-build-flex

app_%_dbg.tgz: app/src/*.[ch] \
app/src/parser/*.[ch] \
Expand Down Expand Up @@ -92,8 +100,14 @@ RUN_TEST_DOCKER = ./tests/integration/run_test_docker.sh
integration_tests_basic_stax: app_stax.tgz \
app_stax_dbg.tgz \
tests/integration/* \
tests/integration/stax/*
$(RUN_TEST_DOCKER) stax tests/integration/stax
tests/integration/touch/*
$(RUN_TEST_DOCKER) stax tests/integration/touch

integration_tests_basic_flex: app_flex.tgz \
app_flex_dbg.tgz \
tests/integration/* \
tests/integration/touch/*
$(RUN_TEST_DOCKER) flex tests/integration/touch

integration_tests_basic_%: app_%.tgz \
app_%_dbg.tgz \
Expand All @@ -116,7 +130,8 @@ integration_tests_basic_%: app_%.tgz \
integration_tests_basic: integration_tests_basic_nanos \
integration_tests_basic_nanosp \
integration_tests_basic_nanox \
integration_tests_basic_stax
integration_tests_basic_stax \
integration_tests_basic_flex

integration_tests_%: integration_tests_basic_% \
test/samples/operations/nano/samples.hex\
Expand All @@ -130,7 +145,8 @@ integration_tests: tests/integration/*.sh \
integration_tests_nanos \
integration_tests_nanosp \
integration_tests_nanox \
integration_tests_basic_stax
integration_tests_basic_stax \
integration_tests_basic_flex

test/samples/micheline/%/samples.hex: tests/generate/*.ml* \
tests/generate/dune \
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Both of these commands take the following arguments:
-x
: executes the tests with shell tracing (-x)

Basic tests rely on gold-images, rather than OCR. They are stored under [nano/snapshots](./tests/integration/nano/snapshots) and [stax/snapshots](./tests/integration/stax/snapshots).
Basic tests rely on gold-images, rather than OCR. They are stored under [nano/snapshots](./tests/integration/nano/snapshots) and [touch/snapshots](./tests/integration/touch/snapshots).

To generate/reset the snapshots, you can do so for individual tests.

Expand Down Expand Up @@ -171,7 +171,7 @@ You will be requested to press enter to take snapshots in term.
**NB** make sure that the screen has updated to the screen you want to snapshot each time. It's also a good idea to
re-run the test normally afterwards, to ensure the snapshots have been set correctly.

### STAX
### STAX/FLEX

#### Preparation

Expand All @@ -196,15 +196,15 @@ $ docker exec -it ledger-app-tezos-integration-tests bash;
You can run an individual test from the test container. You should see the app progress on the display.

```sh
./tests/integration/stax/<test_name>.py
./tests/integration/touch/<test_name>.py
```

#### Setting goldimages

You can reset/set goldimages using the following:

```sh
GOLDEN=1 ./tests/integration/stax/<test_name>.py
GOLDEN=1 ./tests/integration/touch/<test_name>.py
```

If you are resetting goldimages for multiple tests, you can also use `export NOQUIT=1` to keep the app
Expand Down Expand Up @@ -264,4 +264,4 @@ with a new version
1. app/Makefile
2. tests/integration/app_vars.sh
3. tests/integration/nano/utils/app.py
4. the snapshots (nano and stax)
4. the snapshots (nano and touch)
1 change: 1 addition & 0 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ ICON_NANOS = icons/nano-s-tezos.gif
ICON_NANOX = icons/nano-x-tezos.gif
ICON_NANOSP = icons/nano-x-tezos.gif
ICON_STAX = icons/stax_tezos.gif
ICON_FLEX = icons/flex_tezos.gif

# Application allowed derivation curves.
# Possibles curves are: secp256k1, secp256r1, ed25519 and bls12381g1
Expand Down
Binary file added app/icons/flex_tezos.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ledger_app.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[app]
build_directory = "./app"
sdk = "C"
devices = ["nanos", "nanox", "nanos+", "stax"]
devices = ["nanos", "nanox", "nanos+", "stax", "flex"]
4 changes: 2 additions & 2 deletions scripts/test_swap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -x
set -e

usage() {
echo "Usage: ./scripts/test_swap.sh {build_app_tezos|build_app_ethereum|build_app_exchange|run_tests|run_tests_all|update} {nanos|nanosp|nanox|stax}"
echo "Usage: ./scripts/test_swap.sh {build_app_tezos|build_app_ethereum|build_app_exchange|run_tests|run_tests_all|update} {nanos|nanosp|nanox|stax|flex}"
}

_assert_tezos_repo() {
Expand Down Expand Up @@ -72,7 +72,7 @@ _assert_app_exchange_repo() {
set -x
}

devices=("nanos" "nanosp" "nanox" "stax")
devices=("nanos" "nanosp" "nanox" "stax" "flex")

_assert_device() {
set +x
Expand Down
9 changes: 5 additions & 4 deletions tests/integration/test_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,12 @@ run_a_test() {
. $CMD
;;
*.py)
if [ "$TARGET" == "stax" ]; then
if [ "$TARGET" == "stax" ] || [ "$TARGET" == "flex" ]; then
start_speculos "$seed"
PORT=$PORT\
COMMIT_BYTES=$COMMIT_BYTES\
VERSION_BYTES=$VERSION_BYTES\
TARGET=$TARGET\
python3 $CMD
elif [[ "$CMD" != *"conftest.py" ]]; then
if [ "$DBG" = "DEBUG" ]; then
Expand Down Expand Up @@ -555,7 +556,7 @@ usage() {
echo " -F means that only failures are stored" >&2
echo " -d tgz specifies that tgz contains the debug app" >&2
echo " -l lim limits the number of tests run to lim" >&2
echo " -m arch is one of nanos, nanosp, nanox, or stax" >&2
echo " -m arch is one of nanos, nanosp, nanox, stax or flex" >&2
echo " -t tgz specifies that tgz contains the app" >&2
exit 1
}
Expand Down Expand Up @@ -585,8 +586,8 @@ main() {

[ $# -lt 1 ] && usage "At least one test must be provided"

if ! echo $TARGET | grep -qE '^(stax)|(nano(s|sp|x))$'; then
usage "Target \"$TARGET\" must be nanos, nanosp, nanox or stax."
if ! echo $TARGET | grep -qE '^(stax)|(flex)|(nano(s|sp|x))$'; then
usage "Target \"$TARGET\" must be nanos, nanosp, nanox, stax or flex."
fi

if [ -z "$TGZ" ]; then
Expand Down
Binary file added tests/integration/touch/snapshots/flex/home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/integration/touch/snapshots/flex/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from utils import *
from utils import tezos_app

if __name__ == "__main__":
app = stax_app(__file__)
app = tezos_app(__file__)

app.assert_home()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from utils import *
from utils import (
tezos_app,
send_initialize_msg,
send_payload
)

if __name__ == "__main__":
app = stax_app(__file__)
app = tezos_app(__file__)

app.assert_home()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from utils import *
from utils import (
tezos_app,
send_initialize_msg,
send_payload,
verify_err_reject_response
)

def toggle_blindsigning(app):
app.assert_home()
Expand All @@ -23,7 +28,7 @@ def toggle_blindsigning(app):
app.assert_home()

if __name__ == "__main__":
app = stax_app(__file__)
app = tezos_app(__file__)

app.assert_home()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from utils import *
from utils import (
tezos_app,
send_initialize_msg,
send_payload
)

if __name__ == "__main__":
app = stax_app(__file__)
app = tezos_app(__file__)

# Switch to blindsign mode
app.assert_home()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@
"""
Check if valid operations are not blindsigned, even when blindsigning is enabled.
"""
from utils import *

from utils import (
tezos_app,
send_initialize_msg,
send_payload,
index_screen
)

if __name__ == "__main__":
app = stax_app(__file__)
app = tezos_app(__file__)

# Switch to blindsign mode
app.assert_home()
Expand All @@ -36,17 +42,18 @@
send_initialize_msg(app,"800f000011048000002c800006c18000000080000000")
send_payload(app,"800f81005e0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316")

app.review.next()
app.assert_screen("tst_review_001")
screen = "tst_review"
nb_screen = 2

app.review.next()
app.assert_screen("tst_review_002")
for index in range(1, nb_screen+1):
app.review.next()
app.assert_screen(index_screen(screen, index))

app.review.next()
app.expert_mode_splash()

app.review.next()
app.assert_screen("tst_review_003")
app.assert_screen(index_screen(screen, index+1))

app.review.next()
app.assert_screen("operation_sign")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from utils import *
from utils import (
tezos_app,
send_initialize_msg,
send_payload,
verify_reject_response,
index_screen
)

# full input: 0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316
# full output: CAR
Expand All @@ -25,14 +31,17 @@ def sign_transfer_initialize(app):
app.assert_home()
send_initialize_msg(app,"800f000011048000002c800006c18000000080000000")
send_payload(app,"800f81005e0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316")
app.review.next()
app.assert_screen("tst_review_001")
app.review.next()
app.assert_screen("tst_review_002")

screen = "tst_review"
nb_screen = 2

for index in range(1, nb_screen+1):
app.review.next()
app.assert_screen(index_screen(screen, index))


if __name__ == "__main__":
app = stax_app(__file__)
app = tezos_app(__file__)
# Reject from enable expert mode
sign_transfer_initialize(app)
app.review.next()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from utils import *
from utils import tezos_app

if __name__ == "__main__":
app = stax_app(__file__)
app = tezos_app(__file__)

app.assert_home()

Expand Down
Loading

0 comments on commit 361f1f4

Please sign in to comment.