Improve ragger tests
- Use defined firmware instead of strings - Fix compatibility with Python 3.9 - Fix test navigation steps
This commit is contained in:
committed by
Alexandre Paillier
parent
fee187d90e
commit
cf3c5c3064
@@ -1,4 +1,3 @@
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from ragger.error import ExceptionRAPDU
|
||||
@@ -17,7 +16,6 @@ BIP32_PATH = "m/44'/60'/0'/0/0"
|
||||
def common(backend: BackendInterface,
|
||||
scenario: NavigateWithScenario,
|
||||
test_name: str,
|
||||
screenshot_path: Path,
|
||||
msg: str):
|
||||
|
||||
app_client = EthAppClient(backend)
|
||||
@@ -27,7 +25,7 @@ def common(backend: BackendInterface,
|
||||
_, DEVICE_ADDR, _ = ResponseParser.pk_addr(app_client.response().data)
|
||||
|
||||
with app_client.personal_sign(BIP32_PATH, msg.encode('utf-8')):
|
||||
scenario.review_approve(screenshot_path, test_name, "Sign")
|
||||
scenario.review_approve(test_name=test_name, custom_screen_text="Sign")
|
||||
|
||||
# verify signature
|
||||
vrs = ResponseParser.signature(app_client.response().data)
|
||||
@@ -37,29 +35,26 @@ def common(backend: BackendInterface,
|
||||
|
||||
def test_personal_sign_metamask(backend: BackendInterface,
|
||||
scenario_navigator: NavigateWithScenario,
|
||||
test_name: str,
|
||||
default_screenshot_path: Path):
|
||||
test_name: str):
|
||||
|
||||
msg = "Example `personal_sign` message"
|
||||
common(backend, scenario_navigator, test_name, default_screenshot_path, msg)
|
||||
common(backend, scenario_navigator, test_name, msg)
|
||||
|
||||
|
||||
def test_personal_sign_non_ascii(backend: BackendInterface,
|
||||
scenario_navigator: NavigateWithScenario,
|
||||
test_name: str,
|
||||
default_screenshot_path: Path):
|
||||
test_name: str):
|
||||
|
||||
msg = "0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658"
|
||||
common(backend, scenario_navigator, test_name, default_screenshot_path, msg)
|
||||
common(backend, scenario_navigator, test_name, msg)
|
||||
|
||||
|
||||
def test_personal_sign_opensea(firmware: Firmware,
|
||||
backend: BackendInterface,
|
||||
scenario_navigator: NavigateWithScenario,
|
||||
test_name: str,
|
||||
default_screenshot_path: Path):
|
||||
test_name: str):
|
||||
|
||||
if firmware.device == "nanos":
|
||||
if firmware == Firmware.NANOS:
|
||||
pytest.skip("Not supported on LNS")
|
||||
|
||||
msg = "Welcome to OpenSea!\n\n"
|
||||
@@ -67,14 +62,12 @@ def test_personal_sign_opensea(firmware: Firmware,
|
||||
msg += "This request will not trigger a blockchain transaction or cost any gas fees.\n\n"
|
||||
msg += "Your authentication status will reset after 24 hours.\n\n"
|
||||
msg += "Wallet address:\n0x9858effd232b4033e47d90003d41ec34ecaeda94\n\nNonce:\n2b02c8a0-f74f-4554-9821-a28054dc9121"
|
||||
common(backend, scenario_navigator, test_name, default_screenshot_path, msg)
|
||||
common(backend, scenario_navigator, test_name, msg)
|
||||
|
||||
|
||||
def test_personal_sign_reject(firmware: Firmware,
|
||||
backend: BackendInterface,
|
||||
scenario_navigator: NavigateWithScenario,
|
||||
test_name: str,
|
||||
default_screenshot_path: Path):
|
||||
scenario_navigator: NavigateWithScenario):
|
||||
|
||||
msg = "This is an reject sign"
|
||||
|
||||
@@ -82,11 +75,11 @@ def test_personal_sign_reject(firmware: Firmware,
|
||||
|
||||
try:
|
||||
with app_client.personal_sign(BIP32_PATH, msg.encode('utf-8')):
|
||||
if firmware.device.startswith("nano"):
|
||||
if firmware.is_nano:
|
||||
end_text = "Cancel"
|
||||
else:
|
||||
end_text = "Sign"
|
||||
scenario_navigator.review_reject(default_screenshot_path, test_name, end_text)
|
||||
scenario_navigator.review_reject(custom_screen_text=end_text)
|
||||
|
||||
except ExceptionRAPDU as e:
|
||||
assert e.status == StatusWord.CONDITION_NOT_SATISFIED
|
||||
|
||||
Reference in New Issue
Block a user