Skip to content

Commit

Permalink
Merge pull request #93 from trilitech/emturner@tooling
Browse files Browse the repository at this point in the history
tooling: improvements to dev workflow
  • Loading branch information
emturner authored Oct 26, 2023
2 parents 58c9d27 + 0d32812 commit 99f7f49
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 32 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
all: app_nanos.tgz app_nanosp.tgz app_nanox.tgz
debug: app_nanos_dbg.tgz app_nanosp_dbg.tgz app_nanox_dbg.tgz

.PHONY: clean all debug integration_tests unit_tests scan-build% \
.PHONY: clean all debug format integration_tests unit_tests scan-build% \
integration_tests_basic integration_tests_basic_% docker_%

DOCKER = docker
Expand Down Expand Up @@ -130,6 +130,10 @@ load_%: app_%.tgz
#
# Dash vs under aliases:

format:
@find ./app/src -name '*.c' -exec clang-format -i "{}" \;
@find ./app/src -name '*.h' -exec clang-format -i "{}" \;

docker-images: docker_images
integration-tests: integration_tests
unit-tests: unit_tests
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,22 @@ To generate/reset the snapshots, you can do so for individual tests.
First, start a container for running individual tests:

```sh
docker run --rm -it --entrypoint /bin/bash -v $(pwd)/tests/integration:/tests --network host \
docker run --rm -it --entrypoint /bin/bash -v $(pwd):/app --network host \
ledger-app-tezos-integration-tests

cd /tests/stax
cd /app/tests/integration/stax
export PORT=5000

git config --global --add safe.directory /app
. ../app_vars.sh
```

Before running the test, start the app in a separate container (as each test will quit the app):

```sh
make app_stax_dbg.tgz
seed="zebra`for i in $(seq 1 23) ; do echo -n ' zebra' ; done`"
docker run --rm -it -v $(pwd)/app/bin:/speculos/apps -v $(pwd)/tests/integration:/tests --network host \
ledger-app-tezos-integration-tests --display=headless --vnc-port 41000 --seed "$seed" -m stax apps/app.elf

TARGET=stax ./scripts/run_app.sh
```

You can view/interact with the app using a vnc client on port `41000`.
Expand Down
23 changes: 23 additions & 0 deletions scripts/run_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Copyright 2023 Nomadic Labs <[email protected]>
# Copyright 2023 TriliTech <[email protected]>
#
# 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.

seed="zebra`for i in $(seq 1 23) ; do echo -n ' zebra' ; done`"

docker run --rm -it -v $(pwd)/app/bin:/speculos/apps \
-v $(pwd)/tests/integration:/tests --network host \
ledger-app-tezos-integration-tests --display=headless --vnc-port 41000 \
--seed "$seed" -m $TARGET apps/app.elf
42 changes: 42 additions & 0 deletions tests/integration/app_vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2023 Nomadic Labs <[email protected]>
# Copyright 2023 Trilitech <[email protected]>
# Copyright 2023 Functori <[email protected]>
#
# 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.

COMMIT=$(git describe --tags --abbrev=8 --always --long --dirty 2>/dev/null | sed 's/-dirty/*/')
export COMMIT_BYTES=$(printf '%s' "$COMMIT" | xxd -p -c 256)

VERSION_WALLET_TAG="00"
APPVERSION_M=3
APPVERSION_N=0
APPVERSION_P=0
export VERSION_BYTES=$(printf "%02x%02x%02x%02x" "$VERSION_WALLET_TAG" "$APPVERSION_M" "$APPVERSION_N" "$APPVERSION_P")

## Error code
ERR_WRONG_PARAM=6b00
ERR_WRONG_LENGTH=6c00
ERR_INVALID_INS=6d00
ERR_WRONG_LENGTH_FOR_INS=917e
ERR_REJECT=6985
ERR_PARSE_ERROR=9405
ERR_REFERENCED_DATA_NOT_FOUND=6a88
ERR_WRONG_VALUES=6a80
ERR_SECURITY=6982
ERR_HID_REQUIRED=6983
ERR_CLASS=6e00
ERR_MEMORY_ERROR=9200
ERR_UNEXPECTED_STATE=9001
ERR_UNEXPECTED_SIGN_STATE=9002
ERR_UNKNOWN_CX_ERR=9003
ERR_UNKNOWN=90ff
28 changes: 2 additions & 26 deletions tests/integration/test_runtime.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2023 Nomadic Labs <[email protected]>
# Copyright 2023 Trilitech <[email protected]>
# Copyright 2023 Functori <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,32 +48,7 @@
seed="zebra`for i in $(seq 1 23) ; do echo -n ' zebra' ; done`"
OUTPUT_BARS=$(for i in $(seq 1 $((COLUMNS-18))); do echo -n =; done)

COMMIT=$(git describe --tags --abbrev=8 --always --long --dirty 2>/dev/null | sed 's/-dirty/*/')
COMMIT_BYTES=$(printf '%s' "$COMMIT" | xxd -p -c 256)

VERSION_WALLET_TAG="00"
APPVERSION_M=3
APPVERSION_N=0
APPVERSION_P=0
VERSION_BYTES=$(printf "%02x%02x%02x%02x" "$VERSION_WALLET_TAG" "$APPVERSION_M" "$APPVERSION_N" "$APPVERSION_P")

## Error code
ERR_WRONG_PARAM=6b00
ERR_WRONG_LENGTH=6c00
ERR_INVALID_INS=6d00
ERR_WRONG_LENGTH_FOR_INS=917e
ERR_REJECT=6985
ERR_PARSE_ERROR=9405
ERR_REFERENCED_DATA_NOT_FOUND=6a88
ERR_WRONG_VALUES=6a80
ERR_SECURITY=6982
ERR_HID_REQUIRED=6983
ERR_CLASS=6e00
ERR_MEMORY_ERROR=9200
ERR_UNEXPECTED_STATE=9001
ERR_UNEXPECTED_SIGN_STATE=9002
ERR_UNKNOWN_CX_ERR=9003
ERR_UNKNOWN=90ff
. "`dirname $0`/app_vars.sh"

attempts() {
nb=$(( $TIMEOUT * 20 )) # We use multiplication to avoid floats
Expand Down

0 comments on commit 99f7f49

Please sign in to comment.