Skip to content

Commit

Permalink
README: fix testing instructions for STAX
Browse files Browse the repository at this point in the history
The instructions were out of date due to updates to test_runtime
  • Loading branch information
emturner committed Oct 25, 2023
1 parent 08fbb85 commit 0d32812
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 31 deletions.
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 0d32812

Please sign in to comment.