Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions tests/standalone/test_hedera.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from ragger.backend.interface import RAPDU, RaisePolicy
from ragger.navigator import NavInsID
from ragger.firmware import Firmware
from ragger.firmware.touch.use_cases import UseCaseReview
import pytest
from ledgered.devices import Devices

from tests.application_client.hedera import HederaClient, ErrorType, STATUS_OK
from tests.application_client.hedera_builder import crypto_create_account_conf, crypto_transfer_verify, \
Expand Down Expand Up @@ -43,9 +42,10 @@ def test_hedera_get_public_key_ok(backend, firmware, navigator, test_name):
backend.wait_for_home_screen()
assert from_public_key.hex() == key
with hedera.get_public_key_confirm(index):
if firmware.device == "nanos":
device_info = Devices.get_by_type(firmware)
if device_info.name == "nanos":
nav_ins = [NavInsID.RIGHT_CLICK]
elif backend.firmware.device.startswith("nano"):
elif device_info.name.startswith("nano"):
nav_ins = [NavInsID.RIGHT_CLICK,
NavInsID.BOTH_CLICK]
else:
Expand All @@ -60,9 +60,10 @@ def test_hedera_get_public_key_ok(backend, firmware, navigator, test_name):
def test_hedera_get_public_key_refused(backend, firmware, navigator, test_name):
hedera = HederaClient(backend)
with hedera.get_public_key_confirm(0):
if firmware.device == "nanos":
device_info = Devices.get_by_type(firmware)
if device_info.name == "nanos":
nav_ins = [NavInsID.LEFT_CLICK]
elif backend.firmware.device.startswith("nano"):
elif device_info.name.startswith("nano"):
nav_ins = [NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
NavInsID.BOTH_CLICK]
Expand All @@ -75,7 +76,7 @@ def test_hedera_get_public_key_refused(backend, firmware, navigator, test_name):
rapdu = hedera.get_async_response()
assert rapdu.status == ErrorType.EXCEPTION_USER_REJECTED

if not firmware.is_nano:
if not device_info.name.startswith("nano"):
with hedera.get_public_key_confirm(0):
backend.raise_policy = RaisePolicy.RAISE_NOTHING
nav_ins = [NavInsID.USE_CASE_REVIEW_NEXT,
Expand Down Expand Up @@ -266,9 +267,10 @@ def test_hedera_crypto_update_account_refused(backend, firmware, scenario_naviga
conf=conf,
):
backend.raise_policy = RaisePolicy.RAISE_NOTHING
if firmware is Firmware.NANOS:
device_info = Devices.get_by_type(firmware)
if device_info.name == "nanos":
scenario_navigator.review_reject(custom_screen_text="Deny")
elif firmware.is_nano:
elif device_info.name.startswith("nano"):
scenario_navigator.review_reject(custom_screen_text="Reject")
else:
navigation_helper_reject(firmware, scenario_navigator)
Expand Down Expand Up @@ -1984,7 +1986,8 @@ def test_hedera_erc20_reject_warning(backend, firmware, navigator, scenario_navi


def test_hedera_erc20_show_qr_code(backend, firmware, navigator, scenario_navigator, test_name):
if firmware.is_nano:
device_info = Devices.get_by_type(firmware)
if device_info.name.startswith("nano"):
pytest.skip("QR codes are not implemented for nano")
return

Expand Down
23 changes: 14 additions & 9 deletions tests/standalone/utils.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
from pathlib import Path
from ragger.firmware import Firmware
from ragger.navigator import NavInsID

from ledgered.devices import Devices

ROOT_SCREENSHOT_PATH = Path(__file__).parent.resolve()

def navigation_helper_confirm(firmware, scenario_navigator):
if firmware.is_nano:
device_info = Devices.get_by_type(firmware)
if device_info.name.startswith("nano"):
scenario_navigator.review_approve(custom_screen_text="Confirm")
else:
scenario_navigator.review_approve()

def navigation_helper_reject(firmware, scenario_navigator):
if firmware is Firmware.NANOS:
device_info = Devices.get_by_type(firmware)
if device_info.name == "nanos":
scenario_navigator.review_reject(custom_screen_text="Deny")
elif firmware.is_nano:
elif device_info.name.startswith("nano"):
scenario_navigator.review_reject(custom_screen_text="Reject")
else:
scenario_navigator.review_reject()
Expand All @@ -23,7 +24,8 @@ def navigation_helper_reject(firmware, scenario_navigator):
def navigate_erc20_confirm(firmware, navigator, scenario_navigator, screenshots_path: Path, test_name: str):
print(type(firmware))
"""Standard ERC20 navigation schema: capture NBGL warning, then approve review."""
if firmware.is_nano:
device_info = Devices.get_by_type(firmware)
if device_info.name.startswith("nano"):
print("navigate_erc20_confirm nano")
navigator.navigate_and_compare(
screenshots_path,
Expand All @@ -44,7 +46,8 @@ def navigate_erc20_confirm(firmware, navigator, scenario_navigator, screenshots_

def navigate_erc20_reject(firmware, navigator, scenario_navigator, screenshots_path: Path, test_name: str):
"""Standard ERC20 navigation schema: capture NBGL warning, then reject review."""
if firmware.is_nano:
device_info = Devices.get_by_type(firmware)
if device_info.name.startswith("nano"):
print("navigate_erc20_reject nano")
navigator.navigate_and_compare(
screenshots_path,
Expand All @@ -64,7 +67,8 @@ def navigate_erc20_reject(firmware, navigator, scenario_navigator, screenshots_p

def navigate_erc20_reject_at_warning(firmware, navigator, scenario_navigator, screenshots_path: Path, test_name: str):
"""Standard ERC20 navigation schema: capture NBGL warning, then reject review."""
if firmware.is_nano:
device_info = Devices.get_by_type(firmware)
if device_info.name.startswith("nano"):
print("navigate_erc20_reject_at_warning nano")
navigator.navigate_and_compare(
screenshots_path,
Expand All @@ -83,7 +87,8 @@ def navigate_erc20_reject_at_warning(firmware, navigator, scenario_navigator, sc

def navigate_erc20_show_qr_code(firmware, navigator, scenario_navigator, screenshots_path: Path, test_name: str):
"""Standard ERC20 navigation schema: capture NBGL warning, then show QR code."""
if firmware.is_nano:
device_info = Devices.get_by_type(firmware)
if device_info.name.startswith("nano"):
raise NotImplementedError("navigate_erc20_show_qr_code is not implemented for nano")
else:
navigator.navigate_and_compare(
Expand Down
Loading