From d574d9a4a12a5363de3b2ab0a95e1e3a501687e4 Mon Sep 17 00:00:00 2001 From: Charles-Edouard de la Vergne Date: Sun, 9 Jun 2024 19:30:23 +0200 Subject: [PATCH] Update usage of 'scenario_navigator' default parameters --- tests/functional_test.py | 26 +++++++++++++------------- tests/utils.py | 6 ++---- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/tests/functional_test.py b/tests/functional_test.py index 5ff899de..7438a9ff 100755 --- a/tests/functional_test.py +++ b/tests/functional_test.py @@ -15,13 +15,16 @@ from ragger.error import ExceptionRAPDU from .xrp import XRPClient, Errors from .utils import DEFAULT_PATH, DEFAULT_BIP32_PATH -from .utils import ROOT_SCREENSHOT_PATH, verify_ecdsa_secp256k1, verify_version +from .utils import verify_ecdsa_secp256k1, verify_version -def test_app_configuration(backend: BackendInterface, firmware: Firmware, navigator: Navigator): +def test_app_configuration(backend: BackendInterface, + firmware: Firmware, + navigator: Navigator, + default_screenshot_path: Path): xrp = XRPClient(backend, firmware, navigator) version = xrp.get_configuration() - verify_version(version) + verify_version(default_screenshot_path, version) def test_sign_too_large(backend: BackendInterface, firmware: Firmware, navigator: Navigator): @@ -70,11 +73,10 @@ def test_get_public_key_no_confirm(backend: BackendInterface, def test_get_public_key_confirm(backend: BackendInterface, firmware: Firmware, navigator: Navigator, - scenario_navigator: NavigateWithScenario, - test_name: str): + scenario_navigator: NavigateWithScenario): xrp = XRPClient(backend, firmware, navigator) with xrp.get_pubkey_confirm(): - scenario_navigator.address_review_approve(ROOT_SCREENSHOT_PATH, test_name) + scenario_navigator.address_review_approve() # Check the status (Asynchronous) reply = xrp.get_async_response() @@ -84,13 +86,12 @@ def test_get_public_key_confirm(backend: BackendInterface, def test_get_public_key_reject(backend: BackendInterface, firmware: Firmware, navigator: Navigator, - scenario_navigator: NavigateWithScenario, - test_name: str): + scenario_navigator: NavigateWithScenario): xrp = XRPClient(backend, firmware, navigator) with pytest.raises(ExceptionRAPDU) as err: with xrp.get_pubkey_confirm(): - scenario_navigator.address_review_reject(ROOT_SCREENSHOT_PATH, test_name) + scenario_navigator.address_review_reject() # Assert we have received a refusal assert err.value.status == Errors.SW_WRONG_ADDRESS @@ -100,8 +101,7 @@ def test_get_public_key_reject(backend: BackendInterface, def test_sign_reject(backend: BackendInterface, firmware: Firmware, navigator: Navigator, - scenario_navigator: NavigateWithScenario, - test_name: str): + scenario_navigator: NavigateWithScenario): xrp = XRPClient(backend, firmware, navigator) # pragma pylint: disable=line-too-long @@ -115,7 +115,7 @@ def test_sign_reject(backend: BackendInterface, # Send the APDU (Asynchronous) with pytest.raises(ExceptionRAPDU) as err: with xrp.sign(DEFAULT_BIP32_PATH + message): - scenario_navigator.review_reject(ROOT_SCREENSHOT_PATH, test_name) + scenario_navigator.review_reject() # Assert we have received a refusal assert err.value.status == Errors.SW_WRONG_ADDRESS @@ -144,7 +144,7 @@ def test_sign_valid_tx(backend: BackendInterface, else: text = "^Hold to sign$" with xrp.sign(DEFAULT_BIP32_PATH + tx): - scenario_navigator.review_approve(ROOT_SCREENSHOT_PATH, snapdir, text) + scenario_navigator.review_approve(test_name=snapdir, custom_screen_text=text) reply = xrp.get_async_response() assert reply and reply.status == Errors.SW_SUCCESS diff --git a/tests/utils.py b/tests/utils.py index 5e4ff1b2..17bc66a4 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -15,7 +15,6 @@ from ragger.bip import calculate_public_key_and_chaincode, CurveChoice -ROOT_SCREENSHOT_PATH = Path(__file__).parent.resolve() DEFAULT_PATH = "44'/144'/0'/0'/0" DEFAULT_BIP32_PATH = Bip32Path.build(DEFAULT_PATH) TX_PREFIX_SINGLE = [0x53, 0x54, 0x58, 0x00] @@ -55,12 +54,11 @@ def unpack_get_public_key_response(reply: bytes) -> Tuple[int, str, int, str]: return key_len, key_data.hex(), len(chain_data), chain_data.hex() -def verify_version(version: str) -> None: +def verify_version(root_path: Path, version: str) -> None: """ Verify the app version, based on defines in Makefile """ print(f"version: {version}") - parent = Path(ROOT_SCREENSHOT_PATH).parent.resolve() - makefile = f"{parent}/Makefile" + makefile = f"{root_path.parent.resolve()}/Makefile" print(f"{makefile}") with open(makefile, "r", encoding="utf-8") as f_p: lines = f_p.readlines()