Skip to content

Commit

Permalink
Adapt client and ragger tests for eip712 friction
Browse files Browse the repository at this point in the history
  • Loading branch information
cedelavergne-ledger committed Sep 17, 2024
1 parent 02ec8a4 commit cb76c12
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions client/src/ledger_app_clients/ethereum/eip712/InputData.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down
10 changes: 8 additions & 2 deletions tests/ragger/test_eip712.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cb76c12

Please sign in to comment.