Skip to content

Commit

Permalink
[test] use navigator instead of assert_screen
Browse files Browse the repository at this point in the history
  • Loading branch information
spalmer25 committed Dec 12, 2024
1 parent 1ead502 commit c4b1268
Show file tree
Hide file tree
Showing 138 changed files with 221 additions and 237 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 63 additions & 64 deletions tests/integration/nano/test_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,68 +16,67 @@

"""Gathering of tests related to app menu."""

from utils.app import Screen, TezosAppScreen

def test_menu(app: TezosAppScreen):
"""Check main menu flow"""
app.assert_screen(Screen.HOME)
app.backend.right_click()
app.assert_screen(Screen.VERSION)
app.backend.both_click()
app.assert_screen(Screen.VERSION)
app.backend.right_click()
app.assert_screen(Screen.SETTINGS)
app.backend.right_click()
app.assert_screen(Screen.QUIT)
app.backend.left_click()
app.assert_screen(Screen.SETTINGS)
app.backend.left_click()
app.assert_screen(Screen.VERSION)
app.backend.left_click()
app.assert_screen(Screen.HOME)
app.backend.both_click()
app.assert_screen(Screen.HOME)
app.backend.left_click()
app.assert_screen(Screen.QUIT)
app.backend.right_click()
app.assert_screen(Screen.HOME)
app.backend.right_click()
app.assert_screen(Screen.VERSION)
app.backend.right_click()
app.assert_screen(Screen.SETTINGS)
app.backend.right_click()
app.assert_screen(Screen.QUIT)
app.backend.right_click()
app.assert_screen(Screen.HOME)
app.backend.right_click()
app.assert_screen(Screen.VERSION)

# Check Settings menu operation
app.backend.right_click()
app.assert_screen(Screen.SETTINGS)
app.backend.both_click()
app.assert_screen(Screen.SETTINGS_EXPERT_MODE_DISABLED)
app.backend.both_click()
app.assert_screen(Screen.SETTINGS_EXPERT_MODE_ENABLED)
app.backend.right_click()
app.assert_screen(Screen.SETTINGS_BLINDSIGN_OFF)
app.backend.both_click()
app.assert_screen(Screen.SETTINGS_BLINDSIGN_ON)
app.backend.both_click()
app.assert_screen(Screen.SETTINGS_BLINDSIGN_OFF)
app.backend.right_click()
app.assert_screen(Screen.SETTINGS_BACK)
app.backend.left_click()
app.assert_screen(Screen.SETTINGS_BLINDSIGN_OFF)
app.backend.left_click()
app.assert_screen(Screen.SETTINGS_EXPERT_MODE_ENABLED)
app.backend.left_click()
app.assert_screen(Screen.SETTINGS_BACK)
app.backend.right_click()
app.assert_screen(Screen.SETTINGS_EXPERT_MODE_ENABLED)
app.backend.left_click()
app.assert_screen(Screen.SETTINGS_BACK)
app.backend.both_click()
app.assert_screen(Screen.HOME)
from pathlib import Path
from typing import List, Union

import requests

from ragger.navigator import NavIns, NavInsID

from utils.backend import TezosBackend
from utils.app import TezosAppScreen


def test_home_menu(app: TezosAppScreen, snapshot_dir: Path):
"""Check home menu flow"""
instructions: List[Union[NavIns, NavInsID]] = [
# Home
NavInsID.RIGHT_CLICK, # Version
NavInsID.RIGHT_CLICK, # Settings
NavInsID.RIGHT_CLICK, # Quit
]
app.navigate(
instructions=instructions,
snap_path=snapshot_dir,
)


def test_settings_menu(app: TezosAppScreen, snapshot_dir: Path):
"""Check settings menu flow"""
app.navigate_to_settings()
instructions: List[Union[NavIns, NavInsID]] = [
# Expert Mode
NavInsID.RIGHT_CLICK, # Blind Sign
NavInsID.RIGHT_CLICK, # Back
NavInsID.BOTH_CLICK, # Home
]
app.navigate(
instructions=instructions,
snap_path=snapshot_dir
)


def test_toggle_expert_mode(app: TezosAppScreen, snapshot_dir: Path):
"""Check settings' expert_mode toggle"""
snap_idx = app.toggle_expert_mode(snap_path=snapshot_dir)
# Toggle back
app.toggle_expert_mode(snap_start_idx=snap_idx, snap_path=snapshot_dir)


def test_toggle_blindsign(app: TezosAppScreen, snapshot_dir: Path):
"""Check settings' blindsign toggle"""
snap_idx = app.toggle_blindsign(snap_path=snapshot_dir)
# Toggle back
app.toggle_blindsign(snap_start_idx=snap_idx, snap_path=snapshot_dir)


def test_quit(app: TezosAppScreen):
"""Check quit app"""
# Home
app.backend.left_click()
app._quit()
app.backend.wait_for_screen_change() # Quit
try:
app.backend.both_click()
assert False, "Must have lost connection with speculos"
except requests.exceptions.ConnectionError:
pass
2 changes: 1 addition & 1 deletion tests/integration/nano/test_public_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import pytest

from utils.account import Account, PublicKey, SigType
from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT
from utils.app import TezosAppScreen, DEFAULT_ACCOUNT
from utils.backend import StatusCode

accounts = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pathlib import Path

from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT
from utils.app import TezosAppScreen, DEFAULT_ACCOUNT
from utils.message import Ballot

def test_sign_ballot(app: TezosAppScreen, snapshot_dir: Path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from conftest import requires_device

from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT
from utils.app import TezosAppScreen, DEFAULT_ACCOUNT
from utils.message import (
OperationGroup,
Origination,
Expand All @@ -32,7 +32,7 @@
def test_nanos_regression_batched_ops(app: TezosAppScreen, snapshot_dir: Path):
"""Check signing batch operation"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = OperationGroup([
Transaction(
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_nanos_regression_batched_ops(app: TezosAppScreen, snapshot_dir: Path):
def test_nanox_regression_batched_ops(app: TezosAppScreen, snapshot_dir: Path):
"""Check signing batch operation"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = OperationGroup([
Transaction(
Expand Down Expand Up @@ -109,7 +109,7 @@ def test_nanox_regression_batched_ops(app: TezosAppScreen, snapshot_dir: Path):
def test_sign_complex_operation(app: TezosAppScreen, snapshot_dir: Path):
"""Check signing complex operation"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = OperationGroup([
Origination(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pathlib import Path

from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT
from utils.app import TezosAppScreen, DEFAULT_ACCOUNT
from utils.message import Delegation

def test_sign_delegation(app: TezosAppScreen, snapshot_dir: Path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pathlib import Path

from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT
from utils.app import TezosAppScreen, DEFAULT_ACCOUNT
from utils.message import FailingNoop

def test_sign_failing_noop(app: TezosAppScreen, snapshot_dir: Path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pathlib import Path

from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT
from utils.app import TezosAppScreen, DEFAULT_ACCOUNT
from utils.message import IncreasePaidStorage

def test_sign_increase_paid_storage(app: TezosAppScreen, snapshot_dir: Path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
def test_sign_origination(app: TezosAppScreen, snapshot_dir: Path):
"""Check signing origination"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = Origination(
source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pathlib import Path

from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT
from utils.app import TezosAppScreen, DEFAULT_ACCOUNT
from utils.message import Proposals

def test_sign_proposals(app: TezosAppScreen, snapshot_dir: Path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
def test_sign_register_global_constant(app: TezosAppScreen, snapshot_dir: Path):
"""Check signing register global constant"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = RegisterGlobalConstant(
source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pathlib import Path

from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT
from utils.app import TezosAppScreen, DEFAULT_ACCOUNT
from utils.message import Reveal

def test_sign_reveal(app: TezosAppScreen, snapshot_dir: Path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pathlib import Path

from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT
from utils.app import TezosAppScreen, DEFAULT_ACCOUNT
from utils.message import ScRollupAddMessage

def test_sign_sc_rollup_add_messages(app: TezosAppScreen, snapshot_dir: Path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
def test_sign_sc_rollup_execute_outbox_message(app: TezosAppScreen, snapshot_dir: Path):
"""Check signing smart rollup execute outbox message"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = ScRollupExecuteOutboxMessage(
source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
def test_sign_sc_rollup_originate(app: TezosAppScreen, whitelist: Optional[List[str]], snapshot_dir: Path):
"""Check signing smart rollup originate"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = ScRollupOriginate(
source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pathlib import Path

from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT
from utils.app import TezosAppScreen, DEFAULT_ACCOUNT
from utils.message import UpdateConsensusKey

def test_sign_set_consensus_key(app: TezosAppScreen, snapshot_dir: Path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pathlib import Path

from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT
from utils.app import TezosAppScreen, DEFAULT_ACCOUNT
from utils.message import SetDepositLimit

def test_sign_set_deposit_limit(app: TezosAppScreen, snapshot_dir: Path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

from pathlib import Path

from utils.app import Screen, ScreenText, TezosAppScreen, DEFAULT_ACCOUNT
from utils.app import ScreenText, TezosAppScreen, DEFAULT_ACCOUNT
from utils.backend import StatusCode
from utils.message import Transaction

def test_sign_transaction(app: TezosAppScreen, snapshot_dir: Path):
"""Check signing transaction"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = Transaction(
source = 'tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu',
Expand All @@ -52,7 +52,7 @@ def test_sign_transaction(app: TezosAppScreen, snapshot_dir: Path):
def test_reject_transaction(app: TezosAppScreen, snapshot_dir: Path):
"""Check reject transaction"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = Transaction(
source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa',
Expand All @@ -75,7 +75,7 @@ def test_reject_transaction(app: TezosAppScreen, snapshot_dir: Path):
def test_sign_simple_transaction(app: TezosAppScreen, snapshot_dir: Path):
"""Check sign not complex transaction"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = Transaction(
source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa',
Expand Down Expand Up @@ -123,7 +123,7 @@ def test_too_complex_transaction(app: TezosAppScreen, snapshot_dir: Path):
def test_sign_stake_transaction(app: TezosAppScreen, snapshot_dir: Path):
"""Check sign stake"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = Transaction(
source = 'tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W',
Expand All @@ -149,7 +149,7 @@ def test_sign_stake_transaction(app: TezosAppScreen, snapshot_dir: Path):
def test_sign_unstake_transaction(app: TezosAppScreen, snapshot_dir: Path):
"""Check sign unstake"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = Transaction(
source = 'tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W',
Expand All @@ -175,7 +175,7 @@ def test_sign_unstake_transaction(app: TezosAppScreen, snapshot_dir: Path):
def test_sign_finalize_unstake_transaction(app: TezosAppScreen, snapshot_dir: Path):
"""Check sign finalize_unstake"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = Transaction(
source = 'tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W',
Expand All @@ -201,7 +201,7 @@ def test_sign_finalize_unstake_transaction(app: TezosAppScreen, snapshot_dir: Pa
def test_sign_set_delegate_parameters_transaction(app: TezosAppScreen, snapshot_dir: Path):
"""Check sign set delegate parameters"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = Transaction(
source = 'tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W',
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_sign_set_delegate_parameters_transaction(app: TezosAppScreen, snapshot_
def test_sign_with_long_hash(app: TezosAppScreen, snapshot_dir: Path):
"""Check signing transaction with a long destination hash"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = Transaction(
source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa',
Expand All @@ -263,7 +263,7 @@ def test_sign_with_long_hash(app: TezosAppScreen, snapshot_dir: Path):
def test_ensure_always_clearsign(app: TezosAppScreen, snapshot_dir: Path):
"""Check clear signing never blindsign"""

app.setup_expert_mode()
app.toggle_expert_mode()

message = Transaction(
source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa',
Expand Down
Loading

0 comments on commit c4b1268

Please sign in to comment.