diff --git a/tests/integration/nano/conftest.py b/tests/integration/nano/conftest.py index dddd236a7..1268f3d3e 100644 --- a/tests/integration/nano/conftest.py +++ b/tests/integration/nano/conftest.py @@ -22,7 +22,8 @@ import pytest from ragger.firmware import Firmware -from utils.app import TezosAppScreen, SpeculosTezosBackend, DEFAULT_SEED +from utils.account import Account, DEFAULT_ACCOUNT, DEFAULT_SEED +from utils.app import TezosAppScreen, SpeculosTezosBackend FIRMWARES: List[Firmware] = [ Firmware.NANOS, @@ -150,6 +151,12 @@ def seed(request) -> str: param = getattr(request, "param", None) return param.get("seed", DEFAULT_SEED) if param else DEFAULT_SEED +@pytest.fixture(scope="function") +def account(request) -> Account: + """Get `account` for pytest.""" + param = getattr(request, "param", None) + return param.get("account", DEFAULT_ACCOUNT) if param else DEFAULT_ACCOUNT + @pytest.fixture(scope="function") def backend(app_path: Path, firmware: Firmware, diff --git a/tests/integration/nano/test_public_key.py b/tests/integration/nano/test_public_key.py index 1670e5f7e..2484e75a5 100644 --- a/tests/integration/nano/test_public_key.py +++ b/tests/integration/nano/test_public_key.py @@ -21,7 +21,7 @@ import pytest from utils.account import Account, PublicKey, SigType -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen from utils.backend import StatusCode accounts = [ @@ -67,8 +67,8 @@ def test_provide_pk(app: TezosAppScreen, account: Account, snapshot_dir: Path): f"Expected public key {expected_public_key} but got {public_key}" -def test_reject_pk(app: TezosAppScreen, snapshot_dir: Path): +def test_reject_pk(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check reject pk behaviour""" with StatusCode.REJECT.expected(): - app.reject_public_key(DEFAULT_ACCOUNT, snap_path=snapshot_dir) + app.reject_public_key(account, snap_path=snapshot_dir) diff --git a/tests/integration/nano/test_sign/operations/test_sign_ballot.py b/tests/integration/nano/test_sign/operations/test_sign_ballot.py index c6ab3ad5c..39835e16d 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_ballot.py +++ b/tests/integration/nano/test_sign/operations/test_sign_ballot.py @@ -18,10 +18,11 @@ from pathlib import Path -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import Ballot -def test_sign_ballot(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_ballot(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing ballot""" message = Ballot( @@ -31,12 +32,12 @@ def test_sign_ballot(app: TezosAppScreen, snapshot_dir: Path): period = 32 ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_batched_operations.py b/tests/integration/nano/test_sign/operations/test_sign_batched_operations.py index 0b289d627..6875f8296 100644 --- a/tests/integration/nano/test_sign/operations/test_sign_batched_operations.py +++ b/tests/integration/nano/test_sign/operations/test_sign_batched_operations.py @@ -20,7 +20,8 @@ from conftest import requires_device -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import ( OperationGroup, Origination, @@ -29,7 +30,7 @@ ) @requires_device("nanos") -def test_nanos_regression_batched_ops(app: TezosAppScreen, snapshot_dir: Path): +def test_nanos_regression_batched_ops(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing batch operation""" app.toggle_expert_mode() @@ -57,18 +58,18 @@ def test_nanos_regression_batched_ops(app: TezosAppScreen, snapshot_dir: Path): ) ]) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) @requires_device("nanox") -def test_nanox_regression_batched_ops(app: TezosAppScreen, snapshot_dir: Path): +def test_nanox_regression_batched_ops(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing batch operation""" app.toggle_expert_mode() @@ -96,17 +97,17 @@ def test_nanox_regression_batched_ops(app: TezosAppScreen, snapshot_dir: Path): ) ]) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) -def test_sign_complex_operation(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_complex_operation(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing complex operation""" app.toggle_expert_mode() @@ -136,12 +137,12 @@ def test_sign_complex_operation(app: TezosAppScreen, snapshot_dir: Path): ) ]) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_delegation.py b/tests/integration/nano/test_sign/operations/test_sign_delegation.py index 75d3241ef..b777d0c5f 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_delegation.py +++ b/tests/integration/nano/test_sign/operations/test_sign_delegation.py @@ -18,10 +18,11 @@ from pathlib import Path -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import Delegation -def test_sign_delegation(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_delegation(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing delegation""" message = Delegation( @@ -33,12 +34,12 @@ def test_sign_delegation(app: TezosAppScreen, snapshot_dir: Path): delegate = 'tz1TmFPVZsGQ8MnrBJtnECJgkFUwLa6EWYDm' ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_failing_noop.py b/tests/integration/nano/test_sign/operations/test_sign_failing_noop.py index 609c9ef11..f1983ef53 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_failing_noop.py +++ b/tests/integration/nano/test_sign/operations/test_sign_failing_noop.py @@ -18,20 +18,21 @@ from pathlib import Path -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import FailingNoop -def test_sign_failing_noop(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_failing_noop(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing failing noop""" message = FailingNoop("9f09f2952d34528c733f94615cfc39bc555619fc550dd4a67ba2208ce8e867aa3d13a6ef99dfbe32c6974aa9a2150d21eca29c3349e59c13b9081f1c11b440ac4d3455dedbe4ee0de15a8af620d4c86247d9d132de1bb6da23d5ff9d8dffda22ba9a84") - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_increase_paid_storage.py b/tests/integration/nano/test_sign/operations/test_sign_increase_paid_storage.py index b18fc1703..69a456847 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_increase_paid_storage.py +++ b/tests/integration/nano/test_sign/operations/test_sign_increase_paid_storage.py @@ -18,10 +18,11 @@ from pathlib import Path -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import IncreasePaidStorage -def test_sign_increase_paid_storage(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_increase_paid_storage(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing increase paid storage""" message = IncreasePaidStorage( @@ -34,12 +35,12 @@ def test_sign_increase_paid_storage(app: TezosAppScreen, snapshot_dir: Path): destination = "KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT" ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_origination.py b/tests/integration/nano/test_sign/operations/test_sign_origination.py index 53a6a92f7..c3cc05b3a 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_origination.py +++ b/tests/integration/nano/test_sign/operations/test_sign_origination.py @@ -18,10 +18,11 @@ from pathlib import Path -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import Origination -def test_sign_origination(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_origination(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing origination""" app.toggle_expert_mode() @@ -37,12 +38,12 @@ def test_sign_origination(app: TezosAppScreen, snapshot_dir: Path): balance = 500000 ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_proposals.py b/tests/integration/nano/test_sign/operations/test_sign_proposals.py index 948182f71..2f81eb770 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_proposals.py +++ b/tests/integration/nano/test_sign/operations/test_sign_proposals.py @@ -18,10 +18,11 @@ from pathlib import Path -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import Proposals -def test_sign_proposals(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_proposals(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing proposals""" message = Proposals( @@ -33,12 +34,12 @@ def test_sign_proposals(app: TezosAppScreen, snapshot_dir: Path): period = 32 ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_register_global_constant.py b/tests/integration/nano/test_sign/operations/test_sign_register_global_constant.py index ef485011f..e30604297 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_register_global_constant.py +++ b/tests/integration/nano/test_sign/operations/test_sign_register_global_constant.py @@ -18,10 +18,11 @@ from pathlib import Path -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import RegisterGlobalConstant -def test_sign_register_global_constant(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_register_global_constant(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing register global constant""" app.toggle_expert_mode() @@ -35,12 +36,12 @@ def test_sign_register_global_constant(app: TezosAppScreen, snapshot_dir: Path): value = {'prim': 'Pair', 'args': [{'string': '1'}, {'int': 2}]} ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_reveal.py b/tests/integration/nano/test_sign/operations/test_sign_reveal.py index 05b2bfb83..48d1db68c 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_reveal.py +++ b/tests/integration/nano/test_sign/operations/test_sign_reveal.py @@ -18,10 +18,11 @@ from pathlib import Path -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import Reveal -def test_sign_reveal(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_reveal(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing reveal""" message = Reveal( @@ -33,12 +34,12 @@ def test_sign_reveal(app: TezosAppScreen, snapshot_dir: Path): public_key = 'edpkuXX2VdkdXzkN11oLCb8Aurdo1BTAtQiK8ZY9UPj2YMt3AHEpcY' ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_add_messages.py b/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_add_messages.py index 6a0372f7b..b91fdd592 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_add_messages.py +++ b/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_add_messages.py @@ -18,10 +18,11 @@ from pathlib import Path -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import ScRollupAddMessage -def test_sign_sc_rollup_add_messages(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_sc_rollup_add_messages(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing smart rollup add message""" message = ScRollupAddMessage( @@ -33,12 +34,12 @@ def test_sign_sc_rollup_add_messages(app: TezosAppScreen, snapshot_dir: Path): message = [bytes.fromhex('012345'), bytes.fromhex('67'), bytes.fromhex('89abcdef')] ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_execute_outbox_message.py b/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_execute_outbox_message.py index f391921a2..81e04a07f 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_execute_outbox_message.py +++ b/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_execute_outbox_message.py @@ -18,10 +18,11 @@ from pathlib import Path -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import ScRollupExecuteOutboxMessage -def test_sign_sc_rollup_execute_outbox_message(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_sc_rollup_execute_outbox_message(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing smart rollup execute outbox message""" app.toggle_expert_mode() @@ -37,12 +38,12 @@ def test_sign_sc_rollup_execute_outbox_message(app: TezosAppScreen, snapshot_dir output_proof = b'9f09f2952d34528c733f94615cfc39bc555619fc550dd4a67ba2208ce8e867aa3d13a6ef99dfbe32c6974aa9a2150d21eca29c3349e59c13b9081f1c11b440ac4d3455dedbe4ee0de15a8af620d4c86247d9d132de1bb6da23d5ff9d8dffda22ba9a84' ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_originate.py b/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_originate.py index 0e9e1c12a..3743adcf2 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_originate.py +++ b/tests/integration/nano/test_sign/operations/test_sign_sc_rollup_originate.py @@ -21,7 +21,8 @@ import pytest -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import ScRollupOriginate @@ -41,7 +42,7 @@ "with_whitelist", ], ) -def test_sign_sc_rollup_originate(app: TezosAppScreen, whitelist: Optional[List[str]], snapshot_dir: Path): +def test_sign_sc_rollup_originate(app: TezosAppScreen, account: Account, whitelist: Optional[List[str]], snapshot_dir: Path): """Check signing smart rollup originate""" app.toggle_expert_mode() @@ -58,12 +59,12 @@ def test_sign_sc_rollup_originate(app: TezosAppScreen, whitelist: Optional[List[ whitelist = whitelist ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_set_consensus_key.py b/tests/integration/nano/test_sign/operations/test_sign_set_consensus_key.py index 61d8db686..f385b90e9 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_set_consensus_key.py +++ b/tests/integration/nano/test_sign/operations/test_sign_set_consensus_key.py @@ -18,10 +18,11 @@ from pathlib import Path -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import UpdateConsensusKey -def test_sign_set_consensus_key(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_set_consensus_key(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing set consensus key""" message = UpdateConsensusKey( @@ -33,12 +34,12 @@ def test_sign_set_consensus_key(app: TezosAppScreen, snapshot_dir: Path): pk = "edpkuXX2VdkdXzkN11oLCb8Aurdo1BTAtQiK8ZY9UPj2YMt3AHEpcY" ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_set_deposit_limit.py b/tests/integration/nano/test_sign/operations/test_sign_set_deposit_limit.py index 4bda6ec6c..217917bd2 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_set_deposit_limit.py +++ b/tests/integration/nano/test_sign/operations/test_sign_set_deposit_limit.py @@ -18,10 +18,11 @@ from pathlib import Path -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import SetDepositLimit -def test_sign_set_deposit_limit(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_set_deposit_limit(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing set deposit limit""" message = SetDepositLimit( @@ -33,12 +34,12 @@ def test_sign_set_deposit_limit(app: TezosAppScreen, snapshot_dir: Path): limit = 20000 ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_transaction.py b/tests/integration/nano/test_sign/operations/test_sign_transaction.py index 18198cfc8..1575c16ff 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_transaction.py +++ b/tests/integration/nano/test_sign/operations/test_sign_transaction.py @@ -18,11 +18,12 @@ from pathlib import Path -from utils.app import ScreenText, TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import ScreenText, TezosAppScreen from utils.backend import StatusCode from utils.message import Transaction -def test_sign_transaction(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_transaction(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing transaction""" app.toggle_expert_mode() @@ -39,17 +40,17 @@ def test_sign_transaction(app: TezosAppScreen, snapshot_dir: Path): parameter = {'prim': 'CAR'} ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) -def test_reject_transaction(app: TezosAppScreen, snapshot_dir: Path): +def test_reject_transaction(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check reject transaction""" app.toggle_expert_mode() @@ -67,12 +68,12 @@ def test_reject_transaction(app: TezosAppScreen, snapshot_dir: Path): ) with StatusCode.REJECT.expected(): - app.reject_signing(DEFAULT_ACCOUNT, + app.reject_signing(account, message, with_hash=True, snap_path=snapshot_dir) -def test_sign_simple_transaction(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_simple_transaction(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check sign not complex transaction""" app.toggle_expert_mode() @@ -87,17 +88,17 @@ def test_sign_simple_transaction(app: TezosAppScreen, snapshot_dir: Path): amount = 10000 ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) -def test_too_complex_transaction(app: TezosAppScreen, snapshot_dir: Path): +def test_too_complex_transaction(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check sign complex transaction""" message = Transaction( @@ -114,13 +115,13 @@ def test_too_complex_transaction(app: TezosAppScreen, snapshot_dir: Path): with StatusCode.REJECT.expected(): app.sign( - DEFAULT_ACCOUNT, + account, message, with_hash=True, navigate=lambda: app.navigate_review(text=ScreenText.BACK_HOME, snap_path=snapshot_dir) ) -def test_sign_stake_transaction(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_stake_transaction(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check sign stake""" app.toggle_expert_mode() @@ -136,17 +137,17 @@ def test_sign_stake_transaction(app: TezosAppScreen, snapshot_dir: Path): entrypoint = 'stake', ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) -def test_sign_unstake_transaction(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_unstake_transaction(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check sign unstake""" app.toggle_expert_mode() @@ -162,17 +163,17 @@ def test_sign_unstake_transaction(app: TezosAppScreen, snapshot_dir: Path): entrypoint = 'unstake' ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) -def test_sign_finalize_unstake_transaction(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_finalize_unstake_transaction(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check sign finalize_unstake""" app.toggle_expert_mode() @@ -188,17 +189,17 @@ def test_sign_finalize_unstake_transaction(app: TezosAppScreen, snapshot_dir: Pa entrypoint = 'finalize_unstake' ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) -def test_sign_set_delegate_parameters_transaction(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_set_delegate_parameters_transaction(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check sign set delegate parameters""" app.toggle_expert_mode() @@ -223,17 +224,17 @@ def test_sign_set_delegate_parameters_transaction(app: TezosAppScreen, snapshot_ ]} ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) -def test_sign_with_long_hash(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_with_long_hash(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing transaction with a long destination hash""" app.toggle_expert_mode() @@ -250,17 +251,17 @@ def test_sign_with_long_hash(app: TezosAppScreen, snapshot_dir: Path): parameter = {'int': 0} ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) -def test_ensure_always_clearsign(app: TezosAppScreen, snapshot_dir: Path): +def test_ensure_always_clearsign(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check clear signing never blindsign""" app.toggle_expert_mode() @@ -277,12 +278,12 @@ def test_ensure_always_clearsign(app: TezosAppScreen, snapshot_dir: Path): parameter = [{'prim':'pair','args':[{'string':"["},{'prim':'pair','args':[{'string':"Z"},{'prim':'pair','args':[{'string':"Y"},{'prim':'pair','args':[{'string':"X"},{'prim':'pair','args':[{'string':"W"},{'prim':'pair','args':[{'string':"V"},{'prim':'pair','args':[{'string':"U"},{'prim':'pair','args':[{'string':"T"},{'prim':'pair','args':[{'string':"S"},{'prim':'pair','args':[{'string':"R"},{'prim':'pair','args':[{'string':"Q"},{'prim':'pair','args':[{'string':"P"},{'prim':'pair','args':[{'string':"O"},{'prim':'pair','args':[{'string':"N"},{'prim':'pair','args':[{'string':"M"},{'prim':'pair','args':[{'string':"L"},{'prim':'pair','args':[{'string':"K"},{'prim':'pair','args':[{'string':"J"},{'prim':'pair','args':[{'string':"I"},{'prim':'pair','args':[{'string':"H"},{'prim':'pair','args':[{'string':"G"},{'prim':'pair','args':[{'string':"F"},{'prim':'pair','args':[{'string':"E"},{'prim':'pair','args':[{'string':"D"},{'prim':'pair','args':[{'string':"C"},{'prim':'pair','args':[{'string':"B"},[]]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]},{'prim':'pair','args':[{'int':10},{'prim':'pair','args':[{'int':9},{'prim':'pair','args':[{'int':8},{'prim':'pair','args':[{'int':7},{'prim':'pair','args':[{'int':6},{'prim':'pair','args':[{'int':5},{'prim':'pair','args':[{'int':4},{'prim':'pair','args':[{'int':3},{'prim':'pair','args':[{'int':2},{'prim':'pair','args':[{'int':1},[]]}]}]}]}]}]}]}]}]}]}] ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/operations/test_sign_transfer_ticket.py b/tests/integration/nano/test_sign/operations/test_sign_transfer_ticket.py index 6ba362b2a..7b205f289 100755 --- a/tests/integration/nano/test_sign/operations/test_sign_transfer_ticket.py +++ b/tests/integration/nano/test_sign/operations/test_sign_transfer_ticket.py @@ -19,10 +19,11 @@ from pathlib import Path from conftest import requires_device -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import TezosAppScreen from utils.message import TransferTicket -def test_sign_transfer_ticket(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_transfer_ticket(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing transfer ticket""" app.toggle_expert_mode() @@ -40,18 +41,18 @@ def test_sign_transfer_ticket(app: TezosAppScreen, snapshot_dir: Path): destination = 'KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT' ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) @requires_device("nanosp") -def test_nanosp_regression_potential_empty_screen(app: TezosAppScreen, snapshot_dir: Path): +def test_nanosp_regression_potential_empty_screen(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing operation that display potentially empty screens""" app.toggle_expert_mode() @@ -70,12 +71,12 @@ def test_nanosp_regression_potential_empty_screen(app: TezosAppScreen, snapshot_ entrypoint = 'S\n\nS\nS\nS' ) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=True, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) diff --git a/tests/integration/nano/test_sign/test_apdu_sign.py b/tests/integration/nano/test_sign/test_apdu_sign.py index c7506ec0d..353c03ead 100644 --- a/tests/integration/nano/test_sign/test_apdu_sign.py +++ b/tests/integration/nano/test_sign/test_apdu_sign.py @@ -20,25 +20,25 @@ from conftest import requires_device from utils.account import Account -from utils.app import send_and_navigate, ScreenText, TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import send_and_navigate, ScreenText, TezosAppScreen from utils.message import Message, MichelineExpr, Transaction -def test_sign_micheline_without_hash(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_micheline_without_hash(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing micheline wihout getting hash""" message = MichelineExpr([{'string': 'CACA'}, {'string': 'POPO'}, {'string': 'BOUDIN'}]) - data = app.sign(DEFAULT_ACCOUNT, + data = app.sign(account, message, with_hash=False, snap_path=snapshot_dir) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=False, data=data) -def test_sign_with_small_packet(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_with_small_packet(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check signing using small packet instead of full size packets""" app.toggle_expert_mode() @@ -71,22 +71,22 @@ def check_sign_with_small_packet( ) check_sign_with_small_packet( - account=DEFAULT_ACCOUNT, + account=account, message=message, path=snapshot_dir) @requires_device("nanosp") -def test_nanosp_regression_press_right_works_across_apdu_recieves(app: TezosAppScreen, snapshot_dir: Path): +def test_nanosp_regression_press_right_works_across_apdu_recieves(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check no need to click right two times between APDUs during signing flow""" message = MichelineExpr([{'prim':'IF_NONE','args':[[[{'prim':'SWAP'},{'prim':'IF','args':[[{'prim':'DIP','args':[[[{'prim':'DROP','args':[{'int':1}]},{'prim':'PUSH','args':[{'prim':'unit'},{'prim':'Unit'}]},{'prim':'PUSH','args':[{'prim':'bool'},{'prim':'True'}]},{'prim':'PUSH','args':[{'prim':'string'},{'string':';L\\S?p$-Fq)VDg\n]te\no4v0_8)\"'}]}]]]}],[[{'prim':'DROP','args':[{'int':2}]},{'prim':'PUSH','args':[{'prim':'unit'},{'prim':'Unit'}]},{'prim':'PUSH','args':[{'prim':'bool'},{'prim':'False'}]},{'prim':'PUSH','args':[{'prim':'string'},{'string':'Li-%*edF6~?E[5Kmu?dyviwJ^2\"\\d$FyQ>>!>D$g(Qg'}]},{'prim':'PUSH','args':[{'prim':'string'},{'string':'*Tx None: app.navigate_review(text=ScreenText.ACCEPT_RISK, snap_path=path / "clear_n_too_long_warning") app.navigate_review(text=ScreenText.SIGN_ACCEPT, snap_path=path / "summary") - _sign_too_long(app, message, navigate) + _sign_too_long(app, account, message, navigate) def _reject_too_long( app: TezosAppScreen, + account: Account, message: Message, status_code: StatusCode, navigate: Callable[[], None]): @@ -78,7 +82,7 @@ def _reject_too_long( with status_code.expected(): app.sign( - DEFAULT_ACCOUNT, + account, message, with_hash=True, navigate=navigate @@ -154,31 +158,31 @@ def _reject_too_long( ) ]) -def test_sign_basic_too_long_operation(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_basic_too_long_operation(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check sign too long operation""" - _sign_decodable_too_long(app, BASIC_OPERATION, snapshot_dir) + _sign_decodable_too_long(app, account, BASIC_OPERATION, snapshot_dir) -def test_reject_basic_too_long_operation_at_warning(app: TezosAppScreen, snapshot_dir: Path): +def test_reject_basic_too_long_operation_at_warning(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check reject too long operation at warning""" def navigate() -> None: app.navigate_review(text=ScreenText.SIGN_REJECT, snap_path=snapshot_dir / "clear_n_too_long_warning") - _reject_too_long(app, BASIC_OPERATION, StatusCode.REJECT, navigate) + _reject_too_long(app, account, BASIC_OPERATION, StatusCode.REJECT, navigate) -def test_reject_basic_too_long_operation_at_summary(app: TezosAppScreen, snapshot_dir: Path): +def test_reject_basic_too_long_operation_at_summary(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check reject too long operation at summary""" def navigate() -> None: app.navigate_review(text=ScreenText.ACCEPT_RISK, snap_path=snapshot_dir / "clear_n_too_long_warning") app.navigate_review(text=ScreenText.SIGN_REJECT, snap_path=snapshot_dir / "summary") - _reject_too_long(app, BASIC_OPERATION, StatusCode.REJECT, navigate) + _reject_too_long(app, account, BASIC_OPERATION, StatusCode.REJECT, navigate) ### Different kind of too long operation ### -def test_sign_too_long_operation_with_only_transactions(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_too_long_operation_with_only_transactions(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check sign too long operation that contains only transaction""" message = OperationGroup([ Transaction( @@ -236,9 +240,9 @@ def test_sign_too_long_operation_with_only_transactions(app: TezosAppScreen, sna amount = 5000000 ) ]) - _sign_decodable_too_long(app, message, snapshot_dir) + _sign_decodable_too_long(app, account, message, snapshot_dir) -def test_sign_too_long_operation_without_fee_or_amount(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_too_long_operation_without_fee_or_amount(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check sign too long operation that doesn't have fees or amount""" message = Proposals( source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', @@ -266,7 +270,7 @@ def test_sign_too_long_operation_without_fee_or_amount(app: TezosAppScreen, snap ], period = 32 ) - _sign_decodable_too_long(app, message, snapshot_dir) + _sign_decodable_too_long(app, account, message, snapshot_dir) ### Too long operation containing a too large number ### @@ -321,33 +325,33 @@ def test_sign_too_long_operation_without_fee_or_amount(app: TezosAppScreen, snap ) ]) -def test_sign_too_long_operation_with_too_large(app: TezosAppScreen, snapshot_dir: Path): +def test_sign_too_long_operation_with_too_large(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check sign too long operation that will also fail the parsing""" def navigate() -> None: app.navigate_review(text=ScreenText.ACCEPT_RISK, snap_path=snapshot_dir / "clear_n_too_large_warning") app.navigate_review(text=ScreenText.SIGN_ACCEPT, snap_path=snapshot_dir / "blindsigning") - _sign_too_long(app, OPERATION_WITH_TOO_LARGE, navigate) + _sign_too_long(app, account, OPERATION_WITH_TOO_LARGE, navigate) -def test_reject_too_long_operation_with_too_large_at_too_large_warning(app: TezosAppScreen, snapshot_dir: Path): +def test_reject_too_long_operation_with_too_large_at_too_large_warning(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check reject too long operation that will also fail the parsing at too large warning""" def navigate() -> None: app.navigate_review(text=ScreenText.SIGN_REJECT, snap_path=snapshot_dir / "clear_n_too_large_warning") - _reject_too_long(app, OPERATION_WITH_TOO_LARGE, StatusCode.PARSE_ERROR, navigate) + _reject_too_long(app, account, OPERATION_WITH_TOO_LARGE, StatusCode.PARSE_ERROR, navigate) -def test_reject_too_long_operation_with_too_large_at_blindsigning(app: TezosAppScreen, snapshot_dir: Path): +def test_reject_too_long_operation_with_too_large_at_blindsigning(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check reject too long operation that will also fail the parsing at blindsigning""" def navigate() -> None: app.navigate_review(text=ScreenText.ACCEPT_RISK, snap_path=snapshot_dir / "clear_n_too_large_warning") app.navigate_review(text=ScreenText.SIGN_REJECT, snap_path=snapshot_dir / "blindsigning") - _reject_too_long(app, OPERATION_WITH_TOO_LARGE, StatusCode.REJECT, navigate) + _reject_too_long(app, account, OPERATION_WITH_TOO_LARGE, StatusCode.REJECT, navigate) -def test_blindsign_too_deep(app: TezosAppScreen, snapshot_dir: Path): +def test_blindsign_too_deep(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check blindsigning on too deep expression""" expression = MichelineExpr([[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{'int':42}]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) @@ -379,18 +383,18 @@ def navigate() -> None: app.navigate_review(text=ScreenText.SIGN_ACCEPT, snap_path=snapshot_dir / "blind") data = app.sign( - DEFAULT_ACCOUNT, + account, expression, with_hash=True, navigate=navigate ) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=expression, with_hash=True, data=data) -def test_blindsign_too_large(app: TezosAppScreen, snapshot_dir: Path): +def test_blindsign_too_large(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check blindsigning on too large expression""" message = MichelineExpr({'int':12345678901234567890123456789012345678901234567890123456789012345678901234567890}) @@ -400,31 +404,31 @@ def navigate() -> None: app.navigate_review(text=ScreenText.SIGN_ACCEPT, snap_path=snapshot_dir / "blind") data = app.sign( - DEFAULT_ACCOUNT, + account, message, with_hash=True, navigate=navigate ) - DEFAULT_ACCOUNT.check_signature( + account.check_signature( message=message, with_hash=True, data=data) -def test_blindsign_reject_from_clear(app: TezosAppScreen, snapshot_dir: Path): +def test_blindsign_reject_from_clear(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check blindsigning rejection""" expression = MichelineExpr({'int':12345678901234567890123456789012345678901234567890123456789012345678901234567890}) with StatusCode.PARSE_ERROR.expected(): app.reject_signing( - DEFAULT_ACCOUNT, + account, expression, with_hash=False, snap_path=snapshot_dir ) -def test_blindsign_reject_from_blind(app: TezosAppScreen, snapshot_dir: Path): +def test_blindsign_reject_from_blind(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check blindsigning rejection""" expression = MichelineExpr({'int':12345678901234567890123456789012345678901234567890123456789012345678901234567890}) @@ -435,7 +439,7 @@ def navigate() -> None: with StatusCode.REJECT.expected(): app.sign( - DEFAULT_ACCOUNT, + account, expression, with_hash=False, navigate=navigate diff --git a/tests/integration/nano/test_sign/test_parsing_errors.py b/tests/integration/nano/test_sign/test_parsing_errors.py index 6cddb4d15..766df7453 100755 --- a/tests/integration/nano/test_sign/test_parsing_errors.py +++ b/tests/integration/nano/test_sign/test_parsing_errors.py @@ -20,7 +20,8 @@ import pytest -from utils.app import ScreenText, TezosAppScreen, DEFAULT_ACCOUNT +from utils.account import Account +from utils.app import ScreenText, TezosAppScreen from utils.backend import StatusCode from utils.message import RawMessage @@ -53,14 +54,14 @@ "one_byte_added_inside", ] ) -def test_parsing_error(app: TezosAppScreen, raw_msg: str, snapshot_dir: Path): +def test_parsing_error(app: TezosAppScreen, raw_msg: str, account: Account, snapshot_dir: Path): """Check parsing error handling""" app.toggle_expert_mode() with StatusCode.PARSE_ERROR.expected(): app.reject_signing( - DEFAULT_ACCOUNT, + account, RawMessage(raw_msg), with_hash=True, snap_path=snapshot_dir @@ -74,14 +75,14 @@ def test_parsing_error(app: TezosAppScreen, raw_msg: str, snapshot_dir: Path): "wrong_last_packet", ] ) -def test_parsing_hard_fail(app: TezosAppScreen, raw_msg: str, snapshot_dir: Path): +def test_parsing_hard_fail(app: TezosAppScreen, raw_msg: str, account: Account, snapshot_dir: Path): """Check parsing error hard failing""" app.toggle_expert_mode() with StatusCode.UNEXPECTED_SIGN_STATE.expected(): app.sign( - DEFAULT_ACCOUNT, + account, RawMessage(raw_msg), with_hash=True, navigate=lambda: app.navigate_review( diff --git a/tests/integration/nano/test_wrong_apdu.py b/tests/integration/nano/test_wrong_apdu.py index 13e15c872..7715ae6a8 100644 --- a/tests/integration/nano/test_wrong_apdu.py +++ b/tests/integration/nano/test_wrong_apdu.py @@ -22,17 +22,17 @@ import pytest from utils.account import Account, SigType -from utils.app import TezosAppScreen, DEFAULT_ACCOUNT +from utils.app import TezosAppScreen from utils.backend import Cla, Index, Ins, StatusCode from utils.message import Transaction -def test_regression_continue_after_reject(app: TezosAppScreen, snapshot_dir: Path): +def test_regression_continue_after_reject(app: TezosAppScreen, account: Account, snapshot_dir: Path): """Check the app still runs after rejects signing""" app.toggle_expert_mode() with StatusCode.REJECT.expected(): - app.reject_public_key(DEFAULT_ACCOUNT, snap_path=snapshot_dir / "reject_public_key") + app.reject_public_key(account, snap_path=snapshot_dir / "reject_public_key") app.backend.wait_for_home_screen() @@ -49,15 +49,15 @@ def test_regression_continue_after_reject(app: TezosAppScreen, snapshot_dir: Pat ) with StatusCode.REJECT.expected(): - app.reject_signing(DEFAULT_ACCOUNT, + app.reject_signing(account, message, with_hash=True, snap_path=snapshot_dir / "reject_signing") - app.backend.get_public_key(DEFAULT_ACCOUNT, with_prompt=False) + app.backend.get_public_key(account, with_prompt=False) -def test_change_sign_instruction(app: TezosAppScreen): +def test_change_sign_instruction(app: TezosAppScreen, account: Account): """Check signing instruction changes behaviour""" message = Transaction( @@ -73,57 +73,57 @@ def test_change_sign_instruction(app: TezosAppScreen): ) payload=bytes(message) - app.backend._ask_sign(Ins.SIGN_WITH_HASH, DEFAULT_ACCOUNT) + app.backend._ask_sign(Ins.SIGN_WITH_HASH, account) with StatusCode.INVALID_INS.expected(): app.backend._continue_sign(Ins.SIGN, payload, last=True) - app.backend._ask_sign(Ins.SIGN, DEFAULT_ACCOUNT) + app.backend._ask_sign(Ins.SIGN, account) with StatusCode.INVALID_INS.expected(): app.backend._continue_sign(Ins.SIGN_WITH_HASH, payload, last=True) -def test_mixing_command(app: TezosAppScreen): +def test_mixing_command(app: TezosAppScreen, account: Account): """Check that mixing instruction fails""" - app.backend._ask_sign(Ins.SIGN, DEFAULT_ACCOUNT) + app.backend._ask_sign(Ins.SIGN, account) with StatusCode.UNEXPECTED_STATE.expected(): app.backend.version() - app.backend._ask_sign(Ins.SIGN_WITH_HASH, DEFAULT_ACCOUNT) + app.backend._ask_sign(Ins.SIGN_WITH_HASH, account) with StatusCode.UNEXPECTED_STATE.expected(): - app.backend._ask_sign(Ins.SIGN, DEFAULT_ACCOUNT) + app.backend._ask_sign(Ins.SIGN, account) - app.backend._ask_sign(Ins.SIGN, DEFAULT_ACCOUNT) + app.backend._ask_sign(Ins.SIGN, account) with StatusCode.UNEXPECTED_STATE.expected(): - app.backend._ask_sign(Ins.SIGN_WITH_HASH, DEFAULT_ACCOUNT) + app.backend._ask_sign(Ins.SIGN_WITH_HASH, account) - app.backend._ask_sign(Ins.SIGN, DEFAULT_ACCOUNT) + app.backend._ask_sign(Ins.SIGN, account) with StatusCode.UNEXPECTED_STATE.expected(): - app.backend.get_public_key(DEFAULT_ACCOUNT, with_prompt=True) + app.backend.get_public_key(account, with_prompt=True) - app.backend._ask_sign(Ins.SIGN, DEFAULT_ACCOUNT) + app.backend._ask_sign(Ins.SIGN, account) with StatusCode.UNEXPECTED_STATE.expected(): - app.backend.get_public_key(DEFAULT_ACCOUNT, with_prompt=False) + app.backend.get_public_key(account, with_prompt=False) - app.backend._ask_sign(Ins.SIGN, DEFAULT_ACCOUNT) + app.backend._ask_sign(Ins.SIGN, account) with StatusCode.UNEXPECTED_STATE.expected(): app.backend.git() @pytest.mark.parametrize("ins", [Ins.GET_PUBLIC_KEY, Ins.PROMPT_PUBLIC_KEY], ids=lambda ins: f"{ins}") @pytest.mark.parametrize("index", [Index.OTHER, Index.LAST], ids=lambda index: f"{index}") -def test_wrong_index(app: TezosAppScreen, ins: Ins, index: Index): +def test_wrong_index(app: TezosAppScreen, account: Account, ins: Ins, index: Index): """Check wrong apdu index behaviour""" with StatusCode.WRONG_PARAM.expected(): app.backend._exchange(ins, index=index, - sig_type=DEFAULT_ACCOUNT.sig_type, - payload=DEFAULT_ACCOUNT.path) + sig_type=account.sig_type, + payload=account.path) @pytest.mark.parametrize( diff --git a/tests/integration/nano/utils/account.py b/tests/integration/nano/utils/account.py index 5544b1789..6fd077c80 100644 --- a/tests/integration/nano/utils/account.py +++ b/tests/integration/nano/utils/account.py @@ -194,3 +194,12 @@ def check_signature( f"Fail to verify signature {signature!r}, \n\ with account {self} \n\ and message {message}" + + +DEFAULT_SEED = ' '.join(['zebra']*24) + +DEFAULT_ACCOUNT = Account( + "m/44'/1729'/0'/0'", + SigType.ED25519, + "edpkuXX2VdkdXzkN11oLCb8Aurdo1BTAtQiK8ZY9UPj2YMt3AHEpcY" +) diff --git a/tests/integration/nano/utils/app.py b/tests/integration/nano/utils/app.py index 571f8902b..ce64a14d8 100644 --- a/tests/integration/nano/utils/app.py +++ b/tests/integration/nano/utils/app.py @@ -324,9 +324,3 @@ def reject_signing(self, def navigate(): self.navigate_review(text=ScreenText.SIGN_REJECT, **kwargs) self.sign(account, message, with_hash, navigate) - -DEFAULT_SEED = 'zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra zebra' - -DEFAULT_ACCOUNT = Account("m/44'/1729'/0'/0'", - SigType.ED25519, - "edpkuXX2VdkdXzkN11oLCb8Aurdo1BTAtQiK8ZY9UPj2YMt3AHEpcY")