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
  • Loading branch information
apaillier-ledger committed Jun 20, 2024
1 parent 78cc02d commit 9c426dc
Show file tree
Hide file tree
Showing 30 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 @@ -394,6 +395,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 @@ -404,10 +411,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 @@ -422,6 +431,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.
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.
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.
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.
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 Down Expand Up @@ -340,7 +341,8 @@ def test_eip712_advanced_filtering(firmware: Firmware,
navigator: Navigator,
default_screenshot_path: Path,
test_name: str,
data_set: DataSet):
data_set: DataSet,
golden_run: bool):
global SNAPS_CONFIG

app_client = EthAppClient(backend)
Expand All @@ -355,7 +357,8 @@ def test_eip712_advanced_filtering(firmware: Firmware,
app_client,
data_set.data,
data_set.filters,
False)
False,
golden_run)

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

0 comments on commit 9c426dc

Please sign in to comment.