From cb76c124145b7c6bd6e19b255bd68382397c3b02 Mon Sep 17 00:00:00 2001 From: Charles-Edouard de la Vergne Date: Thu, 12 Sep 2024 11:15:00 +0200 Subject: [PATCH] Adapt client and ragger tests for eip712 friction --- .../ledger_app_clients/ethereum/eip712/InputData.py | 9 +++++++++ tests/ragger/test_eip712.py | 10 ++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/client/src/ledger_app_clients/ethereum/eip712/InputData.py b/client/src/ledger_app_clients/ethereum/eip712/InputData.py index 43f88f3af4..9cbb07d9b3 100644 --- a/client/src/ledger_app_clients/ethereum/eip712/InputData.py +++ b/client/src/ledger_app_clients/ethereum/eip712/InputData.py @@ -11,6 +11,7 @@ from client.client import EthAppClient, EIP712FieldType from ragger.firmware import Firmware +from ragger.navigator import Navigator, NavInsID from client.client import PKIPubKeyUsage @@ -436,6 +437,7 @@ def disable_autonext(): def process_data(aclient: EthAppClient, + navigator: Navigator, data_json: dict, filters: Optional[dict] = None, autonext: Optional[Callable] = None, @@ -494,6 +496,13 @@ def process_data(aclient: EthAppClient, # send domain implementation with app_client.eip712_send_struct_impl_root_struct(domain_typename): + if filters is None: + if app_client._client.firmware.is_nano: + print("TODO!!!") + else: + navigator.navigate([NavInsID.USE_CASE_CHOICE_REJECT], + screen_change_before_first_instruction=False, + screen_change_after_last_instruction=False) enable_autonext() disable_autonext() if not send_struct_impl(types, domain, domain_typename): diff --git a/tests/ragger/test_eip712.py b/tests/ragger/test_eip712.py index 90f8022d6b..1e1bc5a499 100644 --- a/tests/ragger/test_eip712.py +++ b/tests/ragger/test_eip712.py @@ -117,6 +117,7 @@ def eip712_new_common(firmware: Firmware, verbose: bool, golden_run: bool): assert InputData.process_data(app_client, + navigator, json_data, filters, partial(autonext, firmware, navigator, default_screenshot_path), @@ -173,8 +174,13 @@ def test_eip712_new(firmware: Firmware, except (IOError, json.decoder.JSONDecodeError) as e: pytest.skip(f"{filterfile.name}: {e.strerror}") + settings = [] if verbose: - settings_toggle(firmware, navigator, [SettingID.VERBOSE_EIP712]) + settings.append(SettingID.VERBOSE_EIP712) + if not filtering: + settings.append(SettingID.BLIND_SIGNING) + if len(settings) > 0: + settings_toggle(firmware, navigator, settings) with open(input_file, encoding="utf-8") as file: data = json.load(file) @@ -566,7 +572,7 @@ def test_eip712_advanced_missing_token(firmware: Firmware, golden_run: bool): global SNAPS_CONFIG - test_name += "-%s-%s" % (len(tokens[0]) == 0, len(tokens[1]) == 0) + test_name += f"-{len(tokens[0]) == 0}-{len(tokens[1]) == 0}" SNAPS_CONFIG = SnapshotsConfig(test_name) app_client = EthAppClient(backend)