Skip to content

Commit

Permalink
Ragger tests fix
Browse files Browse the repository at this point in the history
- Also lower the EIP-712 autonext delay but slow it down for golden runs
- Also re-generated Flex snapshots impacted by latest SDK changes
  • Loading branch information
apaillier-ledger committed Jun 13, 2024
1 parent 6617cd5 commit 6aa5a0d
Show file tree
Hide file tree
Showing 46 changed files with 23 additions and 9 deletions.
13 changes: 12 additions & 1 deletion client/src/ledger_app_clients/ethereum/eip712/InputData.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def default_handler():


autonext_handler: Callable = default_handler
is_golden_run: bool


# From a string typename, extract the type and all the array depth
Expand Down Expand Up @@ -389,6 +390,12 @@ def enable_autonext():
delay = 1/3
else:
delay = 1/4

# golden run has to be slower to make sure we take good snapshots
# and not processing/loading screens
if is_golden_run:
delay *= 3

signal.setitimer(signal.ITIMER_REAL, delay, delay)


Expand All @@ -399,10 +406,12 @@ def disable_autonext():
def process_data(aclient: EthAppClient,
data_json: dict,
filters: Optional[dict] = None,
autonext: Optional[Callable] = None) -> bool:
autonext: Optional[Callable] = None,
golden_run: bool = False) -> bool:
global sig_ctx
global app_client
global autonext_handler
global is_golden_run

# deepcopy because this function modifies the dict
data_json = copy.deepcopy(data_json)
Expand All @@ -417,6 +426,8 @@ def process_data(aclient: EthAppClient,
autonext_handler = autonext
signal.signal(signal.SIGALRM, next_timeout)

is_golden_run = golden_run

if filters:
init_signature_context(types, domain)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/ragger/snapshots/flex/test_personal_sign_opensea/00002.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/ragger/snapshots/flex/test_personal_sign_opensea/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
19 changes: 11 additions & 8 deletions tests/ragger/test_eip712.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ def eip712_new_common(firmware: Firmware,
app_client: EthAppClient,
json_data: dict,
filters: Optional[dict],
verbose: bool):
verbose: bool,
golden_run: bool):
assert InputData.process_data(app_client,
json_data,
filters,
partial(autonext, firmware, navigator, default_screenshot_path))
partial(autonext, firmware, navigator, default_screenshot_path),
golden_run)
with app_client.eip712_sign_new(BIP32_PATH):
moves = []
if firmware.device.startswith("nano"):
Expand All @@ -126,15 +128,13 @@ def eip712_new_common(firmware: Firmware,
moves += [NavInsID.BOTH_CLICK]
else:
# need to skip the message hash
if not verbose and filters is None:
moves += [NavInsID.USE_CASE_REVIEW_TAP]
moves += [NavInsID.USE_CASE_REVIEW_TAP]
moves += [NavInsID.USE_CASE_REVIEW_CONFIRM]
if SNAPS_CONFIG is not None:
navigator.navigate_and_compare(default_screenshot_path,
SNAPS_CONFIG.test_name,
moves,
snap_start_idx=SNAPS_CONFIG.idx)
SNAPS_CONFIG.idx += 1
else:
navigator.navigate(moves)
return ResponseParser.signature(app_client.response().data)
Expand Down Expand Up @@ -173,7 +173,8 @@ def test_eip712_new(firmware: Firmware,
app_client,
data,
filters,
verbose)
verbose,
False)

recovered_addr = recover_message(data, vrs)

Expand All @@ -185,7 +186,8 @@ def test_eip712_advanced_filtering(firmware: Firmware,
navigator: Navigator,
default_screenshot_path: Path,
test_name: str,
verbose: bool):
verbose: bool,
golden_run: bool):
global SNAPS_CONFIG

app_client = EthAppClient(backend)
Expand Down Expand Up @@ -286,7 +288,8 @@ def test_eip712_advanced_filtering(firmware: Firmware,
app_client,
data,
filters,
verbose)
verbose,
golden_run)

# verify signature
addr = recover_message(data, vrs)
Expand Down

0 comments on commit 6aa5a0d

Please sign in to comment.