diff --git a/app/icons/flex_tezos.gif b/app/icons/flex_tezos.gif index 31026024a..7e6e4c6b1 100644 Binary files a/app/icons/flex_tezos.gif and b/app/icons/flex_tezos.gif differ diff --git a/app/src/ui_stream_nbgl.c b/app/src/ui_stream_nbgl.c index e5285f765..47c05a98e 100644 --- a/app/src/ui_stream_nbgl.c +++ b/app/src/ui_stream_nbgl.c @@ -517,7 +517,10 @@ tz_ui_stream_pushl(tz_ui_cb_type_t cb_type, const char *title, 0, &push_to_next); PRINTF("[DEBUG] idx=%d fit=%d push_to_next=%d\n", idx, fit, push_to_next); - push_to_next |= fit <= (uint8_t)idx; + /* + * Dont push to next screen if the number of pairs is one. + */ + push_to_next = (fit <= (uint8_t)idx); if (push_to_next) { /* We need to move to the next screen, retry */ diff --git a/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_proof_396...834_0.png b/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_proof_396...834_0.png index c5a7ad65c..92613e909 100644 Binary files a/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_proof_396...834_0.png and b/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_proof_396...834_0.png differ diff --git a/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_proof_396...834_1.png b/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_proof_396...834_1.png index 75d9e4e15..8cff58e64 100644 Binary files a/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_proof_396...834_1.png and b/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_proof_396...834_1.png differ diff --git a/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_proof_396...834_2.png b/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_proof_396...834_2.png deleted file mode 100644 index e4814a994..000000000 Binary files a/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_proof_396...834_2.png and /dev/null differ diff --git a/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_prooof_details_396...834_0.png b/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_prooof_details_396...834_0.png new file mode 100644 index 000000000..6b4f5e17c Binary files /dev/null and b/tests/integration/touch/snapshots/flex/test_sign_execute_outbox_messages/operation_prooof_details_396...834_0.png differ diff --git a/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_proof_396...834_0.png b/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_proof_396...834_0.png index c58bef7b0..f01cbf85a 100644 Binary files a/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_proof_396...834_0.png and b/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_proof_396...834_0.png differ diff --git a/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_proof_396...834_1.png b/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_proof_396...834_1.png index d8d320a1e..6e42e29b2 100644 Binary files a/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_proof_396...834_1.png and b/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_proof_396...834_1.png differ diff --git a/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_proof_396...834_2.png b/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_proof_396...834_2.png deleted file mode 100644 index 59731fe56..000000000 Binary files a/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_proof_396...834_2.png and /dev/null differ diff --git a/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_prooof_details_396...834_0.png b/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_prooof_details_396...834_0.png new file mode 100644 index 000000000..bbe11d5a3 Binary files /dev/null and b/tests/integration/touch/snapshots/stax/test_sign_execute_outbox_messages/operation_prooof_details_396...834_0.png differ diff --git a/tests/integration/touch/test_sign_execute_outbox_messages.py b/tests/integration/touch/test_sign_execute_outbox_messages.py index 2ed471ef3..556af67a9 100755 --- a/tests/integration/touch/test_sign_execute_outbox_messages.py +++ b/tests/integration/touch/test_sign_execute_outbox_messages.py @@ -20,6 +20,7 @@ send_payload ) + # full input: 0000000000000000000000000000000000000000000000000000000000000000ce00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c6396630396632393532643334353238633733336639343631356366633339626335353536313966633535306464346136376261323230386365386538363761613364313361366566393964666265333263363937346161396132313530643231656361323963333334396535396331336239303831663163313162343430616334643334353564656462653465653064653135613861663632306434633836323437643964313332646531626236646132336435666639643864666664613232626139613834 # signer: tz1dyX3B1CFYa2DfdFLyPtiJCfQRUgPVME6E @@ -41,9 +42,14 @@ app.review.next() app.expert_mode_splash() - for i in range(3): - app.review.next() - app.assert_screen(f"operation_proof_396...834_{i}") + app.review.next() + app.assert_screen("operation_proof_396...834_0") + app.review.show_more() + app.assert_screen("operation_prooof_details_396...834_0") + app.review.details.exit() + app.assert_screen("operation_proof_396...834_0") + app.review.next() + app.assert_screen("operation_proof_396...834_1") app.review.next() app.assert_screen("operation_sign") diff --git a/tests/integration/touch/utils.py b/tests/integration/touch/utils.py index b57bba567..169d71017 100644 --- a/tests/integration/touch/utils.py +++ b/tests/integration/touch/utils.py @@ -31,21 +31,21 @@ UseCaseSettings as OriginalUseCaseSettings, UseCaseAddressConfirmation as OriginalUseCaseAddressConfirmation, UseCaseReview as OriginalUseCaseReview, - UseCaseChoice + UseCaseChoice, + UseCaseViewDetails ) from ragger.firmware.touch.layouts import ChoiceList from ragger.firmware.touch.positions import ( Position, STAX_BUTTON_LOWER_LEFT, STAX_BUTTON_ABOVE_LOWER_MIDDLE, - STAX_BUTTON_LOWER_RIGHT, - STAX_BUTTON_LOWER_MIDDLE, FLEX_BUTTON_LOWER_LEFT, FLEX_BUTTON_ABOVE_LOWER_MIDDLE ) MAX_ATTEMPTS = 50 + def with_retry(f, attempts=MAX_ATTEMPTS): while True: try: @@ -58,14 +58,20 @@ def with_retry(f, attempts=MAX_ATTEMPTS): # Give plenty of time for speculos to update - can take a long time on CI machines time.sleep(0.5) + class UseCaseReview(OriginalUseCaseReview): """Extension of UseCaseReview for our app.""" reject_tx: UseCaseChoice enable_expert: UseCaseChoice enable_blindsign: UseCaseChoice + details: UseCaseViewDetails _center: Center + MORE_POSITIONS = { + Firmware.STAX: Position(200, 390), + Firmware.FLEX: Position(240, 350) + } def __init__(self, client: BackendInterface, firmware: Firmware): super().__init__(client, firmware) @@ -73,11 +79,22 @@ def __init__(self, client: BackendInterface, firmware: Firmware): self.enable_expert = UseCaseChoice(client, firmware) self.enable_blindsign = UseCaseChoice(client, firmware) self._center = Center(client, firmware) + self.details = UseCaseViewDetails(client, firmware) + + @property + def more_position(self) -> Position: + """Position of the `More` button.""" + return UseCaseReview.MORE_POSITIONS[self.firmware] def next(self) -> None: """Pass to the next screen.""" self._center.swipe_left() + def show_more(self) -> None: + """Tap to show more.""" + self.client.finger_touch(*self.more_position) + + class UseCaseAddressConfirmation(OriginalUseCaseAddressConfirmation): """Extension of UseCaseAddressConfirmation for our app.""" @@ -105,6 +122,7 @@ def show_qr(self) -> None: """Tap to show qr code.""" self.client.finger_touch(*self.qr_position) + class UseCaseSettings(OriginalUseCaseSettings): """Extension of UseCaseSettings for our app.""" @@ -126,6 +144,7 @@ def exit(self) -> None: """Exits settings.""" self.multi_page_exit() + class TezosAppScreen(metaclass=MetaScreen): use_case_welcome = UseCaseHomeExt use_case_settings = UseCaseSettings @@ -171,8 +190,9 @@ def __init__(self, for filename in os.listdir(path): os.remove(os.path.join(path, filename)) path = f"{self.__snapshots_path}" - home_path=os.path.join(path, "home.png") - if os.path.exists(home_path): os.remove(home_path) + home_path = os.path.join(path, "home.png") + if os.path.exists(home_path): + os.remove(home_path) def send_apdu(self, data): """Send hex-encoded bytes to the apdu""" @@ -182,7 +202,8 @@ def remove_info_page(self): """ Delete the info page for golden tests""" if self.__golden: info_path=os.path.join(self.__snapshots_path, "info.png") - if os.path.exists(info_path): os.remove(info_path) + if os.path.exists(info_path): + os.remove(info_path) def expect_apdu_return(self, expected): """Expect hex-encoded response from the apdu""" @@ -210,9 +231,10 @@ def assert_screen(self, screen, fixed: bool = False): path = f'{self.__snapshots_path}/{screen}.png' else: path = f'{self.__prefixed_snapshots_path}/{screen}.png' + def check(): print(f"- Expecting {screen} -") - assert self.__backend.compare_screen_with_snapshot(path, golden_run = golden) + assert self.__backend.compare_screen_with_snapshot(path, golden_run=golden) with_retry(check) @@ -301,46 +323,53 @@ def process_blindsign_warnings(self, landing_screen: str): self.review.enable_blindsign.confirm() - def tezos_app(prefix) -> TezosAppScreen: port = os.environ["PORT"] commit = os.environ["COMMIT_BYTES"] version = os.environ["VERSION_BYTES"] - golden = os.getenv("GOLDEN") != None + golden = os.getenv("GOLDEN") is not None target = os.getenv("TARGET") firmware = Firmware.STAX if target == "stax" else Firmware.FLEX backend = SpeculosBackend("__unused__", firmware, args=["--api-port", port]) return TezosAppScreen(backend, firmware, commit, version, prefix, golden) + def assert_home_with_code(app, code): app.assert_home() app.expect_apdu_failure(code) + def send_initialize_msg(app, apdu): app.send_apdu(apdu) app.expect_apdu_return("9000") app.assert_screen("review_request_sign_operation") + def send_payload(app, apdu): app.send_apdu(apdu) app.assert_screen("review_request_sign_operation") + def verify_err_reject_response(app, tag): verify_reject_response_common(app, tag, "9405") + def verify_reject_response(app, tag): - verify_reject_response_common(app, tag,"6985") + verify_reject_response_common(app, tag, "6985") + def verify_reject_response_common(app, tag, err_code): app.assert_screen(tag) app.review.reject() reject_flow(app, err_code) -def reject_flow(app,err_code): + +def reject_flow(app, err_code): app.assert_screen("reject_review") with app.fading_screen("rejected"): app.review.reject_tx.confirm() assert_home_with_code(app, err_code) + def index_screen(screen: str, index: int) -> str: return screen + "_" + str(index).zfill(2)