Skip to content

Commit

Permalink
build: bump sdk/speculos versions
Browse files Browse the repository at this point in the history
- OCR fix for missing 'S' / conversion of 'I' to 'l'
- introduce odd OCR issue on nanox for 'Parsing Error ERR'
- stax snapshotting has changed slightly, required re-snapshotting images
  • Loading branch information
emturner committed Sep 26, 2023
1 parent 968e65e commit fd005a7
Show file tree
Hide file tree
Showing 27 changed files with 53 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
device: [nanos, nanosp, nanox, stax]
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:1d9f741e9bc969b072e2de53762b64993536c0f7
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:3.5.0
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ docker_speculos:
$(DOCKER) image tag $(LEDGERHQ)/speculos speculos

docker_ledger_app_builder:
$(DOCKER) pull $(LEDGERHQ)/ledger-app-builder/ledger-app-builder:1d9f741e9bc969b072e2de53762b64993536c0f7
$(DOCKER) image tag $(LEDGERHQ)/ledger-app-builder/ledger-app-builder:1d9f741e9bc969b072e2de53762b64993536c0f7 \
$(DOCKER) pull $(LEDGERHQ)/ledger-app-builder/ledger-app-builder:3.5.0
$(DOCKER) image tag $(LEDGERHQ)/ledger-app-builder/ledger-app-builder:3.5.0 \
ledger-app-builder

docker_ledger_app_ocaml:
Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile.integration-tests
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM ghcr.io/ledgerhq/speculos:sha-744f56b
FROM ghcr.io/ledgerhq/speculos:sha-6a34680

RUN apt update && \
apt install -y curl jq build-essential libsodium-dev git && \
pip install base58 pytezos && \
git clone --depth 1 --branch v1.11.1 https://github.com/ledgerHQ/ragger && \
pip install base58 pytezos pytesseract && \
git clone --depth 1 --branch v1.11.4 https://github.com/ledgerHQ/ragger && \
cd ragger && \
pip install --extra-index-url https://test.pypi.org/simple/ '.[all_backends]' && \
cd ..
Expand Down
64 changes: 19 additions & 45 deletions tests/integration/check_section_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ class Screen:
title: str
text: list[str]

def matches(self, content: str, content_lines: int, device) -> bool:
def matches(self, content: str, content_lines: int) -> bool:
for l in self.text:
l = device_alter_content(device, l)
content = content.lstrip('\n')
if not content.startswith(l):
return False
Expand Down Expand Up @@ -86,42 +85,29 @@ def check_multi_screen(url, title, content, content_lines, device):
"""Assert that the screen contents across all screens with the given title match expected content."""
while True:
def check_screen(screen):
assert screen.title == title, f"expected section '{title}' but on '{screen.title}'"
assert screen.matches(content, content_lines, device), f"{screen} did not match {content}"
return screen
t = title
c = content
cl = content_lines

on_screen = with_retry(url, check_screen)
content = on_screen.strip(content)
if device == "nanox":
# Sometimes the title goes missing, along with the start of the first line.
if screen.title != title and screen.title in content[:20] and len(screen.text) == content_lines - 1:
start = content.find(screen.title)
c = content[start + len(screen.title):]
t = screen.title
cl = content_lines - 1

if content == "":
break
assert screen.title == t, f"expected section '{t}' ('{title}') but on '{screen.title}'"
assert screen.matches(c, cl), f"{screen} did not match {content}"

press_right(url)
return screen.strip(c)

print(f'- final screen {on_screen} -')
content = with_retry(url, check_screen)

def check_potential_remaining_screen(url, device, title, content):
"""Ignore the next blank screen on nanosp/nanox to avoid missing a potential terminal 'S'."""
# OCR issue https://github.com/LedgerHQ/speculos/issues/204
if device in ["nanosp", "nanox"] and content.endswith('S'):

def check_screen(screen):
if screen.title == title:
assert all([l == "" for l in screen.text]), f"Expected blank screen (containing only 'S'), got {screen.text}"
return screen

while True:
press_right(url)
screen = with_retry(url, check_screen)
if screen.title != title:
break

def check_back(screen):
assert screen.title == title
if content == "":
break

press_left(url)
# wait until we are back on last page of content
with_retry(url, check_back)
press_right(url)

def device_content_lines(device: str) -> int:
if device == "nanos":
Expand All @@ -131,17 +117,6 @@ def device_content_lines(device: str) -> int:

raise ValueError(f"unsupported device '{device}'")

def device_alter_content(device: str, content: str) -> str:
if device == "nanos":
return content
if device in ["nanosp", "nanox"]:
# OCR issue https://github.com/LedgerHQ/speculos/issues/204
content = content.replace('S', '')
content = content.replace('I', 'l')
return content

raise ValueError(f"unsupported device '{device}'")

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Check a section of pages contain the expected content.")
parser.add_argument("-d", "--device", help="device type: nanos | nanosp", required=True)
Expand All @@ -151,7 +126,6 @@ def device_alter_content(device: str, content: str) -> str:
args = parser.parse_args()

content_lines = device_content_lines(args.device)
content = device_alter_content(args.device, args.expected_content)
content = args.expected_content

check_multi_screen(args.url, args.title, content, content_lines, args.device)
check_potential_remaining_screen(args.url, args.device, args.title, args.expected_content)
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,11 @@ send_async_apdus \
800f8200502000040743036c030b07430359030a074303680100000009225c365f340a246b25074303680100000024635e31225c3f45795f31214556627e393b45583b59550a234b6a325a54386860552158200345 "expect_apdu_return dcba96786c40c7894527a85050bc0b75eaee37aa020a52c634275450018da47822d552099146915f4c3280b3dbd4ab5d459b96b585247e58fda9bf53c9951dbe017811d074e688f11d8f47ce7f94c0548dca76be9ae9e87df794d3facdb4bb0a9000
"

expect_full_text 'Expression' '{lF_NONE {{WAP;lF {DlP {{DROP 1;PUH unit Unit;PUH bool True;PUH string "'
press_button right
expect_full_text 'Expression' ';L\\?p$-Fq)VDg\n]te\no4v0_8)\""}}} {{DROP 2;PUH unit Unit;PUH bool False;'
press_button right
expect_full_text 'Expression' 'PUH string "Li-%*edF6~?E[5Kmu?dyviwJ^2\"\\d$FyQ>>!>D$g(Qg";PUH string "*Tx'
press_button right
expect_full_text 'Expression' '<E`iG6Yf*A^kZ\\=7?H[mOlQ\n]Ehs"}}}} {lF_NONE {DUP} {{DROP 4;PUH unit Unit;'
press_button right
expect_full_text 'Expression' 'PUH bool True;PUH string "\"\\6_4\n$k%";PUH string "c^1\"\\?Ey_1!EVb~9;EX'
press_button right
expect_full_text 'Expression' ';YU\n#Kj2ZT8h`U!X "}}};lZE}'
press_button right
expect_section_content nanosp \
'Expression' \
'{IF_NONE {{SWAP;IF {DIP {{DROP 1;PUSH unit Unit;PUSH bool True;PUSH string ";L\\S?p$-Fq)VDg\n]te\no4v0_8)\""}}} {{DROP 2;PUSH unit Unit;PUSH bool False;PUSH string "Li-%*edF6~?E[5Kmu?dyviwJ^2\"\\d$FyQ>>!>D$g(Qg";PUSH string "*Tx<E`SiG6Yf*A^kZ\\=7?H[mOlQ\n]Ehs"}}}} {IF_NONE {DUP} {{DROP 4;PUSH unit Unit;PUSH bool True;PUSH string "\"\\6_4\n$k%";PUSH string "c^1\"\\?Ey_1!EVb~9;EX;YU\n#Kj2ZT8h`U!X "}}};SIZE}'

press_button right
expect_full_text 'Accept?' 'Press both buttons to accept.'
press_button both
expect_async_apdus_sent
8 changes: 4 additions & 4 deletions tests/integration/nanosp/test_blindsign_too_deep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ expect_full_text 'Tezos Wallet' 'ready for' 'safe signing'
press_button right
expect_full_text 'Tezos Wallet' 'ready for' 'BLIND signing'
send_async_apdus \
800f000011048000002c800006c18000000080000000 "expect_apdu_return 9000" \
800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000 "expect_apdu_return 9000" \
800f82001211020000000c02000000070200000002002a "expect_apdu_return 93070b00990e4cf29c31f6497307bea0ad86a9d0dc08dba8b607e8dc0e23652f8309e41ed87ac1d33006806b688cfcff7632c4fbe499ff3ea4983ae4f06dea7790ec25db045689bca2c63967b5c563aabff86c4ef163bff92af3bb2ca9392d099000"
800f000011048000002c800006c18000000080000000 "expect_apdu_return 9000" \
800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000 "expect_apdu_return 9000" \
800f82001211020000000c02000000070200000002002a "expect_apdu_return 93070b00990e4cf29c31f6497307bea0ad86a9d0dc08dba8b607e8dc0e23652f8309e41ed87ac1d33006806b688cfcff7632c4fbe499ff3ea4983ae4f06dea7790ec25db045689bca2c63967b5c563aabff86c4ef163bff92af3bb2ca9392d099000"
expect_full_text 'Sign Hash' Micheline expression
press_button right
expect_full_text 'Sign Hash' AtwAJe8iMNaJwdugjXmGWQM8Z2dznb215smWzkLY3qY
expect_full_text 'Sign Hash' AtwAJe8iMNaJwdugjXmGWQM8Z2dznb215smWzkSLY3qY
press_button right
expect_full_text 'Accept?' 'Press both buttons to accept.'
press_button both
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/nanosp/test_blindsign_too_large.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ expect_full_text 'Tezos Wallet' 'ready for' 'safe signing'
press_button right
expect_full_text 'Tezos Wallet' 'ready for' 'BLIND signing'
send_async_apdus \
800f000011048000002c800006c18000000080000000 "expect_apdu_return 9000" \
800f810028050092abf8e3d9e5f8cfd9ae8a9fe5f28ea1d5b5abf1af82dae8a4b68df3d1889eb6f988f5e8d31a "expect_apdu_return ef565fa445d815cd77518a4d14ce90b7a536627455f0930c9dbfa22a75d478d83e2bcb333ba0d639dd28c1b77c5860e552ab02092a50a57f1424f573278230ab8ba81d8a40956415278a27e3f28cae64d1f1f13bf613e6e9a57035e9e14511029000"
800f000011048000002c800006c18000000080000000 "expect_apdu_return 9000" \
800f810028050092abf8e3d9e5f8cfd9ae8a9fe5f28ea1d5b5abf1af82dae8a4b68df3d1889eb6f988f5e8d31a "expect_apdu_return ef565fa445d815cd77518a4d14ce90b7a536627455f0930c9dbfa22a75d478d83e2bcb333ba0d639dd28c1b77c5860e552ab02092a50a57f1424f573278230ab8ba81d8a40956415278a27e3f28cae64d1f1f13bf613e6e9a57035e9e14511029000"
expect_full_text 'Sign Hash' Micheline expression
press_button right
expect_full_text 'Sign Hash' H7Gq5omPmhFhDPeyywQsb5Mmt2fiBwsgwvuNXzu18Xq
expect_full_text 'Sign Hash' H7Gq5omPmhFhDPeyywQsSb5Mmt2fiBwsgwvuNXzu18Xq
press_button right
expect_full_text 'Accept?' 'Press both buttons to accept.'
press_button both
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/nanosp/test_tz2_sign_micheline_basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expect_full_text "Tezos Wallet" "ready for" "safe signing"
send_apdu 800f000111048000002c800006c18000000080000000
expect_apdu_return 9000
send_apdu 800f81012305020000001d0100000004434143410100000004504f504f0100000006424f5544494e
expect_full_text Expression '{"CACA";"POPO";"BOUDlN"}'
expect_full_text Expression '{"CACA";"POPO";"BOUDIN"}'
press_button right
expect_full_text "Accept?" "Press both buttons to accept."
press_button both
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/nanox/test_blindsign_too_deep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ expect_full_text 'Tezos Wallet' 'ready for' 'safe signing'
press_button right
expect_full_text 'Tezos Wallet' 'ready for' 'BLIND signing'
send_async_apdus \
800f000011048000002c800006c18000000080000000 "expect_apdu_return 9000" \
800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000 "expect_apdu_return 9000" \
800f82001211020000000c02000000070200000002002a "expect_apdu_return 93070b00990e4cf29c31f6497307bea0ad86a9d0dc08dba8b607e8dc0e23652f8309e41ed87ac1d33006806b688cfcff7632c4fbe499ff3ea4983ae4f06dea7790ec25db045689bca2c63967b5c563aabff86c4ef163bff92af3bb2ca9392d099000"
800f000011048000002c800006c18000000080000000 "expect_apdu_return 9000" \
800f0100eb0502000000f702000000f202000000ed02000000e802000000e302000000de02000000d902000000d402000000cf02000000ca02000000c502000000c002000000bb02000000b602000000b102000000ac02000000a702000000a2020000009d02000000980200000093020000008e02000000890200000084020000007f020000007a02000000750200000070020000006b02000000660200000061020000005c02000000570200000052020000004d02000000480200000043020000003e02000000390200000034020000002f020000002a02000000250200000020020000001b020000001602000000 "expect_apdu_return 9000" \
800f82001211020000000c02000000070200000002002a "expect_apdu_return 93070b00990e4cf29c31f6497307bea0ad86a9d0dc08dba8b607e8dc0e23652f8309e41ed87ac1d33006806b688cfcff7632c4fbe499ff3ea4983ae4f06dea7790ec25db045689bca2c63967b5c563aabff86c4ef163bff92af3bb2ca9392d099000"
expect_full_text 'Sign Hash' Micheline expression
press_button right
expect_full_text 'Sign Hash' AtwAJe8iMNaJwdugjXmGWQM8Z2dznb215smWzkLY3qY
expect_full_text 'Sign Hash' AtwAJe8iMNaJwdugjXmGWQM8Z2dznb215smWzkSLY3qY
press_button right
expect_full_text 'Accept?' 'Press both buttons to accept.'
press_button both
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/nanox/test_blindsign_too_large.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ expect_full_text 'Tezos Wallet' 'ready for' 'safe signing'
press_button right
expect_full_text 'Tezos Wallet' 'ready for' 'BLIND signing'
send_async_apdus \
800f000011048000002c800006c18000000080000000 "expect_apdu_return 9000" \
800f810028050092abf8e3d9e5f8cfd9ae8a9fe5f28ea1d5b5abf1af82dae8a4b68df3d1889eb6f988f5e8d31a "expect_apdu_return ef565fa445d815cd77518a4d14ce90b7a536627455f0930c9dbfa22a75d478d83e2bcb333ba0d639dd28c1b77c5860e552ab02092a50a57f1424f573278230ab8ba81d8a40956415278a27e3f28cae64d1f1f13bf613e6e9a57035e9e14511029000"
800f000011048000002c800006c18000000080000000 "expect_apdu_return 9000" \
800f810028050092abf8e3d9e5f8cfd9ae8a9fe5f28ea1d5b5abf1af82dae8a4b68df3d1889eb6f988f5e8d31a "expect_apdu_return ef565fa445d815cd77518a4d14ce90b7a536627455f0930c9dbfa22a75d478d83e2bcb333ba0d639dd28c1b77c5860e552ab02092a50a57f1424f573278230ab8ba81d8a40956415278a27e3f28cae64d1f1f13bf613e6e9a57035e9e14511029000"
expect_full_text 'Sign Hash' Micheline expression
press_button right
expect_full_text 'Sign Hash' H7Gq5omPmhFhDPeyywQsb5Mmt2fiBwsgwvuNXzu18Xq
expect_full_text 'Sign Hash' H7Gq5omPmhFhDPeyywQsSb5Mmt2fiBwsgwvuNXzu18Xq
press_button right
expect_full_text 'Accept?' 'Press both buttons to accept.'
press_button both
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/nanox/test_tz2_sign_micheline_basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expect_full_text "Tezos Wallet" "ready for" "safe signing"
send_apdu 800f000111048000002c800006c18000000080000000
expect_apdu_return 9000
send_apdu 800f81012305020000001d0100000004434143410100000004504f504f0100000006424f5544494e
expect_full_text Expression '{"CACA";"POPO";"BOUDlN"}'
expect_full_text Expression '{"CACA";"POPO";"BOUDIN"}'
press_button right
expect_full_text "Accept?" "Press both buttons to accept."
press_button both
Expand Down
Binary file modified tests/integration/stax/snapshots/address_rejected.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 modified tests/integration/stax/snapshots/address_verified.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 modified tests/integration/stax/snapshots/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 modified tests/integration/stax/snapshots/home_bs_enabled_blindsign.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 modified tests/integration/stax/snapshots/home_bs_enabled_clearsign.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 modified tests/integration/stax/snapshots/info.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 modified tests/integration/stax/snapshots/loading_operation.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 modified tests/integration/stax/snapshots/request_blindsign_manager.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 modified tests/integration/stax/snapshots/review_blindsign_approve.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 modified tests/integration/stax/snapshots/review_blindsign_manager_basic.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 modified tests/integration/stax/snapshots/screen_show_address_tz1_zebra.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 modified tests/integration/stax/snapshots/screen_verify_address.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 modified tests/integration/stax/snapshots/settings_blindsigning_off.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 modified tests/integration/stax/snapshots/settings_blindsigning_on.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 modified tests/integration/stax/snapshots/signing_successful.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions tests/integration/test_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@ attempts() {
}

compare_strings() {
STR1="$(echo $1 | sed 's/I/l/g; s/S//g')"
STR2="$(echo $2 | sed 's/I/l/g; s/S//g')"
STR1="$1"
STR2="$2"

if [ "nanox" = "$TARGET" ]; then
# TODO: raise issue on speculos?
STR1="$(echo $1 | sed 's/Parsing errorERR//g')"
STR2="$(echo $2 | sed 's/Parsing errorERR//g')"
fi

[ "$STR1" = "$STR2" ]
}
Expand Down

0 comments on commit fd005a7

Please sign in to comment.