Skip to content

Commit

Permalink
Tests: get screens contents with the 'events' service for nanox
Browse files Browse the repository at this point in the history
While the 'events?currentscreenonly=true' service does not work
properly for nanox in the sha-6a34680 version of speculos
  • Loading branch information
spalmer25 committed Oct 5, 2023
1 parent df6208c commit 60f361d
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions tests/integration/check_section_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ def get_screen(url):
print(f'- {screen} -')
return screen

def get_titled_screen(url, title):
"""Retrieve the screen until title"""
r = requests.get(f'{url}/events')
r.raise_for_status()
lines = [e["text"] for e in r.json()["events"]]

assert len(lines) > 0, "Unexpected empty screen. Speculos killed?"

assert title in lines, f"Title \"{title}\" no found"

title_index = len(lines) - lines[::-1].index(title) - 1

screen = Screen(title=lines[title_index], text=lines[title_index+1:])
print(f'- {screen} -')
return screen

def press_button(url, button):
"""Press a button on the ledger device."""
print("- press", button)
Expand All @@ -89,8 +105,16 @@ 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 = get_screen(url)
assert screen.title == title, f"expected section '{title}' but on '{screen.title}'"
if device in ["nanos", "nanosp"]:
screen = get_screen(url)
assert screen.title == title, f"expected section '{title}' but on '{screen.title}'"
# https://github.com/trilitech/ledger-app-tezos-wallet/issues/43
# Get screens contents with the 'events' service for nanox
# while the 'events?currentscreenonly=true' service does not
# work properly for nanox in the sha-6a34680 version of
# speculos
if device == "nanox":
screen = get_titled_screen(url, title)
assert screen.matches(content, content_lines), \
f"{screen} did not match {content[:10]}...{content[-10:]}"

Expand Down

0 comments on commit 60f361d

Please sign in to comment.