Port scenario review in 'test_domain_name'

This commit is contained in:
Charles-Edouard de la Vergne
2024-04-16 23:43:00 +02:00
parent 1c9f138fdd
commit e428657f01
6 changed files with 26 additions and 44 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -2,14 +2,15 @@ from pathlib import Path
import pytest import pytest
from web3 import Web3 from web3 import Web3
import client.response_parser as ResponseParser
from client.client import EthAppClient, StatusWord
from client.settings import SettingID, settings_toggle
from ragger.backend import BackendInterface from ragger.backend import BackendInterface
from ragger.firmware import Firmware from ragger.firmware import Firmware
from ragger.error import ExceptionRAPDU from ragger.error import ExceptionRAPDU
from ragger.navigator import Navigator, NavInsID from ragger.navigator import Navigator
from ragger.navigator.navigation_scenario import NavigateWithScenario
import client.response_parser as ResponseParser
from client.client import EthAppClient, StatusWord
from client.settings import SettingID, settings_toggle
# Values used across all tests # Values used across all tests
@@ -41,6 +42,7 @@ def common(firmware: Firmware, app_client: EthAppClient) -> int:
def test_send_fund(firmware: Firmware, def test_send_fund(firmware: Firmware,
backend: BackendInterface, backend: BackendInterface,
navigator: Navigator, navigator: Navigator,
scenario_navigator: NavigateWithScenario,
default_screenshot_path: Path, default_screenshot_path: Path,
verbose: bool): verbose: bool):
app_client = EthAppClient(backend) app_client = EthAppClient(backend)
@@ -60,20 +62,12 @@ def test_send_fund(firmware: Firmware,
"value": Web3.to_wei(AMOUNT, "ether"), "value": Web3.to_wei(AMOUNT, "ether"),
"chainId": CHAIN_ID "chainId": CHAIN_ID
}): }):
moves = []
if firmware.device.startswith("nano"): if firmware.device.startswith("nano"):
moves += [NavInsID.RIGHT_CLICK] * 4 end_text = "Accept"
if verbose:
moves += [NavInsID.RIGHT_CLICK]
moves += [NavInsID.BOTH_CLICK]
else: else:
moves += [NavInsID.USE_CASE_REVIEW_TAP] * 2 end_text = "Sign"
if verbose:
moves += [NavInsID.USE_CASE_REVIEW_TAP] scenario_navigator.review_approve(default_screenshot_path, f"domain_name_verbose_{str(verbose)}", end_text)
moves += [NavInsID.USE_CASE_REVIEW_CONFIRM]
navigator.navigate_and_compare(default_screenshot_path,
"domain_name_verbose_" + str(verbose),
moves)
def test_send_fund_wrong_challenge(firmware: Firmware, backend: BackendInterface): def test_send_fund_wrong_challenge(firmware: Firmware, backend: BackendInterface):
@@ -87,7 +81,7 @@ def test_send_fund_wrong_challenge(firmware: Firmware, backend: BackendInterface
def test_send_fund_wrong_addr(firmware: Firmware, def test_send_fund_wrong_addr(firmware: Firmware,
backend: BackendInterface, backend: BackendInterface,
navigator: Navigator, scenario_navigator: NavigateWithScenario,
default_screenshot_path: Path): default_screenshot_path: Path):
app_client = EthAppClient(backend) app_client = EthAppClient(backend)
challenge = common(firmware, app_client) challenge = common(firmware, app_client)
@@ -106,21 +100,17 @@ def test_send_fund_wrong_addr(firmware: Firmware,
"value": Web3.to_wei(AMOUNT, "ether"), "value": Web3.to_wei(AMOUNT, "ether"),
"chainId": CHAIN_ID "chainId": CHAIN_ID
}): }):
moves = []
if firmware.device.startswith("nano"): if firmware.device.startswith("nano"):
moves += [NavInsID.RIGHT_CLICK] * 4 end_text = "Accept"
moves += [NavInsID.BOTH_CLICK]
else: else:
moves += [NavInsID.USE_CASE_REVIEW_TAP] * 2 end_text = "Sign"
moves += [NavInsID.USE_CASE_REVIEW_CONFIRM]
navigator.navigate_and_compare(default_screenshot_path, scenario_navigator.review_approve(default_screenshot_path, "domain_name_wrong_addr", end_text)
"domain_name_wrong_addr",
moves)
def test_send_fund_non_mainnet(firmware: Firmware, def test_send_fund_non_mainnet(firmware: Firmware,
backend: BackendInterface, backend: BackendInterface,
navigator: Navigator, scenario_navigator: NavigateWithScenario,
default_screenshot_path: Path): default_screenshot_path: Path):
app_client = EthAppClient(backend) app_client = EthAppClient(backend)
challenge = common(firmware, app_client) challenge = common(firmware, app_client)
@@ -136,21 +126,17 @@ def test_send_fund_non_mainnet(firmware: Firmware,
"value": Web3.to_wei(AMOUNT, "ether"), "value": Web3.to_wei(AMOUNT, "ether"),
"chainId": 5 "chainId": 5
}): }):
moves = []
if firmware.device.startswith("nano"): if firmware.device.startswith("nano"):
moves += [NavInsID.RIGHT_CLICK] * 5 end_text = "Accept"
moves += [NavInsID.BOTH_CLICK]
else: else:
moves += [NavInsID.USE_CASE_REVIEW_TAP] * 2 end_text = "Sign"
moves += [NavInsID.USE_CASE_REVIEW_CONFIRM]
navigator.navigate_and_compare(default_screenshot_path, scenario_navigator.review_approve(default_screenshot_path, "domain_name_non_mainnet", end_text)
"domain_name_non_mainnet",
moves)
def test_send_fund_unknown_chain(firmware: Firmware, def test_send_fund_unknown_chain(firmware: Firmware,
backend: BackendInterface, backend: BackendInterface,
navigator: Navigator, scenario_navigator: NavigateWithScenario,
default_screenshot_path: Path): default_screenshot_path: Path):
app_client = EthAppClient(backend) app_client = EthAppClient(backend)
challenge = common(firmware, app_client) challenge = common(firmware, app_client)
@@ -166,16 +152,12 @@ def test_send_fund_unknown_chain(firmware: Firmware,
"value": Web3.to_wei(AMOUNT, "ether"), "value": Web3.to_wei(AMOUNT, "ether"),
"chainId": 9 "chainId": 9
}): }):
moves = []
if firmware.device.startswith("nano"): if firmware.device.startswith("nano"):
moves += [NavInsID.RIGHT_CLICK] * 5 end_text = "Accept"
moves += [NavInsID.BOTH_CLICK]
else: else:
moves += [NavInsID.USE_CASE_REVIEW_TAP] * 3 end_text = "Sign"
moves += [NavInsID.USE_CASE_REVIEW_CONFIRM]
navigator.navigate_and_compare(default_screenshot_path, scenario_navigator.review_approve(default_screenshot_path, "domain_name_unknown_chain", end_text)
"domain_name_unknown_chain",
moves)
def test_send_fund_domain_too_long(firmware: Firmware, backend: BackendInterface): def test_send_fund_domain_too_long(firmware: Firmware, backend: BackendInterface):