Skip to content

Commit

Permalink
[test] add test to check too long operation flow on parsing error
Browse files Browse the repository at this point in the history
  • Loading branch information
spalmer25 committed Sep 10, 2024
1 parent d959df3 commit af93b45
Show file tree
Hide file tree
Showing 103 changed files with 64 additions and 8 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.
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.
72 changes: 64 additions & 8 deletions tests/integration/nano/test_sign_too_long_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,19 @@
# limitations under the License.

from pathlib import Path
from typing import Callable

from utils.app import Screen, Screen_text, DEFAULT_ACCOUNT
from utils.message import Message

test_path = Path(Path(__file__).stem)

def _sign_too_long(app, msg: str, path: Path):
def _sign_too_long(app, msg: str, navigate: Callable[[], None]):

app.setup_expert_mode()

message = Message.from_bytes(msg)

def navigate() -> None:
app.navigate_until_text(Screen_text.Accept_risk, path / "clear_n_too_long_warning")
app.navigate_until_text(Screen_text.Sign_accept, path / "summary")

data = app._sign(
DEFAULT_ACCOUNT,
message,
Expand All @@ -44,6 +41,14 @@ def navigate() -> None:

app.quit()

def _sign_decodable_too_long(app, msg: str, path: Path):

def navigate() -> None:
app.navigate_until_text(Screen_text.Accept_risk, path / "clear_n_too_long_warning")
app.navigate_until_text(Screen_text.Sign_accept, path / "summary")

_sign_too_long(app, msg, navigate)

## Operation (0): Reveal
# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa
# Fee: 1 XTZ
Expand Down Expand Up @@ -93,7 +98,7 @@ def navigate() -> None:
# Staking limit: 10 XTZ
def test_sign_basic_too_long_operation(app):
msg="0300000000000000000000000000000000000000000000000000000000000000006b00ffdd6102321bc251e4a5190ad5b12b251069d9b4c0843d0b0104020320182716513907b6bab33f905396d031931c07e01bddd780780c1a56b9c086da6c00ffdd6102321bc251e4a5190ad5b12b251069d9b480897a0c0107c08db701000278eb8b6ab9a768579cd5146b480789650c83f28effff0d7570646174655f636f6e6669670000000607070005030a6e00ffdd6102321bc251e4a5190ad5b12b251069d9b4c08db7010d0105ff01ee572f02e5be5d097ba17369789582882e8abb87c900ffdd6102321bc251e4a5190ad5b12b251069d9b48092f4010e0106000000fa000000086d65737361676530000000086d65737361676531000000086d65737361676532000000086d65737361676533000000086d65737361676534000000086d65737361676535000000086d65737361676536000000086d65737361676537000000086d65737361676538000000086d65737361676539000000096d6573736167653130000000096d6573736167653131000000096d6573736167653132000000096d6573736167653133000000096d6573736167653134000000096d6573736167653135000000096d6573736167653136000000096d6573736167653137000000096d6573736167653138000000096d65737361676531397000ffdd6102321bc251e4a5190ad5b12b251069d9b4c0843d0f0103ff80ade204"
_sign_too_long(app, msg, test_path / "basic")
_sign_decodable_too_long(app, msg, test_path / "basic")

## Operation (0): Transaction
# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa
Expand Down Expand Up @@ -133,7 +138,7 @@ def test_sign_basic_too_long_operation(app):
# Destination: tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu
def test_sign_too_long_operation_with_only_transactions(app):
msg="0300000000000000000000000000000000000000000000000000000000000000006c00ffdd6102321bc251e4a5190ad5b12b251069d9b4000b010080ade2040000d2b3082b0fe03f0f7f39915cdba50e9d9b8ab057006c00ffdd6102321bc251e4a5190ad5b12b251069d9b4c0843d0c0101c0843d0001a55ae1858c1201514c97aa9122e77d3c4197a714006c00ffdd6102321bc251e4a5190ad5b12b251069d9b480897a0d010280897a000001e8e5519a315280a374c8765107979a6049de27006c00ffdd6102321bc251e4a5190ad5b12b251069d9b4c08db7010e0103c08db7010002d09584de879c4bbd3f494ed01b82e06a81e8e176006c00ffdd6102321bc251e4a5190ad5b12b251069d9b48092f4010f01048092f4010002cc8e146741cf31fc00123b8c26baf95c57421a3c006c00ffdd6102321bc251e4a5190ad5b12b251069d9b4c096b102100105c096b10200016e8874874d31c3fbd636e924d5a036a43ec8faa700"
_sign_too_long(app, msg, test_path / "only_transactions")
_sign_decodable_too_long(app, msg, test_path / "only_transactions")

## Operation (0): Proposals
# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa
Expand All @@ -160,4 +165,55 @@ def test_sign_too_long_operation_with_only_transactions(app):
# Proposal (19): ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK
def test_sign_too_long_operation_without_fee_or_amount(app):
msg="0300000000000000000000000000000000000000000000000000000000000000000500ffdd6102321bc251e4a5190ad5b12b251069d9b400000020000002800bcd7db2d718ba94e85bd262681049852e1f58512aa552124330d657845c73b70bcd7ffca03f57e38453f0d3e84c302403c05357448b4c2daef8b3a8be3c69c1000000000000000000000000000000000000000000000000000000000000000038ecdef0cd08640f318a9b055f6b0d0c9ae030913a871d9b9d86fb846317da213d0b4bacb5c3e152a167da26fefc266bd3a0e14fc4e41e6c53623bf482833da23e5e3a606afab74a59ca09e333633e2770b6492c5e594455b71e9a2f0ea92afb40cab83d3f37a64da26b57ad3d0432ae881293a25169ada387bfc74a1cbf9e6ec7ad4f7a000e28e9eefc58de8ea1172de843242bd2e688779953d3416a44640b4596285c6871691e25196c6a8d26d90a3ac91375731e3926103c517a13a0ba56cbb944f74244ea2681981f25995f8ebba8ff6cee8c036892fe901cb760c4e39ece5f061e34b5a21feab8dbdfe755ef17e70c9f565464f067ac5e7c02be830a488424520cf9bbf0a42770204d95dcc1f11e404fdb3e90c84850c4cfdb50c5c4b9d0a3f07b8adfcf61f5ca60f244ca9a876e76cbad9140980f6c88d0bf900ac6d8d2ea9f23a1a1011091841b12e32ce2f8c3facff27feee58bb7c9e90567d11425d57ed88be5a69815e39386a33f7dcad391f5f507e03b376e499272c86c6cf2a7d8325f11da2ff36934a586439f085655a833f2ff6a12d15e83b951fb684326e0d9b8c2314cc05ffa3fc655a98bb87155be4cf7ce67fee6b594ea9302e8655df20bf44c7d64e3d7da27d925d10af535fb36cef0ad41930c7929773f4731eba137dbff6586a04802d3f513c65a444d9d4debe42b17e9e7273f8f6c118ea3f4e06e0bcd7b2cadcd87ecb0d5c50330fb59feed7432bffecede8a09a2b86d1527c6a5"
_sign_too_long(app, msg, test_path / "without_fee_or_amount")
_sign_decodable_too_long(app, msg, test_path / "without_fee_or_amount")

# Operation (0): SR: send messages
# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa
# Fee: 4 XTZ
# Storage limit: 6
# Message (0): 6d65737361676530
# Message (1): 6d65737361676531
# Message (2): 6d65737361676532
# Message (3): 6d65737361676533
# Message (4): 6d65737361676534
# Message (5): 6d65737361676535
# Message (6): 6d65737361676536
# Message (7): 6d65737361676537
# Message (8): 6d65737361676538
# Message (9): 6d65737361676539
# Message (10): 6d6573736167653130
# Message (11): 6d6573736167653131
# Message (12): 6d6573736167653132
# Message (13): 6d6573736167653133
# Message (14): 6d6573736167653134
# Message (15): 6d6573736167653135
# Message (16): 6d6573736167653136
# Message (17): 6d6573736167653137
# Message (18): 6d6573736167653138
# Message (19): 6d6573736167653139
# Message (20): 6d6573736167653230
# Message (21): 6d6573736167653231
# Message (22): 6d6573736167653232
# Message (23): 6d6573736167653233
# Message (24): 6d6573736167653234
# Message (25): 6d6573736167653235
# Message (26): 6d6573736167653236
# Message (27): 6d6573736167653237
# Message (28): 6d6573736167653238
# Message (29): 6d6573736167653239
## Operation (1): Register global constant
# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa
# Fee: 5 XTZ
# Storage limit: 3
# Value: 115792089237316195423570985008687907853269984665640564039457584007913129639936
def test_sign_too_long_operation_with_too_large(app):
msg = "030000000000000000000000000000000000000000000000000000000000000000c900ffdd6102321bc251e4a5190ad5b12b251069d9b48092f4010b01060000017c000000086d65737361676530000000086d65737361676531000000086d65737361676532000000086d65737361676533000000086d65737361676534000000086d65737361676535000000086d65737361676536000000086d65737361676537000000086d65737361676538000000086d65737361676539000000096d6573736167653130000000096d6573736167653131000000096d6573736167653132000000096d6573736167653133000000096d6573736167653134000000096d6573736167653135000000096d6573736167653136000000096d6573736167653137000000096d6573736167653138000000096d6573736167653139000000096d6573736167653230000000096d6573736167653231000000096d6573736167653232000000096d6573736167653233000000096d6573736167653234000000096d6573736167653235000000096d6573736167653236000000096d6573736167653237000000096d6573736167653238000000096d65737361676532396f00ffdd6102321bc251e4a5190ad5b12b251069d9b4c096b1020c0103000000260080808080808080808080808080808080808080808080808080808080808080808080808020"

path = test_path / "too_large"

def navigate() -> None:
app.navigate_until_text(Screen_text.Accept_risk, path / "clear_n_too_long_warning")
app.navigate_until_text(Screen_text.Accept_risk, path / "too_large_warning")
app.navigate_until_text(Screen_text.Sign_accept, path / "blindsigning")

_sign_too_long(app, msg, navigate)

0 comments on commit af93b45

Please sign in to comment.