Skip to content

Commit

Permalink
[test] stop taking snapshot if not necessary
Browse files Browse the repository at this point in the history
 - remove
 `test_nanosp_regression_press_right_works_across_apdu_recieves` that
 does not make sens anymore
  • Loading branch information
spalmer25 committed Jan 8, 2025
1 parent 24c8f7e commit 90e4f0c
Show file tree
Hide file tree
Showing 209 changed files with 24 additions and 103 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
62 changes: 9 additions & 53 deletions tests/integration/nano/test_sign/test_apdu_sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,23 @@

"""Gathering of tests related to Sign instructions."""

from pathlib import Path

from conftest import requires_device
from utils.account import Account
from utils.backend import TezosBackend
from utils.message import Message, MichelineExpr, Transaction
from utils.message import MichelineExpr, Transaction
from utils.navigator import TezosNavigator


def test_sign_micheline_without_hash(
backend: TezosBackend,
tezos_navigator: TezosNavigator,
account: Account,
snapshot_dir: Path
account: Account
):
"""Check signing micheline wihout getting hash"""

message = MichelineExpr([{'string': 'CACA'}, {'string': 'POPO'}, {'string': 'BOUDIN'}])

with backend.sign(account, message, with_hash=False) as result:
tezos_navigator.accept_sign(snap_path=snapshot_dir)
tezos_navigator.accept_sign()

account.check_signature(
message=message,
Expand All @@ -47,59 +43,19 @@ def test_sign_micheline_without_hash(
def test_sign_with_small_packet(
backend: TezosBackend,
tezos_navigator: TezosNavigator,
account: Account,
snapshot_dir: Path):
account: Account
):
"""Check signing using small packet instead of full size packets"""

tezos_navigator.toggle_expert_mode()

def check_sign_with_small_packet(
account: Account,
message: Message,
path: Path) -> None:

with backend.sign(account, message, apdu_size=10) as result:
tezos_navigator.accept_sign(snap_path=path)

account.check_signature(
message=message,
with_hash=False,
data=result.value
)

message = Transaction(
source = 'tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu',
fee = 50000,
counter = 8,
gas_limit = 54,
storage_limit = 45,
destination = 'KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT',
amount = 240000,
entrypoint = 'do',
parameter = {'prim': 'CAR'}
)

check_sign_with_small_packet(
account=account,
message=message,
path=snapshot_dir)
message = Transaction()

@requires_device("nanosp")
def test_nanosp_regression_press_right_works_across_apdu_recieves(
backend: TezosBackend,
tezos_navigator: TezosNavigator,
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<E`SiG6Yf*A^kZ\\=7?H[mOlQ\n]Ehs'}]}]]]}]],[{'prim':'IF_NONE','args':[[{'prim':'DUP'}],[[{'prim':'DROP','args':[{'int':4}]},{'prim':'PUSH','args':[{'prim':'unit'},{'prim':'Unit'}]},{'prim':'PUSH','args':[{'prim':'bool'},{'prim':'True'}]},{'prim':'PUSH','args':[{'prim':'string'},{'string':'\"\\6_4\n$k%'}]},{'prim':'PUSH','args':[{'prim':'string'},{'string':'c^1\"\\?Ey_1!EVb~9;EX;YU\n#Kj2ZT8h`U!X '}]}]]]}]]},{'prim':'SIZE'}])

with backend.sign(account, message, with_hash=True) as result:
tezos_navigator.accept_sign(snap_path=snapshot_dir)
with backend.sign(account, message, apdu_size=10) as result:
tezos_navigator.accept_sign()

account.check_signature(
message=message,
with_hash=True,
with_hash=False,
data=result.value
)
30 changes: 8 additions & 22 deletions tests/integration/nano/test_sign/test_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@

"""Gathering of tests related to Key signatures."""

from pathlib import Path

import pytest

from utils.account import Account, SigType
from utils.backend import TezosBackend
from utils.message import MichelineExpr, Transaction
from utils.message import MichelineExpr
from utils.navigator import TezosNavigator


Expand All @@ -43,18 +41,17 @@
],
ids=lambda account: f"{account.sig_type}"
)
def test_sign_micheline_basic(
def test_sign_with_another_sig(
backend: TezosBackend,
tezos_navigator: TezosNavigator,
account: Account,
snapshot_dir: Path
account: Account
):
"""Check signing with ed25519"""

message = MichelineExpr([{'string': 'CACA'}, {'string': 'POPO'}, {'string': 'BOUDIN'}])
message = MichelineExpr([{'int': 0}])

with backend.sign(account, message, with_hash=True) as result:
tezos_navigator.accept_sign(snap_path=snapshot_dir)
tezos_navigator.accept_sign()

account.check_signature(
message=message,
Expand All @@ -71,8 +68,7 @@ def test_sign_micheline_basic(
)
def test_sign_with_another_seed(
backend: TezosBackend,
tezos_navigator: TezosNavigator,
snapshot_dir: Path
tezos_navigator: TezosNavigator
):
"""Check signing using another seed than [zebra*24]"""

Expand All @@ -82,20 +78,10 @@ def test_sign_with_another_seed(
SigType.ED25519,
"edpkupntwMyERpYniuK1GDWquPaPU1wYsQgMirJPLGmC4Y5dMUsQNo")

message = Transaction(
source = 'tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu',
fee = 50000,
counter = 8,
gas_limit = 54,
storage_limit = 45,
destination = 'KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT',
amount = 240000,
entrypoint = 'do',
parameter = {'prim': 'CAR'}
)
message = MichelineExpr([{'int': 0}])

with backend.sign(account, message, with_hash=True) as result:
tezos_navigator.accept_sign(snap_path=snapshot_dir)
tezos_navigator.accept_sign()

account.check_signature(
message=message,
Expand Down
35 changes: 7 additions & 28 deletions tests/integration/nano/test_wrong_apdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

"""Gathering of tests related to APDU checks."""

from pathlib import Path
from typing import Any, Callable, Union

import pytest
Expand All @@ -30,52 +29,32 @@
def test_regression_continue_after_reject(
backend: TezosBackend,
tezos_navigator: TezosNavigator,
account: Account,
snapshot_dir: Path):
account: Account
):
"""Check the app still runs after rejects signing"""

tezos_navigator.toggle_expert_mode()

with StatusCode.REJECT.expected():
with backend.prompt_public_key(account):
tezos_navigator.reject_public_key(snap_path=snapshot_dir / "reject_public_key")
tezos_navigator.reject_public_key()

backend.wait_for_home_screen()

message = Transaction(
source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa',
fee = 10000,
counter = 2,
gas_limit = 3,
storage_limit = 4,
destination = 'KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT',
amount = 0,
entrypoint = 'root',
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},[]]}]}]}]}]}]}]}]}]}]}]
)
message = Transaction()

with StatusCode.REJECT.expected():
with backend.sign(account, message, with_hash=True):
tezos_navigator.reject_sign(snap_path=snapshot_dir / "reject_signing")
tezos_navigator.reject_sign()

backend.get_public_key(account)


def test_change_sign_instruction(backend: TezosBackend, account: Account):
"""Check signing instruction changes behaviour"""

message = Transaction(
source = 'tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu',
fee = 50000,
counter = 8,
gas_limit = 54,
storage_limit = 45,
destination = 'KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT',
amount = 240000,
entrypoint = 'do',
parameter = {'prim': 'CAR'}
)
payload=bytes(message)
message = Transaction()
payload = bytes(message)

backend._ask_sign(Ins.SIGN_WITH_HASH, account)

Expand Down

0 comments on commit 90e4f0c

Please sign in to comment.