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 Dec 14, 2024
1 parent af92939 commit 568e8ce
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.
64 changes: 11 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,25 +16,21 @@

"""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 send_and_navigate, TezosNavigator


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

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

data = tezos_navigator.sign(
account,
message,
with_hash=False,
snap_path=snapshot_dir
with_hash=False
)

account.check_signature(
Expand All @@ -45,58 +41,20 @@ def test_sign_micheline_without_hash(tezos_navigator: TezosNavigator, account: A
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:

data = send_and_navigate(
send=lambda: backend.sign(account, message, apdu_size=10),
navigate=lambda: tezos_navigator.navigate_sign_accept(snap_path=path)
)

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

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)

@requires_device("nanosp")
def test_nanosp_regression_press_right_works_across_apdu_recieves(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'}])
message = Transaction()

data = tezos_navigator.sign(
account,
message,
with_hash=True,
snap_path=snapshot_dir
data = send_and_navigate(
send=lambda: backend.sign(account, message, apdu_size=10),
navigate=tezos_navigator.navigate_sign_accept
)

account.check_signature(
message=message,
with_hash=True,
data=data)
with_hash=False,
data=data
)
28 changes: 7 additions & 21 deletions tests/integration/nano/test_sign/test_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

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

from pathlib import Path

import pytest

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


Expand All @@ -42,16 +40,15 @@
],
ids=lambda account: f"{account.sig_type}"
)
def test_sign_micheline_basic(tezos_navigator: TezosNavigator, account: Account, snapshot_dir: Path):
def test_sign_with_another_sig(tezos_navigator: TezosNavigator, account: Account):
"""Check signing with ed25519"""

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

data = tezos_navigator.sign(
account,
message,
with_hash=True,
snap_path=snapshot_dir
with_hash=True
)

account.check_signature(
Expand All @@ -66,7 +63,7 @@ def test_sign_micheline_basic(tezos_navigator: TezosNavigator, account: Account,
],
ids=["seed21"]
)
def test_sign_with_another_seed(tezos_navigator: TezosNavigator, snapshot_dir: Path):
def test_sign_with_another_seed(tezos_navigator: TezosNavigator):
"""Check signing using another seed than [zebra*24]"""

tezos_navigator.toggle_expert_mode()
Expand All @@ -75,23 +72,12 @@ def test_sign_with_another_seed(tezos_navigator: TezosNavigator, snapshot_dir: P
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}])

data = tezos_navigator.sign(
account,
message,
with_hash=True,
snap_path=snapshot_dir
with_hash=True
)

account.check_signature(
Expand Down
35 changes: 6 additions & 29 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,35 +29,23 @@
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():
tezos_navigator.reject_public_key(account, snap_path=snapshot_dir / "reject_public_key")
tezos_navigator.reject_public_key(account)

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():
tezos_navigator.reject_signing(
account,
message,
with_hash=True,
snap_path=snapshot_dir / "reject_signing"
with_hash=True
)

backend.get_public_key(account, with_prompt=False)
Expand All @@ -67,18 +54,8 @@ def test_regression_continue_after_reject(
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 568e8ce

Please sign in to comment.