From 4a8c7b163d08a314774ec80fd809012e9191de2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Palmer=20S=C3=A9bastien?= Date: Thu, 12 Dec 2024 16:56:23 +0100 Subject: [PATCH] [test] explicits messages (#301) * [test] abstract Message and instantiate RawMessage * [test] build transaction * [test] build failing-noop * [test] build reveal * [test] build origination * [test] build delegation * [test] build register-global-constant * [test] build transfer-ticket * [test] build smart-rollup-add-messages * [test] build smart-rollup-execute-outbox-message * [test] build proposals * [test] build ballot * [test] build set-deposit-limit * [test] build increase-paid-storage * [test] build update-consensus-key * [test] build smart-rollup-originate * [test] build operations group * [test] build micheline expression --- tests/integration/.pylintrc | 1 + .../test_nanos_regression_batched_ops.py | 38 +- ...anosp_regression_potential_empty_screen.py | 30 +- ..._press_right_works_across_apdu_recieves.py | 6 +- .../test_nanox_regression_batched_ops.py | 38 +- .../integration/nano/test_blindsign_reject.py | 7 +- .../nano/test_blindsign_too_deep.py | 6 +- .../nano/test_blindsign_too_large.py | 6 +- .../nano/test_change_sign_instruction.py | 14 +- .../nano/test_ensure_always_clearsign.py | 22 +- tests/integration/nano/test_parsing_errors.py | 25 +- .../test_regression_continue_after_reject.py | 14 +- tests/integration/nano/test_sign_ballot.py | 15 +- .../nano/test_sign_complex_operation.py | 58 +- .../integration/nano/test_sign_delegation.py | 16 +- .../nano/test_sign_failing_noop.py | 7 +- .../nano/test_sign_increase_paid_storage.py | 18 +- .../nano/test_sign_micheline_without_hash.py | 6 +- .../integration/nano/test_sign_origination.py | 21 +- tests/integration/nano/test_sign_proposals.py | 17 +- .../test_sign_register_global_constant.py | 16 +- tests/integration/nano/test_sign_reveal.py | 16 +- .../nano/test_sign_sc_rollup_add_messages.py | 18 +- ...t_sign_sc_rollup_execute_outbox_message.py | 20 +- .../nano/test_sign_sc_rollup_originate.py | 51 +- .../nano/test_sign_set_consensus_key.py | 16 +- .../nano/test_sign_set_deposit_limit.py | 16 +- .../nano/test_sign_too_long_operation.py | 379 +++++---- .../integration/nano/test_sign_transaction.py | 163 ++-- .../nano/test_sign_transfer_ticket.py | 25 +- .../nano/test_sign_with_another_seed.py | 22 +- .../nano/test_sign_with_long_hash.py | 22 +- .../nano/test_sign_with_small_packet.py | 16 +- .../test_tz1_bip25519_sign_micheline_basic.py | 6 +- .../test_tz1_ed25519_sign_micheline_basic.py | 6 +- .../nano/test_tz2_sign_micheline_basic.py | 6 +- .../nano/test_tz3_sign_micheline_basic.py | 6 +- tests/integration/nano/utils/message.py | 792 +++++++++++++++++- 38 files changed, 1417 insertions(+), 544 deletions(-) diff --git a/tests/integration/.pylintrc b/tests/integration/.pylintrc index 0c5eedc64..db2b77d67 100644 --- a/tests/integration/.pylintrc +++ b/tests/integration/.pylintrc @@ -1,6 +1,7 @@ [MESSAGES CONTROL] disable= broad-exception-caught, + dangerous-default-value, global-statement, line-too-long, protected-access, diff --git a/tests/integration/nano/nanos/test_nanos_regression_batched_ops.py b/tests/integration/nano/nanos/test_nanos_regression_batched_ops.py index 08d460704..3143e874a 100755 --- a/tests/integration/nano/nanos/test_nanos_regression_batched_ops.py +++ b/tests/integration/nano/nanos/test_nanos_regression_batched_ops.py @@ -20,20 +20,7 @@ from conftest import requires_device from utils.app import TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Transaction -# Fee: 0.39 XTZ -# Storage limit: 6 -# Amount: 0.02 XTZ -# Destination: tz1cfdVKpBb9VRBdny8BQ5RSK82UudAp2miM -# Entrypoint: jean_bob -# Parameter: {Pair {} (Right -76723569314251090535296646);Pair {Elt Unit (Pair {Left Unit} (Pair (Left 0x03F01167865DC63DFEE0E31251329CEAB660D94606) (Pair 0x0107B21FCA96C5763F67B286752C7AAEFC5931D15A Unit)))} (Right 3120123370638446806591421154959427514880865200209654970345);Pair {} (Left (Some Unit))} -# Operation (1): Transaction -# Fee: 0.65 XTZ -# Storage limit: 2 -# Amount: 0.06 XTZ -# Destination: KT1CYT8oACUcCSNTu2qfgB4fj5bD7szYrpti +from utils.message import OperationGroup, Transaction @requires_device("nanos") def test_nanos_regression_batched_ops(app: TezosAppScreen): @@ -42,7 +29,28 @@ def test_nanos_regression_batched_ops(app: TezosAppScreen): app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c001597c45b11b421bb806a0c56c5da5638bf4b1adbf0e617090006a09c010000bac799dfc7f6af2ff0b95f83d023e68c895020baffff086a65616e5f626f620000009a020000009507070200000000050800c6bab5ccc8d891cd8de4b6f7070707020000004b0704030b070702000000040505030b070705050a0000001503f01167865dc63dfee0e31251329ceab660d9460607070a000000150107b21fca96c5763f67b286752c7aaefc5931d15a030b050800a9df9fc1e7eaa7a9c1f7bd87a9ba9cadf5b5b2cd829deea2b7fef9070707020000000005050509030b6c01ee572f02e5be5d097ba17369789582882e8abb8790d627063202e0d403012b704944f5b5fd30eed2ab4385478488e09fe04a0000") + message = OperationGroup([ + Transaction( + source = 'tz1McCh72NRhYmJBcWr3zDrLJAxnfR9swcFh', + fee = 390000, + counter = 9, + gas_limit = 0, + storage_limit = 6, + destination = 'tz1cfdVKpBb9VRBdny8BQ5RSK82UudAp2miM', + amount = 20000, + entrypoint = 'jean_bob', + parameter = [{'prim':'Pair','args':[[],{'prim':'Right','args':[{'int':-76723569314251090535296646}]}]},{'prim':'Pair','args':[[{'prim':'Elt','args':[{'prim':'Unit','args':[]},{'prim':'Pair','args':[[{'prim':'Left','args':[{'prim':'Unit','args':[]}]}],{'prim':'Pair','args':[{'prim':'Left','args':[{'bytes':"03F01167865DC63DFEE0E31251329CEAB660D94606"}]},{'prim':'Pair','args':[{'bytes':"0107B21FCA96C5763F67B286752C7AAEFC5931D15A"},{'prim':'Unit','args':[]}]}]}]}]}],{'prim':'Right','args':[{'int':3120123370638446806591421154959427514880865200209654970345}]},]},{'prim':'Pair','args':[[],{'prim':'Left','args':[{'prim':'Some','args':[{'prim':'Unit','args':[]}]}]}]}] + ), + Transaction( + source = 'tz2W3Tvcm64GjcV2bipUynnEsctLFz5Z6yRa', + fee = 650000, + counter = 6, + gas_limit = 50, + storage_limit = 2, + destination = 'KT1CYT8oACUcCSNTu2qfgB4fj5bD7szYrpti', + amount = 60000 + ) + ]) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/nanosp/test_nanosp_regression_potential_empty_screen.py b/tests/integration/nano/nanosp/test_nanosp_regression_potential_empty_screen.py index d5c61eb9f..9bc45532b 100755 --- a/tests/integration/nano/nanosp/test_nanosp_regression_potential_empty_screen.py +++ b/tests/integration/nano/nanosp/test_nanosp_regression_potential_empty_screen.py @@ -20,21 +20,7 @@ from conftest import requires_device from utils.app import TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Transfer ticket -# Fee: 0.01 XTZ -# Storage limit: 4 -# Contents: UNPAIR -# Type: pair "1" 2 -# Ticketer: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Amount: 1 -# Destination: KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT -# Entrypoint: S -# -# S -# S -# S +from utils.message import TransferTicket @requires_device("nanosp") def test_nanosp_regression_potential_empty_screen(app: TezosAppScreen): @@ -43,7 +29,19 @@ def test_nanosp_regression_potential_empty_screen(app: TezosAppScreen): app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000009e00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000002037a0000000a076501000000013100020000ffdd6102321bc251e4a5190ad5b12b251069d9b4010100000000000000000000000000000000000000000000000008530a0a530a530a53") + message = TransferTicket( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 10000, + counter = 2, + gas_limit = 3, + storage_limit = 4, + ticket_contents = {'prim': 'UNPAIR'}, + ticket_ty = {'prim': 'pair', 'args': [{'string': '1'}, {'int': 2}]}, + ticket_ticketer = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + ticket_amount = 1, + destination = 'KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT', + entrypoint = 'S\n\nS\nS\nS' + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/nanosp/test_nanosp_regression_press_right_works_across_apdu_recieves.py b/tests/integration/nano/nanosp/test_nanosp_regression_press_right_works_across_apdu_recieves.py index d1ab32855..b84c329cc 100755 --- a/tests/integration/nano/nanosp/test_nanosp_regression_press_right_works_across_apdu_recieves.py +++ b/tests/integration/nano/nanosp/test_nanosp_regression_press_right_works_across_apdu_recieves.py @@ -20,9 +20,7 @@ from conftest import requires_device from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Expression: {IF_NONE {{SWAP;IF {DIP {{DROP 1;PUSH unit Unit;PUSH bool True;PUSH string ";L\\S?p$-Fq)VDg\n]te\no4v0_8)\""}}} {{DROP 2;PUSH unit Unit;PUSH bool False;PUSH string "Li-%*edF6~?E[5Kmu?dyviwJ^2\"\\d$FyQ>>!>D$g(Qg";PUSH string "*Tx>!>D$g(Qg'}]},{'prim':'PUSH','args':[{'prim':'string'},{'string':'*Tx None: diff --git a/tests/integration/nano/test_blindsign_too_large.py b/tests/integration/nano/test_blindsign_too_large.py index fc62d9b41..71c81695d 100755 --- a/tests/integration/nano/test_blindsign_too_large.py +++ b/tests/integration/nano/test_blindsign_too_large.py @@ -18,9 +18,7 @@ from pathlib import Path from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Expression: 12345678901234567890123456789012345678901234567890123456789012345678901234567890 +from utils.message import MichelineExpr def test_blindsign_too_large(app: TezosAppScreen): """Check blindsigning on too large expression""" @@ -28,7 +26,7 @@ def test_blindsign_too_large(app: TezosAppScreen): app.assert_screen(Screen.HOME) - message = Message.from_bytes("050092abf8e3d9e5f8cfd9ae8a9fe5f28ea1d5b5abf1af82dae8a4b68df3d1889eb6f988f5e8d31a") + message = MichelineExpr({'int':12345678901234567890123456789012345678901234567890123456789012345678901234567890}) data = app.blind_sign(DEFAULT_ACCOUNT, message=message, diff --git a/tests/integration/nano/test_change_sign_instruction.py b/tests/integration/nano/test_change_sign_instruction.py index 1a12c1d38..3bc36732d 100755 --- a/tests/integration/nano/test_change_sign_instruction.py +++ b/tests/integration/nano/test_change_sign_instruction.py @@ -17,14 +17,24 @@ from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT from utils.backend import Ins, StatusCode -from utils.message import Message +from utils.message import Transaction def test_change_sign_instruction(app: TezosAppScreen): """Check signing instruction changes behaviour""" app.assert_screen(Screen.HOME) - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316") + 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) app.backend._ask_sign(Ins.SIGN_WITH_HASH, DEFAULT_ACCOUNT) diff --git a/tests/integration/nano/test_ensure_always_clearsign.py b/tests/integration/nano/test_ensure_always_clearsign.py index 7d32f7a4a..84f00c170 100755 --- a/tests/integration/nano/test_ensure_always_clearsign.py +++ b/tests/integration/nano/test_ensure_always_clearsign.py @@ -18,15 +18,7 @@ from pathlib import Path from utils.app import TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Transaction -# Fee: 0.01 XTZ -# Storage limit: 4 -# Amount: 0 XTZ -# Destination: KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT -# Entrypoint: root -# Data: {pair "[" (pair "Z" (pair "Y" (pair "X" (pair "W" (pair "V" (pair "U" (pair "T" (pair "S" (pair "R" (pair "Q" (pair "P" (pair "O" (pair "N" (pair "M" (pair "L" (pair "K" (pair "J" (pair "I" (pair "H" (pair "G" (pair "F" (pair "E" (pair "D" (pair "C" (pair "B" {})))))))))))))))))))))))));pair 10 (pair 9 (pair 8 (pair 7 (pair 6 (pair 5 (pair 4 (pair 3 (pair 2 (pair 1 {})))))))))} +from utils.message import Transaction def test_ensure_always_clearsign(app: TezosAppScreen): """Check clear signing never blindsign""" @@ -34,7 +26,17 @@ def test_ensure_always_clearsign(app: TezosAppScreen): app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e0203040001000000000000000000000000000000000000000000ff01000001070200000102076501000000015b076501000000015a0765010000000159076501000000015807650100000001570765010000000156076501000000015507650100000001540765010000000153076501000000015207650100000001510765010000000150076501000000014f076501000000014e076501000000014d076501000000014c076501000000014b076501000000014a0765010000000149076501000000014807650100000001470765010000000146076501000000014507650100000001440765010000000143076501000000014202000000000765000a0765000907650008076500070765000607650005076500040765000307650002076500010200000000") + 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},[]]}]}]}]}]}]}]}]}]}]}] + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_parsing_errors.py b/tests/integration/nano/test_parsing_errors.py index 05fece840..7b53124f2 100755 --- a/tests/integration/nano/test_parsing_errors.py +++ b/tests/integration/nano/test_parsing_errors.py @@ -19,7 +19,18 @@ from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT from utils.backend import StatusCode -from utils.message import Message +from utils.message import RawMessage + +# Operation (0): Transaction +# Source: tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu +# Fee: 0.05 XTZ +# Gas limit: 54 +# Counter: 8 +# Storage limit: 45 +# Amount: 0.24 XTZ +# Destination: KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT +# Entrypoint: do +# Parameter: CAR # original bytes : 0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316 @@ -32,7 +43,7 @@ def make_path(name: str) -> Path: app.setup_expert_mode() - unknown_magic_bytes_message = Message.from_bytes("0100000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316") + unknown_magic_bytes_message = RawMessage("0100000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316") app.parsing_error_signing(DEFAULT_ACCOUNT, unknown_magic_bytes_message, @@ -41,7 +52,7 @@ def make_path(name: str) -> Path: app.assert_screen(Screen.HOME) - unknown_operation_message = Message.from_bytes("03000000000000000000000000000000000000000000000000000000000000000001016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316") + unknown_operation_message = RawMessage("03000000000000000000000000000000000000000000000000000000000000000001016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316") app.parsing_error_signing(DEFAULT_ACCOUNT, unknown_operation_message, @@ -50,7 +61,7 @@ def make_path(name: str) -> Path: app.assert_screen(Screen.HOME) - one_byte_removed_inside_message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e010000000000000000000000000000000000000000ff02000000020316") + one_byte_removed_inside_message = RawMessage("0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e010000000000000000000000000000000000000000ff02000000020316") app.parsing_error_signing(DEFAULT_ACCOUNT, one_byte_removed_inside_message, @@ -59,7 +70,7 @@ def make_path(name: str) -> Path: app.assert_screen(Screen.HOME) - one_byte_added_at_the_end_message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff0200000002031645") + one_byte_added_at_the_end_message = RawMessage("0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff0200000002031645") app.parsing_error_signing(DEFAULT_ACCOUNT, one_byte_added_at_the_end_message, @@ -68,7 +79,7 @@ def make_path(name: str) -> Path: app.assert_screen(Screen.HOME) - one_byte_added_inside_message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e0100000000000000000000000000000000000000000000ff02000000020316") + one_byte_added_inside_message = RawMessage("0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e0100000000000000000000000000000000000000000000ff02000000020316") app.parsing_error_signing(DEFAULT_ACCOUNT, one_byte_added_inside_message, @@ -77,7 +88,7 @@ def make_path(name: str) -> Path: app.assert_screen(Screen.HOME) - wrong_last_packet_message = Message.from_bytes("030000000000000000000000000000000000000000000000000000000000000000ce00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c63966303966323935326433343532386337333366393436313563666333396263353535363139666335353064643461363762613232303863653865383637616133643133613665663939646662653332633639373461613961323135306432316563613239633333343965353963313362393038316631") + wrong_last_packet_message = RawMessage("030000000000000000000000000000000000000000000000000000000000000000ce00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c63966303966323935326433343532386337333366393436313563666333396263353535363139666335353064643461363762613232303863653865383637616133643133613665663939646662653332633639373461613961323135306432316563613239633333343965353963313362393038316631") app.hard_failing_signing(DEFAULT_ACCOUNT, wrong_last_packet_message, diff --git a/tests/integration/nano/test_regression_continue_after_reject.py b/tests/integration/nano/test_regression_continue_after_reject.py index 1b1025691..ae5aca528 100755 --- a/tests/integration/nano/test_regression_continue_after_reject.py +++ b/tests/integration/nano/test_regression_continue_after_reject.py @@ -18,7 +18,7 @@ from pathlib import Path from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message +from utils.message import Transaction def test_regression_continue_after_reject(app: TezosAppScreen): """Check the app still runs after rejects signing""" @@ -33,7 +33,17 @@ def make_path(name: str) -> Path: app.assert_screen(Screen.HOME) - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e0203040001000000000000000000000000000000000000000000ff01000001070200000102076501000000015b076501000000015a0765010000000159076501000000015807650100000001570765010000000156076501000000015507650100000001540765010000000153076501000000015207650100000001510765010000000150076501000000014f076501000000014e076501000000014d076501000000014c076501000000014b076501000000014a0765010000000149076501000000014807650100000001470765010000000146076501000000014507650100000001440765010000000143076501000000014202000000000765000a0765000907650008076500070765000607650005076500040765000307650002076500010200000000") + 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},[]]}]}]}]}]}]}]}]}]}]}] + ) app.reject_signing(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_ballot.py b/tests/integration/nano/test_sign_ballot.py index bde516d19..30128cc30 100755 --- a/tests/integration/nano/test_sign_ballot.py +++ b/tests/integration/nano/test_sign_ballot.py @@ -18,13 +18,7 @@ from pathlib import Path from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Ballot -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Period: 32 -# Proposal: ProtoALphaALphaALphaALphaALphaALphaALpha61322gcLUGH -# Ballot: yay +from utils.message import Ballot def test_sign_ballot(app: TezosAppScreen): """Check signing ballot""" @@ -32,7 +26,12 @@ def test_sign_ballot(app: TezosAppScreen): app.assert_screen(Screen.HOME) - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000000600ffdd6102321bc251e4a5190ad5b12b251069d9b4000000200bcd7b2cadcd87ecb0d5c50330fb59feed7432bffecede8a09a2b86cfb33847b00") + message = Ballot( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + proposal = 'ProtoALphaALphaALphaALphaALphaALphaALpha61322gcLUGH', + ballot = 'yay', + period = 32 + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_complex_operation.py b/tests/integration/nano/test_sign_complex_operation.py index 709627212..0ccf3ddf5 100644 --- a/tests/integration/nano/test_sign_complex_operation.py +++ b/tests/integration/nano/test_sign_complex_operation.py @@ -18,34 +18,11 @@ from pathlib import Path from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Transaction -# Fee: 0.05 XTZ -# Storage limit: 45 -# Amount: 0.24 XTZ -# Destination: KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT -# Entrypoint: do -# Parameter: CAR - -## Operation (0): Origination -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 0.5 XTZ -# Storage limit: 4 -# Balance: 1 XTZ -# Delegate: None -# Code: UNPACK mutez -# Storage: or key chest -## Operation (1): Transfer ticket -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 0.01 XTZ -# Storage limit: 5 -# Contents: None -# Type: option nat -# Ticketer: tz1TmFPVZsGQ8MnrBJtnECJgkFUwLa6EWYDm -# Amount: 7 -# Destination: tz3eydffbLkjdVb8zx42BvxpGV87zaRnqL3r -# Entrypoint: default +from utils.message import ( + OperationGroup, + Origination, + TransferTicket +) def test_sign_complex_operation(app: TezosAppScreen): """Check signing complex operation""" @@ -54,7 +31,30 @@ def test_sign_complex_operation(app: TezosAppScreen): app.assert_screen(Screen.HOME) app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006d00ffdd6102321bc251e4a5190ad5b12b251069d9b4a0c21e040304c0843d0000000004050d036a000000060764035c038d9e00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e05040500000002030600000004056303620000591e842444265757d6a65e3670ca18b5e662f9c0070002cc8e146741cf31fc00123b8c26baf95c57421a3c0000000764656661756c74") + message = OperationGroup([ + Origination( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 500000, + counter = 4, + gas_limit = 3, + storage_limit = 4, + code = {'prim': 'UNPACK', 'args': [{'prim': 'mutez'}]}, + storage = {'prim': 'or', 'args': [{'prim': 'key'}, {'prim': 'chest'}]}, + balance = 1000000 + ), + TransferTicket( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 10000, + counter = 5, + gas_limit = 4, + storage_limit = 5, + ticket_contents = {'prim': 'None'}, + ticket_ty = {'prim': 'option', 'args': [{'prim': 'nat'}]}, + ticket_ticketer = 'tz1TmFPVZsGQ8MnrBJtnECJgkFUwLa6EWYDm', + ticket_amount = 7, + destination = 'tz3eydffbLkjdVb8zx42BvxpGV87zaRnqL3r' + ) + ]) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_delegation.py b/tests/integration/nano/test_sign_delegation.py index ed1e77d19..daa85df88 100755 --- a/tests/integration/nano/test_sign_delegation.py +++ b/tests/integration/nano/test_sign_delegation.py @@ -18,12 +18,7 @@ from pathlib import Path from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Delegation -# Fee: 0.2 XTZ -# Storage limit: 889 -# Delegate: tz1TmFPVZsGQ8MnrBJtnECJgkFUwLa6EWYDm +from utils.message import Delegation def test_sign_delegation(app: TezosAppScreen): """Check signing delegation""" @@ -31,7 +26,14 @@ def test_sign_delegation(app: TezosAppScreen): app.assert_screen(Screen.HOME) - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006e01774d99da021b92d8c3dfc2e814c7658440319be2c09a0cf40509f906ff00591e842444265757d6a65e3670ca18b5e662f9c0") + message = Delegation( + source = 'tz2KC42yW9FXFMJpkUooae2NFYQsM5do3E8H', + fee = 200000, + counter = 756, + gas_limit = 9, + storage_limit = 889, + delegate = 'tz1TmFPVZsGQ8MnrBJtnECJgkFUwLa6EWYDm' + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_failing_noop.py b/tests/integration/nano/test_sign_failing_noop.py index f8d1c9c85..5bd24dc61 100755 --- a/tests/integration/nano/test_sign_failing_noop.py +++ b/tests/integration/nano/test_sign_failing_noop.py @@ -18,10 +18,7 @@ from pathlib import Path from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Failing noop -# Message: 396630396632393532643334353238633733336639343631356366633339626335353536313966633535306464346136376261323230386365386538363761613364313361366566393964666265333263363937346161396132313530643231656361323963333334396535396331336239303831663163313162343430616334643334353564656462653465653064653135613861663632306434633836323437643964313332646531626236646132336435666639643864666664613232626139613834 +from utils.message import FailingNoop def test_sign_failing_noop(app: TezosAppScreen): """Check signing failing noop""" @@ -29,7 +26,7 @@ def test_sign_failing_noop(app: TezosAppScreen): app.assert_screen(Screen.HOME) - message = Message.from_bytes("03000000000000000000000000000000000000000000000000000000000000000011000000c6396630396632393532643334353238633733336639343631356366633339626335353536313966633535306464346136376261323230386365386538363761613364313361366566393964666265333263363937346161396132313530643231656361323963333334396535396331336239303831663163313162343430616334643334353564656462653465653064653135613861663632306434633836323437643964313332646531626236646132336435666639643864666664613232626139613834") + message = FailingNoop("9f09f2952d34528c733f94615cfc39bc555619fc550dd4a67ba2208ce8e867aa3d13a6ef99dfbe32c6974aa9a2150d21eca29c3349e59c13b9081f1c11b440ac4d3455dedbe4ee0de15a8af620d4c86247d9d132de1bb6da23d5ff9d8dffda22ba9a84") data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_increase_paid_storage.py b/tests/integration/nano/test_sign_increase_paid_storage.py index 748a7d882..db4869180 100755 --- a/tests/integration/nano/test_sign_increase_paid_storage.py +++ b/tests/integration/nano/test_sign_increase_paid_storage.py @@ -18,13 +18,7 @@ from pathlib import Path from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Increase paid storage -# Fee: 0.01 XTZ -# Storage limit: 4 -# Amount: 5 -# Destination: KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT +from utils.message import IncreasePaidStorage def test_sign_increase_paid_storage(app: TezosAppScreen): """Check signing increase paid storage""" @@ -32,7 +26,15 @@ def test_sign_increase_paid_storage(app: TezosAppScreen): app.assert_screen(Screen.HOME) - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000007100ffdd6102321bc251e4a5190ad5b12b251069d9b4904e0203040501000000000000000000000000000000000000000000") + message = IncreasePaidStorage( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 10000, + counter = 2, + gas_limit = 3, + storage_limit = 4, + amount = 5, + destination = "KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT" + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_micheline_without_hash.py b/tests/integration/nano/test_sign_micheline_without_hash.py index e9e373dfe..5b8dee986 100755 --- a/tests/integration/nano/test_sign_micheline_without_hash.py +++ b/tests/integration/nano/test_sign_micheline_without_hash.py @@ -18,9 +18,7 @@ from pathlib import Path from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Expression: {"CACA";"POPO";"BOUDIN"} +from utils.message import MichelineExpr def test_sign_micheline_without_hash(app: TezosAppScreen): """Check signing micheline wihout getting hash""" @@ -28,7 +26,7 @@ def test_sign_micheline_without_hash(app: TezosAppScreen): app.assert_screen(Screen.HOME) - message = Message.from_bytes("05020000001d0100000004434143410100000004504f504f0100000006424f5544494e") + message = MichelineExpr([{'string': 'CACA'}, {'string': 'POPO'}, {'string': 'BOUDIN'}]) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_origination.py b/tests/integration/nano/test_sign_origination.py index 82c3da918..49da3f640 100755 --- a/tests/integration/nano/test_sign_origination.py +++ b/tests/integration/nano/test_sign_origination.py @@ -18,15 +18,7 @@ from pathlib import Path from utils.app import TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Origination -# Fee: 0.01 XTZ -# Storage limit: 4 -# Balance: 0.5 XTZ -# Delegate: Field unset -# Code: UNPAIR -# Storage: pair "1" 2 +from utils.message import Origination def test_sign_origination(app: TezosAppScreen): """Check signing origination""" @@ -34,7 +26,16 @@ def test_sign_origination(app: TezosAppScreen): app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006d00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e020304a0c21e0000000002037a0000000a07650100000001310002") + message = Origination( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 10000, + counter = 2, + gas_limit = 3, + storage_limit = 4, + code = {'prim': 'UNPAIR'}, + storage = {'prim': 'pair', 'args': [{'string': '1'}, {'int': 2}]}, + balance = 500000 + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_proposals.py b/tests/integration/nano/test_sign_proposals.py index 0cc09c172..ae29ca1f5 100755 --- a/tests/integration/nano/test_sign_proposals.py +++ b/tests/integration/nano/test_sign_proposals.py @@ -18,13 +18,7 @@ from pathlib import Path from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Proposals -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Period: 32 -# Proposal (0): ProtoALphaALphaALphaALphaALphaALphaALpha61322gcLUGH -# Proposal (1): ProtoALphaALphaALphaALphaALphaALphaALphabc2a7ebx6WB +from utils.message import Proposals def test_sign_proposals(app: TezosAppScreen): """Check signing proposals""" @@ -32,7 +26,14 @@ def test_sign_proposals(app: TezosAppScreen): app.assert_screen(Screen.HOME) - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000000500ffdd6102321bc251e4a5190ad5b12b251069d9b400000020000000400bcd7b2cadcd87ecb0d5c50330fb59feed7432bffecede8a09a2b86cfb33847b0bcd7b2cadcd87ecb0d5c50330fb59feed7432bffecede8a09a2b86dac301a2d") + message = Proposals( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + proposals = [ + 'ProtoALphaALphaALphaALphaALphaALphaALpha61322gcLUGH', + 'ProtoALphaALphaALphaALphaALphaALphaALphabc2a7ebx6WB' + ], + period = 32 + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_register_global_constant.py b/tests/integration/nano/test_sign_register_global_constant.py index 1c26424eb..4ea36859e 100755 --- a/tests/integration/nano/test_sign_register_global_constant.py +++ b/tests/integration/nano/test_sign_register_global_constant.py @@ -18,12 +18,7 @@ from pathlib import Path from utils.app import TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Register global constant -# Fee: 0.01 XTZ -# Storage limit: 4 -# Value: Pair "1" 2 +from utils.message import RegisterGlobalConstant def test_sign_register_global_constant(app: TezosAppScreen): """Check signing register global constant""" @@ -31,7 +26,14 @@ def test_sign_register_global_constant(app: TezosAppScreen): app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006f00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e0203040000000a07070100000001310002") + message = RegisterGlobalConstant( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 10000, + counter = 2, + gas_limit = 3, + storage_limit = 4, + value = {'prim': 'Pair', 'args': [{'string': '1'}, {'int': 2}]} + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_reveal.py b/tests/integration/nano/test_sign_reveal.py index b8abed62e..ec5cbd15c 100755 --- a/tests/integration/nano/test_sign_reveal.py +++ b/tests/integration/nano/test_sign_reveal.py @@ -18,12 +18,7 @@ from pathlib import Path from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Reveal -# Fee: 0.01 XTZ -# Storage limit: 4 -# Public key: edpkuXX2VdkdXzkN11oLCb8Aurdo1BTAtQiK8ZY9UPj2YMt3AHEpcY +from utils.message import Reveal def test_sign_reveal(app: TezosAppScreen): """Check signing reveal""" @@ -31,7 +26,14 @@ def test_sign_reveal(app: TezosAppScreen): app.assert_screen(Screen.HOME) - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006b00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400747884d9abdf16b3ab745158925f567e222f71225501826fa83347f6cbe9c393") + message = Reveal( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 10000, + counter = 2, + gas_limit = 3, + storage_limit = 4, + public_key = 'edpkuXX2VdkdXzkN11oLCb8Aurdo1BTAtQiK8ZY9UPj2YMt3AHEpcY' + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_sc_rollup_add_messages.py b/tests/integration/nano/test_sign_sc_rollup_add_messages.py index 5d020781e..b89e97533 100755 --- a/tests/integration/nano/test_sign_sc_rollup_add_messages.py +++ b/tests/integration/nano/test_sign_sc_rollup_add_messages.py @@ -18,14 +18,7 @@ from pathlib import Path from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): SR: send messages -# Fee: 0.01 XTZ -# Storage limit: 4 -# Message (0): 012345 -# Message (1): 67 -# Message (2): 89abcdef +from utils.message import ScRollupAddMessage def test_sign_sc_rollup_add_messages(app: TezosAppScreen): """Check signing smart rollup add message""" @@ -33,7 +26,14 @@ def test_sign_sc_rollup_add_messages(app: TezosAppScreen): app.assert_screen(Screen.HOME) - message = Message.from_bytes("030000000000000000000000000000000000000000000000000000000000000000c900ffdd6102321bc251e4a5190ad5b12b251069d9b4904e020304000000140000000301234500000001670000000489abcdef") + message = ScRollupAddMessage( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 10000, + counter = 2, + gas_limit = 3, + storage_limit = 4, + message = [bytes.fromhex('012345'), bytes.fromhex('67'), bytes.fromhex('89abcdef')] + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_sc_rollup_execute_outbox_message.py b/tests/integration/nano/test_sign_sc_rollup_execute_outbox_message.py index b5083c355..5b80577e8 100755 --- a/tests/integration/nano/test_sign_sc_rollup_execute_outbox_message.py +++ b/tests/integration/nano/test_sign_sc_rollup_execute_outbox_message.py @@ -18,14 +18,7 @@ from pathlib import Path from utils.app import TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): SR: execute outbox message -# Fee: 0.01 XTZ -# Storage limit: 4 -# Rollup: sr163Lv22CdE8QagCwf48PWDTquk6isQwv57 -# Commitment: src12UJzB8mg7yU6nWPzicH7ofJbFjyJEbHvwtZdfRXi8DQHNp1LY8 -# Output proof: 396630396632393532643334353238633733336639343631356366633339626335353536313966633535306464346136376261323230386365386538363761613364313361366566393964666265333263363937346161396132313530643231656361323963333334396535396331336239303831663163313162343430616334643334353564656462653465653064653135613861663632306434633836323437643964313332646531626236646132336435666639643864666664613232626139613834 +from utils.message import ScRollupExecuteOutboxMessage def test_sign_sc_rollup_execute_outbox_message(app: TezosAppScreen): """Check signing smart rollup execute outbox message""" @@ -33,7 +26,16 @@ def test_sign_sc_rollup_execute_outbox_message(app: TezosAppScreen): app.setup_expert_mode() - message = Message.from_bytes("030000000000000000000000000000000000000000000000000000000000000000ce00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c6396630396632393532643334353238633733336639343631356366633339626335353536313966633535306464346136376261323230386365386538363761613364313361366566393964666265333263363937346161396132313530643231656361323963333334396535396331336239303831663163313162343430616334643334353564656462653465653064653135613861663632306434633836323437643964313332646531626236646132336435666639643864666664613232626139613834") + message = ScRollupExecuteOutboxMessage( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 10000, + counter = 2, + gas_limit = 3, + storage_limit = 4, + rollup = 'sr163Lv22CdE8QagCwf48PWDTquk6isQwv57', + cemented_commitment = 'src12UJzB8mg7yU6nWPzicH7ofJbFjyJEbHvwtZdfRXi8DQHNp1LY8', + output_proof = b'9f09f2952d34528c733f94615cfc39bc555619fc550dd4a67ba2208ce8e867aa3d13a6ef99dfbe32c6974aa9a2150d21eca29c3349e59c13b9081f1c11b440ac4d3455dedbe4ee0de15a8af620d4c86247d9d132de1bb6da23d5ff9d8dffda22ba9a84' + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_sc_rollup_originate.py b/tests/integration/nano/test_sign_sc_rollup_originate.py index 7adbdfd3b..f10eacdda 100755 --- a/tests/integration/nano/test_sign_sc_rollup_originate.py +++ b/tests/integration/nano/test_sign_sc_rollup_originate.py @@ -16,19 +16,10 @@ """Check signing smart rollup originate""" from pathlib import Path +from typing import List, Optional from utils.app import TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): SR: originate -# Fee: 0.01 XTZ -# Storage limit: 4 -# Kind: arith -# Kernel: 396630396632393532643334353238633733336639343631356366633339626335353536313966633535306464346136376261323230386365386538363761613364313361366566393964666265333263363937346161396132313530643231656361323963333334396535396331336239303831663163313162343430616334643334353564656462653465653064653135613861663632306434633836323437643964313332646531626236646132336435666639643864666664613232626139613834 -# Parameters: Pair "1" 2 -# Whitelist (0): tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Whitelist (1): tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W -# Whitelist (2): tz3XMQscBFM9vPmpbYMavMmwxRMUWvWGZMQQ +from utils.message import ScRollupOriginate def test_sign_sc_rollup_originate(app: TezosAppScreen): """Check signing smart rollup originate""" @@ -36,11 +27,19 @@ def test_sign_sc_rollup_originate(app: TezosAppScreen): app.setup_expert_mode() - sc_rollup_originate_with_missing_white_list = "030000000000000000000000000000000000000000000000000000000000000000c800ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000000c63966303966323935326433343532386337333366393436313563666333396263353535363139666335353064643461363762613232303863653865383637616133643133613665663939646662653332633639373461613961323135306432316563613239633333343965353963313362393038316631633131623434306163346433343535646564626534656530646531356138616636323064346338363234376439643133326465316262366461323364356666396438646666646132326261396138340000000a07070100000001310002" - - def check_sign(name: str, whitelist: str): + def check_sign(name: str, whitelist: Optional[List[str]]): - message = Message.from_bytes(sc_rollup_originate_with_missing_white_list + whitelist) + message = ScRollupOriginate( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 10000, + counter = 2, + gas_limit = 3, + storage_limit = 4, + pvm_kind = "arith", + kernel = '396630396632393532643334353238633733336639343631356366633339626335353536313966633535306464346136376261323230386365386538363761613364313361366566393964666265333263363937346161396132313530643231656361323963333334396535396331336239303831663163313162343430616334643334353564656462653465653064653135613861663632306434633836323437643964313332646531626236646132336435666639643864666664613232626139613834', + parameters_ty = {'prim': 'Pair', 'args': [{'string': '1'}, {'int': 2}]}, + whitelist = whitelist + ) data = app.sign(DEFAULT_ACCOUNT, message, @@ -53,20 +52,12 @@ def check_sign(name: str, whitelist: str): with_hash=True, data=data) - # None - check_sign("no_whitelist", "00") - - # Some [] - check_sign("no_whitelist", "ff00000000") - - # Some [ - # tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa; - # tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W; - # tz3XMQscBFM9vPmpbYMavMmwxRMUWvWGZMQQ - # ] - check_sign( - "with_whitelist", - "ff0000003f00ffdd6102321bc251e4a5190ad5b12b251069d9b401f6552df4f5ff51c3d13347cab045cfdb8b9bd8030278eb8b6ab9a768579cd5146b480789650c83f28e" - ) + check_sign("no_whitelist", None) + check_sign("no_whitelist", []) + check_sign("with_whitelist", [ + 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + 'tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W', + 'tz3XMQscBFM9vPmpbYMavMmwxRMUWvWGZMQQ' + ]) app.quit() diff --git a/tests/integration/nano/test_sign_set_consensus_key.py b/tests/integration/nano/test_sign_set_consensus_key.py index 97afa14ba..d5bf5be6c 100755 --- a/tests/integration/nano/test_sign_set_consensus_key.py +++ b/tests/integration/nano/test_sign_set_consensus_key.py @@ -18,12 +18,7 @@ from pathlib import Path from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Set consensus key -# Fee: 0.01 XTZ -# Storage limit: 4 -# Public key: edpkuXX2VdkdXzkN11oLCb8Aurdo1BTAtQiK8ZY9UPj2YMt3AHEpcY +from utils.message import UpdateConsensusKey def test_sign_set_consensus_key(app: TezosAppScreen): """Check signing set consensus key""" @@ -31,7 +26,14 @@ def test_sign_set_consensus_key(app: TezosAppScreen): app.assert_screen(Screen.HOME) - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000007200c921d4487c90b4472da6cc566a58d79f0d991dbf904e02030400747884d9abdf16b3ab745158925f567e222f71225501826fa83347f6cbe9c393") + message = UpdateConsensusKey( + source = 'tz1dyX3B1CFYa2DfdFLyPtiJCfQRUgPVME6E', + fee = 10000, + counter = 2, + gas_limit = 3, + storage_limit = 4, + pk = "edpkuXX2VdkdXzkN11oLCb8Aurdo1BTAtQiK8ZY9UPj2YMt3AHEpcY" + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_set_deposit_limit.py b/tests/integration/nano/test_sign_set_deposit_limit.py index e90d55c30..4b2943f5c 100755 --- a/tests/integration/nano/test_sign_set_deposit_limit.py +++ b/tests/integration/nano/test_sign_set_deposit_limit.py @@ -18,12 +18,7 @@ from pathlib import Path from utils.app import Screen, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Set deposit limit -# Fee: 0.06 XTZ -# Storage limit: 4 -# Staking limit: 0.02 XTZ +from utils.message import SetDepositLimit def test_sign_set_deposit_limit(app: TezosAppScreen): """Check signing set deposit limit""" @@ -31,7 +26,14 @@ def test_sign_set_deposit_limit(app: TezosAppScreen): app.assert_screen(Screen.HOME) - message = Message.from_bytes("03000000000000000000000000000000000000000000000000000000000000000070027c252d3806e6519ed064026bdb98edf866117331e0d40304f80204ffa09c01") + message = SetDepositLimit( + source = 'tz3XeTwXXJeWNgVR3LqMcyBDdnxjbZ7TeEGH', + fee = 60000, + counter = 4, + gas_limit = 376, + storage_limit = 4, + limit = 20000 + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_too_long_operation.py b/tests/integration/nano/test_sign_too_long_operation.py index e6b76f0cc..a884081ce 100644 --- a/tests/integration/nano/test_sign_too_long_operation.py +++ b/tests/integration/nano/test_sign_too_long_operation.py @@ -19,21 +19,28 @@ from typing import Callable from utils.app import ScreenText, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message from utils.backend import StatusCode +from utils.message import ( + Message, + Proposals, + OperationGroup, + Reveal, + Transaction, + Delegation, + RegisterGlobalConstant, + SetDepositLimit, + ScRollupAddMessage +) test_path = Path(Path(__file__).stem) def _sign_too_long(app: TezosAppScreen, - msg: str, + message: Message, navigate: Callable[[], None]): - """Sign a too long message""" app.setup_expert_mode() app.setup_blindsign_on() - message = Message.from_bytes(msg) - data = app._sign( DEFAULT_ACCOUNT, message, @@ -48,18 +55,20 @@ def _sign_too_long(app: TezosAppScreen, app.quit() -def _sign_decodable_too_long(app, msg: str, path: Path): +def _sign_decodable_too_long(app: TezosAppScreen, + message: Message, + path: Path): """Sign a decodable too long message""" def navigate() -> None: app.navigate_until_text(ScreenText.ACCEPT_RISK, path / "clear_n_too_long_warning") app.navigate_until_text(ScreenText.SIGN_ACCEPT, path / "summary") - _sign_too_long(app, msg, navigate) + _sign_too_long(app, message, navigate) def _reject_too_long( app, - msg: str, + message: Message, status_code: StatusCode, navigate: Callable[[], None]): """Reject a too long message""" @@ -67,8 +76,6 @@ def _reject_too_long( app.setup_expert_mode() app.setup_blindsign_on() - message = Message.from_bytes(msg) - app._failing_signing( DEFAULT_ACCOUNT, message, @@ -83,54 +90,72 @@ def _reject_too_long( basic_test_path = test_path / "basic" -## Operation (0): Reveal -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 1 XTZ -# Storage limit: 4 -# Public key: p2pk66m3NQsd4n6LJWe9WMwx9WHeXwKmBaMwXX92WkMQCR99zmwk2PM -## Operation (1): Transaction -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 2 XTZ -# Storage limit: 7 -# Amount: 3 XTZ -# Destination: tz3XMQscBFM9vPmpbYMavMmwxRMUWvWGZMQQ -# Entrypoint: update_config -# Parameter: Pair 5 True -## Operation (2): Delegation -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 3 XTZ -# Storage limit: 5 -# Delegate: tz2W3Tvcm64GjcV2bipUynnEsctLFz5Z6yRa -## Operation (3): 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 -## Operation (4): Set deposit limit -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 1 XTZ -# Storage limit: 3 -# Staking limit: 10 XTZ -BASIC_OPERATION = "0300000000000000000000000000000000000000000000000000000000000000006b00ffdd6102321bc251e4a5190ad5b12b251069d9b4c0843d0b0104020320182716513907b6bab33f905396d031931c07e01bddd780780c1a56b9c086da6c00ffdd6102321bc251e4a5190ad5b12b251069d9b480897a0c0107c08db701000278eb8b6ab9a768579cd5146b480789650c83f28effff0d7570646174655f636f6e6669670000000607070005030a6e00ffdd6102321bc251e4a5190ad5b12b251069d9b4c08db7010d0105ff01ee572f02e5be5d097ba17369789582882e8abb87c900ffdd6102321bc251e4a5190ad5b12b251069d9b48092f4010e0106000000fa000000086d65737361676530000000086d65737361676531000000086d65737361676532000000086d65737361676533000000086d65737361676534000000086d65737361676535000000086d65737361676536000000086d65737361676537000000086d65737361676538000000086d65737361676539000000096d6573736167653130000000096d6573736167653131000000096d6573736167653132000000096d6573736167653133000000096d6573736167653134000000096d6573736167653135000000096d6573736167653136000000096d6573736167653137000000096d6573736167653138000000096d65737361676531397000ffdd6102321bc251e4a5190ad5b12b251069d9b4c0843d0f0103ff80ade204" +BASIC_OPERATION = OperationGroup([ + Reveal( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 1000000, + counter = 11, + gas_limit = 1, + storage_limit = 4, + public_key = 'p2pk66m3NQsd4n6LJWe9WMwx9WHeXwKmBaMwXX92WkMQCR99zmwk2PM' + ), + Transaction( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 2000000, + counter = 12, + gas_limit = 1, + storage_limit = 7, + destination = 'tz3XMQscBFM9vPmpbYMavMmwxRMUWvWGZMQQ', + amount = 3000000, + entrypoint = 'update_config', + parameter = {'prim': 'Pair', 'args': [ {'int': 5}, {'prim': 'True'} ]} + ), + Delegation( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 3000000, + counter = 13, + gas_limit = 1, + storage_limit = 5, + delegate = 'tz2W3Tvcm64GjcV2bipUynnEsctLFz5Z6yRa' + ), + ScRollupAddMessage( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 4000000, + counter = 14, + gas_limit = 1, + storage_limit = 6, + message = [ + bytes.fromhex('6d65737361676530'), + bytes.fromhex('6d65737361676531'), + bytes.fromhex('6d65737361676532'), + bytes.fromhex('6d65737361676533'), + bytes.fromhex('6d65737361676534'), + bytes.fromhex('6d65737361676535'), + bytes.fromhex('6d65737361676536'), + bytes.fromhex('6d65737361676537'), + bytes.fromhex('6d65737361676538'), + bytes.fromhex('6d65737361676539'), + bytes.fromhex('6d6573736167653130'), + bytes.fromhex('6d6573736167653131'), + bytes.fromhex('6d6573736167653132'), + bytes.fromhex('6d6573736167653133'), + bytes.fromhex('6d6573736167653134'), + bytes.fromhex('6d6573736167653135'), + bytes.fromhex('6d6573736167653136'), + bytes.fromhex('6d6573736167653137'), + bytes.fromhex('6d6573736167653138'), + bytes.fromhex('6d6573736167653139') + ] + ), + SetDepositLimit( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 1000000, + counter = 15, + gas_limit = 1, + storage_limit = 3, + limit = 10000000 + ) +]) def test_sign_basic_too_long_operation(app: TezosAppScreen): """Check sign too long operation""" @@ -158,120 +183,150 @@ def navigate() -> None: ### Different kind of too long operation ### -## Operation (0): Transaction -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 0 XTZ -# Storage limit: 0 -# Amount: 10 XTZ -# Destination: tz1er74kx433vTtpYddGsf3dDt5piBZeeHyQ -## Operation (1): Transaction -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 1 XTZ -# Storage limit: 1 -# Amount: 1 XTZ -# Destination: tz2PPZ2WN4j92Rdx4NM7oW3HAp3x825HUyac -## Operation (2): Transaction -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 2 XTZ -# Storage limit: 2 -# Amount: 2 XTZ -# Destination: tz1Kp8NCAN5WWwvkWkMmQQXMRe68iURmoQ8w -## Operation (3): Transaction -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 3 XTZ -# Storage limit: 3 -# Amount: 3 XTZ -# Destination: tz3fLwHKthqhTPK6Lar6CTXN1WbDETw1YpGB -## Operation (4): Transaction -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 4 XTZ -# Storage limit: 4 -# Amount: 4 XTZ -# Destination: tz3eydffbLkjdVb8zx42BvxpGV87zaRnqL3r -## Operation (5): Transaction -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 5 XTZ -# Storage limit: 5 -# Amount: 5 XTZ -# Destination: tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu def test_sign_too_long_operation_with_only_transactions(app: TezosAppScreen): """Check sign too long operation that contains only transaction""" - msg="0300000000000000000000000000000000000000000000000000000000000000006c00ffdd6102321bc251e4a5190ad5b12b251069d9b4000b010080ade2040000d2b3082b0fe03f0f7f39915cdba50e9d9b8ab057006c00ffdd6102321bc251e4a5190ad5b12b251069d9b4c0843d0c0101c0843d0001a55ae1858c1201514c97aa9122e77d3c4197a714006c00ffdd6102321bc251e4a5190ad5b12b251069d9b480897a0d010280897a000001e8e5519a315280a374c8765107979a6049de27006c00ffdd6102321bc251e4a5190ad5b12b251069d9b4c08db7010e0103c08db7010002d09584de879c4bbd3f494ed01b82e06a81e8e176006c00ffdd6102321bc251e4a5190ad5b12b251069d9b48092f4010f01048092f4010002cc8e146741cf31fc00123b8c26baf95c57421a3c006c00ffdd6102321bc251e4a5190ad5b12b251069d9b4c096b102100105c096b10200016e8874874d31c3fbd636e924d5a036a43ec8faa700" - _sign_decodable_too_long(app, msg, test_path / "only_transactions") - -## Operation (0): Proposals -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Period: 32 -# Proposal (0): ProtoDemoNoopsDemoNoopsDemoNoopsDemoNoopsDemo6XBoYp -# Proposal (1): ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im -# Proposal (2): PrihK96nBAFSxVL1GLJTVhu9YnzkMFiBeuJRPA8NwuZVZCE1L6i -# Proposal (3): Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P -# Proposal (4): PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS -# Proposal (5): PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb -# Proposal (6): PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo -# Proposal (7): PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA -# Proposal (8): PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i -# Proposal (9): PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV -# Proposal (10): PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx -# Proposal (11): Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A -# Proposal (12): PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY -# Proposal (13): PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg -# Proposal (14): PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW -# Proposal (15): PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1 -# Proposal (16): PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf -# Proposal (17): ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH -# Proposal (18): PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ -# Proposal (19): ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK + message = OperationGroup([ + Transaction( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 0, + counter = 11, + gas_limit = 1, + storage_limit = 0, + destination = 'tz1er74kx433vTtpYddGsf3dDt5piBZeeHyQ', + amount = 10000000 + ), + Transaction( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 1000000, + counter = 12, + gas_limit = 1, + storage_limit = 1, + destination = 'tz2PPZ2WN4j92Rdx4NM7oW3HAp3x825HUyac', + amount = 1000000 + ), + Transaction( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 2000000, + counter = 13, + gas_limit = 1, + storage_limit = 2, + destination = 'tz1Kp8NCAN5WWwvkWkMmQQXMRe68iURmoQ8w', + amount = 2000000 + ), + Transaction( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 3000000, + counter = 14, + gas_limit = 1, + storage_limit = 3, + destination = 'tz3fLwHKthqhTPK6Lar6CTXN1WbDETw1YpGB', + amount = 3000000 + ), + Transaction( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 4000000, + counter = 15, + gas_limit = 1, + storage_limit = 4, + destination = 'tz3eydffbLkjdVb8zx42BvxpGV87zaRnqL3r', + amount = 4000000 + ), + Transaction( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 5000000, + counter = 16, + gas_limit = 1, + storage_limit = 5, + destination = 'tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu', + amount = 5000000 + ) + ]) + _sign_decodable_too_long(app, message, test_path / "only_transactions") + def test_sign_too_long_operation_without_fee_or_amount(app: TezosAppScreen): """Check sign too long operation that doesn't have fees or amount""" - msg="0300000000000000000000000000000000000000000000000000000000000000000500ffdd6102321bc251e4a5190ad5b12b251069d9b400000020000002800bcd7db2d718ba94e85bd262681049852e1f58512aa552124330d657845c73b70bcd7ffca03f57e38453f0d3e84c302403c05357448b4c2daef8b3a8be3c69c1000000000000000000000000000000000000000000000000000000000000000038ecdef0cd08640f318a9b055f6b0d0c9ae030913a871d9b9d86fb846317da213d0b4bacb5c3e152a167da26fefc266bd3a0e14fc4e41e6c53623bf482833da23e5e3a606afab74a59ca09e333633e2770b6492c5e594455b71e9a2f0ea92afb40cab83d3f37a64da26b57ad3d0432ae881293a25169ada387bfc74a1cbf9e6ec7ad4f7a000e28e9eefc58de8ea1172de843242bd2e688779953d3416a44640b4596285c6871691e25196c6a8d26d90a3ac91375731e3926103c517a13a0ba56cbb944f74244ea2681981f25995f8ebba8ff6cee8c036892fe901cb760c4e39ece5f061e34b5a21feab8dbdfe755ef17e70c9f565464f067ac5e7c02be830a488424520cf9bbf0a42770204d95dcc1f11e404fdb3e90c84850c4cfdb50c5c4b9d0a3f07b8adfcf61f5ca60f244ca9a876e76cbad9140980f6c88d0bf900ac6d8d2ea9f23a1a1011091841b12e32ce2f8c3facff27feee58bb7c9e90567d11425d57ed88be5a69815e39386a33f7dcad391f5f507e03b376e499272c86c6cf2a7d8325f11da2ff36934a586439f085655a833f2ff6a12d15e83b951fb684326e0d9b8c2314cc05ffa3fc655a98bb87155be4cf7ce67fee6b594ea9302e8655df20bf44c7d64e3d7da27d925d10af535fb36cef0ad41930c7929773f4731eba137dbff6586a04802d3f513c65a444d9d4debe42b17e9e7273f8f6c118ea3f4e06e0bcd7b2cadcd87ecb0d5c50330fb59feed7432bffecede8a09a2b86d1527c6a5" - _sign_decodable_too_long(app, msg, test_path / "without_fee_or_amount") + message = Proposals( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + proposals = [ + 'ProtoDemoNoopsDemoNoopsDemoNoopsDemoNoopsDemo6XBoYp', + 'ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im', + 'PrihK96nBAFSxVL1GLJTVhu9YnzkMFiBeuJRPA8NwuZVZCE1L6i', + 'Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P', + 'PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS', + 'PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb', + 'PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo', + 'PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA', + 'PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i', + 'PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV', + 'PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx', + 'Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A', + 'PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY', + 'PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg', + 'PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW', + 'PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1', + 'PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf', + 'ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH', + 'PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ', + 'ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK' + ], + period = 32 + ) + _sign_decodable_too_long(app, message, test_path / "without_fee_or_amount") ### Too long operation containing a too large number ### too_large_test_path = test_path / "too_large" -# 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 -OPERATION_WITH_TOO_LARGE = "030000000000000000000000000000000000000000000000000000000000000000c900ffdd6102321bc251e4a5190ad5b12b251069d9b48092f4010b01060000017c000000086d65737361676530000000086d65737361676531000000086d65737361676532000000086d65737361676533000000086d65737361676534000000086d65737361676535000000086d65737361676536000000086d65737361676537000000086d65737361676538000000086d65737361676539000000096d6573736167653130000000096d6573736167653131000000096d6573736167653132000000096d6573736167653133000000096d6573736167653134000000096d6573736167653135000000096d6573736167653136000000096d6573736167653137000000096d6573736167653138000000096d6573736167653139000000096d6573736167653230000000096d6573736167653231000000096d6573736167653232000000096d6573736167653233000000096d6573736167653234000000096d6573736167653235000000096d6573736167653236000000096d6573736167653237000000096d6573736167653238000000096d65737361676532396f00ffdd6102321bc251e4a5190ad5b12b251069d9b4c096b1020c0103000000260080808080808080808080808080808080808080808080808080808080808080808080808020" +OPERATION_WITH_TOO_LARGE = OperationGroup([ + ScRollupAddMessage( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 4000000, + counter = 11, + gas_limit = 1, + storage_limit = 6, + message = [ + bytes.fromhex('6d65737361676530'), + bytes.fromhex('6d65737361676531'), + bytes.fromhex('6d65737361676532'), + bytes.fromhex('6d65737361676533'), + bytes.fromhex('6d65737361676534'), + bytes.fromhex('6d65737361676535'), + bytes.fromhex('6d65737361676536'), + bytes.fromhex('6d65737361676537'), + bytes.fromhex('6d65737361676538'), + bytes.fromhex('6d65737361676539'), + bytes.fromhex('6d6573736167653130'), + bytes.fromhex('6d6573736167653131'), + bytes.fromhex('6d6573736167653132'), + bytes.fromhex('6d6573736167653133'), + bytes.fromhex('6d6573736167653134'), + bytes.fromhex('6d6573736167653135'), + bytes.fromhex('6d6573736167653136'), + bytes.fromhex('6d6573736167653137'), + bytes.fromhex('6d6573736167653138'), + bytes.fromhex('6d6573736167653139'), + bytes.fromhex('6d6573736167653230'), + bytes.fromhex('6d6573736167653231'), + bytes.fromhex('6d6573736167653232'), + bytes.fromhex('6d6573736167653233'), + bytes.fromhex('6d6573736167653234'), + bytes.fromhex('6d6573736167653235'), + bytes.fromhex('6d6573736167653236'), + bytes.fromhex('6d6573736167653237'), + bytes.fromhex('6d6573736167653238'), + bytes.fromhex('6d6573736167653239') + ] + ), + RegisterGlobalConstant( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 5000000, + counter = 12, + gas_limit = 1, + storage_limit = 3, + value = {'int': 115792089237316195423570985008687907853269984665640564039457584007913129639936} + ) +]) def test_sign_too_long_operation_with_too_large(app: TezosAppScreen): """Check sign too long operation that will also fail the parsing""" diff --git a/tests/integration/nano/test_sign_transaction.py b/tests/integration/nano/test_sign_transaction.py index 1d38253d0..787c6ed8d 100755 --- a/tests/integration/nano/test_sign_transaction.py +++ b/tests/integration/nano/test_sign_transaction.py @@ -19,25 +19,27 @@ from utils.app import Screen, ScreenText, TezosAppScreen, DEFAULT_ACCOUNT from utils.backend import StatusCode -from utils.message import Message +from utils.message import Transaction test_path = Path(Path(__file__).stem) -# Operation (0): Transaction -# Source: tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu -# Fee: 0.05 XTZ -# Storage limit: 45 -# Amount: 0.24 XTZ -# Destination: KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT -# Entrypoint: do -# Parameter: CAR def test_sign_transaction(app: TezosAppScreen): """Check signing transaction""" path = test_path / "basic" app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316") + message = Transaction( + source = 'tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu', + fee = 50000, + counter = 8, + gas_limit = 54, + storage_limit = 45, + destination = 'KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT', + amount = 240000, + entrypoint = 'do', + parameter = {'prim': 'CAR'} + ) data = app.sign(DEFAULT_ACCOUNT, message, @@ -52,21 +54,23 @@ def test_sign_transaction(app: TezosAppScreen): app.quit() -# Operation (0): Transaction -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 0.01 XTZ -# Storage limit: 4 -# Amount: 0 XTZ -# Destination: KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT -# Entrypoint: root -# Data: {pair "[" (pair "Z" (pair "Y" (pair "X" (pair "W" (pair "V" (pair "U" (pair "T" (pair "S" (pair "R" (pair "Q" (pair "P" (pair "O" (pair "N" (pair "M" (pair "L" (pair "K" (pair "J" (pair "I" (pair "H" (pair "G" (pair "F" (pair "E" (pair "D" (pair "C" (pair "B" {})))))))))))))))))))))))));pair 10 (pair 9 (pair 8 (pair 7 (pair 6 (pair 5 (pair 4 (pair 3 (pair 2 (pair 1 {})))))))))} def test_reject_transaction(app: TezosAppScreen): """Check reject transaction""" path = test_path / "reject" app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e0203040001000000000000000000000000000000000000000000ff01000001070200000102076501000000015b076501000000015a0765010000000159076501000000015807650100000001570765010000000156076501000000015507650100000001540765010000000153076501000000015207650100000001510765010000000150076501000000014f076501000000014e076501000000014d076501000000014c076501000000014b076501000000014a0765010000000149076501000000014807650100000001470765010000000146076501000000014507650100000001440765010000000143076501000000014202000000000765000a0765000907650008076500070765000607650005076500040765000307650002076500010200000000") + 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},[]]}]}]}]}]}]}]}]}]}]}] + ) app.reject_signing(DEFAULT_ACCOUNT, message, @@ -75,19 +79,21 @@ def test_reject_transaction(app: TezosAppScreen): app.quit() -# Operation (0): Transaction -# Source: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Fee: 0.5 XTZ -# Storage limit: 4 -# Amount: 0.01 XTZ -# Destination: KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT def test_sign_simple_transaction(app: TezosAppScreen): """Check sign not complex transaction""" path = test_path / "simple" app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c00ffdd6102321bc251e4a5190ad5b12b251069d9b4a0c21e020304904e0100000000000000000000000000000000000000000000") + message = Transaction( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 500000, + counter = 2, + gas_limit = 3, + storage_limit = 4, + destination = 'KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT', + amount = 10000 + ) data = app.sign(DEFAULT_ACCOUNT, message, @@ -102,20 +108,22 @@ def test_sign_simple_transaction(app: TezosAppScreen): app.quit() -# Operation (0): Transaction -# Source: tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu -# Fee: 0.05 XTZ -# Storage limit: 45 -# Amount: 0.24 XTZ -# Destination: KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT -# Entrypoint: do -# Parameter: CAR def test_too_complex_transaction(app: TezosAppScreen): """Check sign complex transaction""" path = test_path / "complex" app.assert_screen(Screen.HOME) - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316") + message = Transaction( + source = 'tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu', + fee = 50000, + counter = 8, + gas_limit = 54, + storage_limit = 45, + destination = 'KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT', + amount = 240000, + entrypoint = 'do', + parameter = {'prim': 'CAR'} + ) app._failing_signing(DEFAULT_ACCOUNT, message, @@ -127,21 +135,22 @@ def test_too_complex_transaction(app: TezosAppScreen): app.quit() -# Operation (0): Transaction -# Source: tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W -# Fee: 0.04 XTZ -# Storage limit: 2 -# Amount: 1000 XTZ -# Destination: tz2CJBeWWLsUDjVUDqGZL6od3DeBCNzYXrXk -# Entrypoint: stake -# Parameter: Unit def test_sign_stake_transaction(app: TezosAppScreen): """Check sign stake""" path = test_path / "stake" app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c01f6552df4f5ff51c3d13347cab045cfdb8b9bd803c0b8020031028094ebdc0300012bad922d045c068660fabe19576f8506a1fa8fa3ff0600000002030b") + message = Transaction( + source = 'tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W', + fee = 40000, + counter = 0, + gas_limit = 49, + storage_limit = 2, + destination = 'tz2CJBeWWLsUDjVUDqGZL6od3DeBCNzYXrXk', + amount = 1000000000, + entrypoint = 'stake', + ) data = app.sign(DEFAULT_ACCOUNT, message, @@ -156,21 +165,22 @@ def test_sign_stake_transaction(app: TezosAppScreen): app.quit() -# Operation (0): Transaction -# Source: tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W -# Fee: 0.04 XTZ -# Storage limit: 2 -# Amount: 500 XTZ -# Destination: tz2CJBeWWLsUDjVUDqGZL6od3DeBCNzYXrXk -# Entrypoint: unstake -# Parameter: Unit def test_sign_unstake_transaction(app: TezosAppScreen): """Check sign unstake""" path = test_path / "unstake" app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c01f6552df4f5ff51c3d13347cab045cfdb8b9bd803c0b80200310280cab5ee0100012bad922d045c068660fabe19576f8506a1fa8fa3ff0700000002030b") + message = Transaction( + source = 'tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W', + fee = 40000, + counter = 0, + gas_limit = 49, + storage_limit = 2, + destination = 'tz2CJBeWWLsUDjVUDqGZL6od3DeBCNzYXrXk', + amount = 500000000, + entrypoint = 'unstake' + ) data = app.sign(DEFAULT_ACCOUNT, message, @@ -185,21 +195,22 @@ def test_sign_unstake_transaction(app: TezosAppScreen): app.quit() -# Operation (0): Transaction -# Source: tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W -# Fee: 0.04 XTZ -# Storage limit: 2 -# Amount: 0 XTZ -# Destination: tz2CJBeWWLsUDjVUDqGZL6od3DeBCNzYXrXk -# Entrypoint: finalize_unstake -# Parameter: Unit def test_sign_finalize_unstake_transaction(app: TezosAppScreen): """Check sign finalize_unstake""" path = test_path / "finalize_unstake" app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c01f6552df4f5ff51c3d13347cab045cfdb8b9bd803c0b8020031020000012bad922d045c068660fabe19576f8506a1fa8fa3ff0800000002030b") + message = Transaction( + source = 'tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W', + fee = 40000, + counter = 0, + gas_limit = 49, + storage_limit = 2, + destination = 'tz2CJBeWWLsUDjVUDqGZL6od3DeBCNzYXrXk', + amount = 0, + entrypoint = 'finalize_unstake' + ) data = app.sign(DEFAULT_ACCOUNT, message, @@ -214,21 +225,31 @@ def test_sign_finalize_unstake_transaction(app: TezosAppScreen): app.quit() -# Operation (0): Transaction -# Source: tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W -# Fee: 0.04 XTZ -# Storage limit: 2 -# Amount: 0 XTZ -# Destination: tz2CJBeWWLsUDjVUDqGZL6od3DeBCNzYXrXk -# Entrypoint: set_delegate_parameters -# Parameter: Pair 4000000 (Pair 20000000 Unit) def test_sign_set_delegate_parameters_transaction(app: TezosAppScreen): """Check sign set delegate parameters""" path = test_path / "delegate_parameters" app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c01f6552df4f5ff51c3d13347cab045cfdb8b9bd803c0b8020031020000012bad922d045c068660fabe19576f8506a1fa8fa3ff090000001007070080a4e80307070080b48913030b") + message = Transaction( + source = 'tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W', + fee = 40000, + counter = 0, + gas_limit = 49, + storage_limit = 2, + destination = 'tz2CJBeWWLsUDjVUDqGZL6od3DeBCNzYXrXk', + amount = 0, + entrypoint = 'delegate_parameters', + parameter = {'prim': 'Pair', + 'args': [ + {'int': 4000000}, + {'prim': 'Pair', + 'args': [ + {'int': 20000000}, + {'prim': 'Unit'} + ]} + ]} + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_transfer_ticket.py b/tests/integration/nano/test_sign_transfer_ticket.py index 708f0f61f..0712588b1 100755 --- a/tests/integration/nano/test_sign_transfer_ticket.py +++ b/tests/integration/nano/test_sign_transfer_ticket.py @@ -18,17 +18,7 @@ from pathlib import Path from utils.app import TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Transfer ticket -# Fee: 0.01 XTZ -# Storage limit: 4 -# Contents: UNPAIR -# Type: pair "1" 2 -# Ticketer: tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa -# Amount: 1 -# Destination: KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT -# Entrypoint: default +from utils.message import TransferTicket def test_sign_transfer_ticket(app: TezosAppScreen): """Check signing transfer ticket""" @@ -36,7 +26,18 @@ def test_sign_transfer_ticket(app: TezosAppScreen): app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000009e00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e02030400000002037a0000000a076501000000013100020000ffdd6102321bc251e4a5190ad5b12b251069d9b401010000000000000000000000000000000000000000000000000764656661756c74") + message = TransferTicket( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 10000, + counter = 2, + gas_limit = 3, + storage_limit = 4, + ticket_contents = {'prim': 'UNPAIR'}, + ticket_ty = {'prim': 'pair', 'args': [{'string': '1'}, {'int': 2}]}, + ticket_ticketer = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + ticket_amount = 1, + destination = 'KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT' + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_with_another_seed.py b/tests/integration/nano/test_sign_with_another_seed.py index e09089b4d..44cdc39b1 100755 --- a/tests/integration/nano/test_sign_with_another_seed.py +++ b/tests/integration/nano/test_sign_with_another_seed.py @@ -21,15 +21,7 @@ from utils.account import Account, SigType from utils.app import TezosAppScreen -from utils.message import Message - -# Operation (0): Transaction -# Fee: 0.05 XTZ -# Storage limit: 45 -# Amount: 0.24 XTZ -# Destination: KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT -# Entrypoint: do -# Parameter: CAR +from utils.message import Transaction @pytest.mark.parametrize("seed", ["around dignity equal spread between young lawsuit interest climb wide that panther rather mom snake scene ecology reunion ice illegal brush"]) def test_sign_with_another_seed(app: TezosAppScreen): @@ -42,7 +34,17 @@ def test_sign_with_another_seed(app: TezosAppScreen): SigType.ED25519, "edpkupntwMyERpYniuK1GDWquPaPU1wYsQgMirJPLGmC4Y5dMUsQNo") - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316") + message = Transaction( + source = 'tz2JPgTWZZpxZZLqHMfS69UAy1UHm4Aw5iHu', + fee = 50000, + counter = 8, + gas_limit = 54, + storage_limit = 45, + destination = 'KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT', + amount = 240000, + entrypoint = 'do', + parameter = {'prim': 'CAR'} + ) data = app.sign(account, message, diff --git a/tests/integration/nano/test_sign_with_long_hash.py b/tests/integration/nano/test_sign_with_long_hash.py index ad07111f9..7c4540986 100755 --- a/tests/integration/nano/test_sign_with_long_hash.py +++ b/tests/integration/nano/test_sign_with_long_hash.py @@ -18,15 +18,7 @@ from pathlib import Path from utils.app import TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message - -# Operation (0): Transaction -# Fee: 0.01 XTZ -# Storage limit: 4 -# Amount: 0 XTZ -# Destination: KT1GW4QHn66m7WWWMWCMNaWmGYpCRbg5ahwU -# Entrypoint: root -# Parameter: 0 +from utils.message import Transaction def test_sign_with_long_hash(app: TezosAppScreen): """Check signing transaction with a long destination hash""" @@ -34,7 +26,17 @@ def test_sign_with_long_hash(app: TezosAppScreen): app.setup_expert_mode() - message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c00ffdd6102321bc251e4a5190ad5b12b251069d9b4904e020304000156dcfb211fa76c525fd7c4566c09a5e3e4d5b81000ff01000000020000") + message = Transaction( + source = 'tz1ixvCiPJYyMjsp2nKBVaq54f6AdbV8hCKa', + fee = 10000, + counter = 2, + gas_limit = 3, + storage_limit = 4, + destination = 'KT1GW4QHn66m7WWWMWCMNaWmGYpCRbg5ahwU', + amount = 0, + entrypoint = 'root', + parameter = {'int': 0} + ) data = app.sign(DEFAULT_ACCOUNT, message, diff --git a/tests/integration/nano/test_sign_with_small_packet.py b/tests/integration/nano/test_sign_with_small_packet.py index 8a482feaf..ee02faaca 100755 --- a/tests/integration/nano/test_sign_with_small_packet.py +++ b/tests/integration/nano/test_sign_with_small_packet.py @@ -19,7 +19,7 @@ from utils.account import Account from utils.app import send_and_navigate, Screen, ScreenText, TezosAppScreen, DEFAULT_ACCOUNT -from utils.message import Message +from utils.message import Message, Transaction def test_sign_with_small_packet(app: TezosAppScreen): """Check signing using small packet instead of full size packets""" @@ -44,9 +44,21 @@ def check_sign_with_small_packet( 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=DEFAULT_ACCOUNT, - message=Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c016e8874874d31c3fbd636e924d5a036a43ec8faa7d0860308362d80d30e01000000000000000000000000000000000000000000ff02000000020316"), + message=message, path=test_name) app.quit() diff --git a/tests/integration/nano/test_tz1_bip25519_sign_micheline_basic.py b/tests/integration/nano/test_tz1_bip25519_sign_micheline_basic.py index 6d5ec7414..f021bb746 100755 --- a/tests/integration/nano/test_tz1_bip25519_sign_micheline_basic.py +++ b/tests/integration/nano/test_tz1_bip25519_sign_micheline_basic.py @@ -19,9 +19,7 @@ from utils.account import Account, SigType from utils.app import Screen, TezosAppScreen -from utils.message import Message - -# Expression: {"CACA";"POPO";"BOUDIN"} +from utils.message import MichelineExpr def test_tz1_bip25519_sign_micheline_basic(app: TezosAppScreen): """Check signing with bip25519""" @@ -33,7 +31,7 @@ def test_tz1_bip25519_sign_micheline_basic(app: TezosAppScreen): SigType.BIP32_ED25519, "edpkumJgSsSxkpiB5hmTq6eZcrmc6BsJtLAhYceFTiziFqje4mongz") - message = Message.from_bytes("05020000001d0100000004434143410100000004504f504f0100000006424f5544494e") + message = MichelineExpr([{'string': 'CACA'}, {'string': 'POPO'}, {'string': 'BOUDIN'}]) data = app.sign(account, message, diff --git a/tests/integration/nano/test_tz1_ed25519_sign_micheline_basic.py b/tests/integration/nano/test_tz1_ed25519_sign_micheline_basic.py index 05fa1d95f..6bc992ed8 100755 --- a/tests/integration/nano/test_tz1_ed25519_sign_micheline_basic.py +++ b/tests/integration/nano/test_tz1_ed25519_sign_micheline_basic.py @@ -19,9 +19,7 @@ from utils.account import Account, SigType from utils.app import Screen, TezosAppScreen -from utils.message import Message - -# Expression: {"CACA";"POPO";"BOUDIN"} +from utils.message import MichelineExpr def test_tz1_ed25519_sign_micheline_basic(app: TezosAppScreen): """Check signing with ed25519""" @@ -33,7 +31,7 @@ def test_tz1_ed25519_sign_micheline_basic(app: TezosAppScreen): SigType.ED25519, "edpkuXX2VdkdXzkN11oLCb8Aurdo1BTAtQiK8ZY9UPj2YMt3AHEpcY") - message = Message.from_bytes("05020000001d0100000004434143410100000004504f504f0100000006424f5544494e") + message = MichelineExpr([{'string': 'CACA'}, {'string': 'POPO'}, {'string': 'BOUDIN'}]) data = app.sign(account, message, diff --git a/tests/integration/nano/test_tz2_sign_micheline_basic.py b/tests/integration/nano/test_tz2_sign_micheline_basic.py index fa29e13f0..7ca2efd20 100755 --- a/tests/integration/nano/test_tz2_sign_micheline_basic.py +++ b/tests/integration/nano/test_tz2_sign_micheline_basic.py @@ -19,9 +19,7 @@ from utils.account import Account, SigType from utils.app import TezosAppScreen -from utils.message import Message - -# Expression: {"CACA";"POPO";"BOUDIN"} +from utils.message import MichelineExpr def test_tz2_sign_micheline_basic(app: TezosAppScreen): """Check signing with secp256k1""" @@ -31,7 +29,7 @@ def test_tz2_sign_micheline_basic(app: TezosAppScreen): SigType.SECP256K1, "sppk7bVy617DmGvXsMqcwsiLtnedTN2trUi5ugXcNig7en4rHJyunK1") - message = Message.from_bytes("05020000001d0100000004434143410100000004504f504f0100000006424f5544494e") + message = MichelineExpr([{'string': 'CACA'}, {'string': 'POPO'}, {'string': 'BOUDIN'}]) data = app.sign(account, message, diff --git a/tests/integration/nano/test_tz3_sign_micheline_basic.py b/tests/integration/nano/test_tz3_sign_micheline_basic.py index f0839b34d..9bd28aa3b 100755 --- a/tests/integration/nano/test_tz3_sign_micheline_basic.py +++ b/tests/integration/nano/test_tz3_sign_micheline_basic.py @@ -19,9 +19,7 @@ from utils.account import Account, SigType from utils.app import TezosAppScreen -from utils.message import Message - -# Expression: {"CACA";"POPO";"BOUDIN"} +from utils.message import MichelineExpr def test_tz3_sign_micheline_basic(app: TezosAppScreen): """Check signing with p256""" @@ -31,7 +29,7 @@ def test_tz3_sign_micheline_basic(app: TezosAppScreen): SigType.SECP256R1, "p2pk67fq5pzuMMABZ9RDrooYbLrgmnQbLt8z7PTGM9mskf7LXS5tdBG") - message = Message.from_bytes("05020000001d0100000004434143410100000004504f504f0100000006424f5544494e") + message = MichelineExpr([{'string': 'CACA'}, {'string': 'POPO'}, {'string': 'BOUDIN'}]) data = app.sign(account, message, diff --git a/tests/integration/nano/utils/message.py b/tests/integration/nano/utils/message.py index 488803024..209e06ccf 100644 --- a/tests/integration/nano/utils/message.py +++ b/tests/integration/nano/utils/message.py @@ -14,35 +14,783 @@ """Implemenation of sent messages.""" -from hashlib import blake2b -from typing import Union +from abc import ABC, abstractmethod +from enum import IntEnum +from typing import Any, Dict, List, Optional, Union -class Message: - """Class representing messages.""" +from pytezos.block.forge import forge_int_fixed +from pytezos.crypto.key import blake2b_32 +from pytezos.michelson.forge import ( + forge_address, + forge_array, + forge_base58, + forge_bool, + forge_int32, + forge_micheline, + forge_nat, + forge_public_key, +) +from pytezos.operation.content import ContentMixin, format_mutez +import pytezos.operation.forge as forge_operation +from pytezos.operation.forge import reserved_entrypoints, forge_tag +from pytezos.rpc.kind import operation_tags - HASH_SIZE = 32 +class Message(ABC): + """Class representing a message.""" - value: bytes + @property + def hash(self) -> bytes: + """hash of the message.""" + return blake2b_32(bytes(self)).digest() - def __init__(self, value: bytes): - self.value = value + @abstractmethod + def __bytes__(self) -> bytes: + raise NotImplementedError - @classmethod - def from_bytes(cls, value: Union[str, bytes]) -> 'Message': - """Get message from bytes or hex.""" +class RawMessage(Message): + """Class representing a raw message.""" - if isinstance(value, str): - value = bytes.fromhex(value) - return cls(value) + _value: bytes - @property - def hash(self) -> bytes: - """Hash of the message.""" + def __init__(self, value: Union[str, bytes]): + self._value = value if isinstance(value, bytes) else \ + bytes.fromhex(value) + + def __bytes__(self) -> bytes: + return self._value + + +Micheline = Union[List, Dict] + +class Default: + """Class holding default values.""" + BLOCK_HASH: str = 'BKiHLREqU3JkXfzEDYAkmmfX48gBDtYhMrpA98s7Aq4SzbUAB6M' + PROTOCOL_HASH: str = 'PrihK96nBAFSxVL1GLJTVhu9YnzkMFiBeuJRPA8NwuZVZCE1L6i' + ED25519_PUBLIC_KEY_HASH: str = 'tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU' + ORIGINATED_ADDRESS: str = 'KT18amZmM5W7qDWVt2pH6uj7sCEd3kbzLrHT' + ORIGINATED_SMART_ROLLUP_ADDRESS: str = 'sr163Lv22CdE8QagCwf48PWDTquk6isQwv57' + SMART_ROLLUP_COMMITMENT_HASH: str = 'src12UJzB8mg7yU6nWPzicH7ofJbFjyJEbHvwtZdfRXi8DQHNp1LY8' + ED25519_PUBLIC_KEY: str = 'edpkteDwHwoNPB18tKToFKeSCykvr1ExnoMV5nawTJy9Y9nLTfQ541' + ENTRYPOINT: str = 'default' + BALLOT: str = 'yay' + SMART_ROLLUP_KIND: str = 'arith' + + class DefaultMicheline: + """Class holding Micheline default values.""" + VALUE: Micheline = {'prim': 'Unit'} + TYPE: Micheline = {'prim': 'unit'} + CODE: Micheline = [{'prim': 'CDR'}, {'prim': 'NIL', 'args': [{'prim': 'operation'}]}, {'prim': 'PAIR'}] + +class Watermark(IntEnum): + """Class hodling messages watermark.""" + MANAGER_OPERATION = 0x03 + MICHELINE_EXPRESSION = 0x05 + + +class MichelineExpr(Message): + """Class representing a tezos micheline expression.""" + + expr: Micheline + + def __init__(self, expr: Micheline): + self.expr = expr + + def __bytes__(self) -> bytes: + raw = b'' + raw += forge_int_fixed(Watermark.MICHELINE_EXPRESSION, 1) + raw += forge_micheline(self.expr) + return raw + + +class OperationBuilder(ContentMixin): + """Class representing to extends and fix pytezos.ContentMixin.""" + + def delegation(self, delegate, *args, **kwargs): + delegation = super().delegation(delegate, *args, **kwargs) + + if delegate is None: + delegation.pop('delegate') + + return delegation + + def set_deposit_limit( + self, + limit: Optional[int] = None, + source: str = '', + counter: int = 0, + fee: int = 0, + gas_limit: int = 0, + storage_limit: int = 0): + """Build a Tezos set-deposit-limit.""" + content = { + 'kind': 'set_deposit_limit', + 'source': source, + 'fee': format_mutez(fee), + 'counter': str(counter), + 'gas_limit': str(gas_limit), + 'storage_limit': str(storage_limit), + } + + if limit is not None: + content['limit'] = format_mutez(limit) + + return self.operation(content) + + def increase_paid_storage( + self, + amount: int = 0, + destination: str = '', + source: str = '', + counter: int = 0, + fee: int = 0, + gas_limit: int = 0, + storage_limit: int = 0): + """Build a Tezos increase-paid-storage.""" + return self.operation( + { + 'kind': 'increase_paid_storage', + 'source': source, + 'fee': format_mutez(fee), + 'counter': str(counter), + 'gas_limit': str(gas_limit), + 'storage_limit': str(storage_limit), + 'amount': str(amount), + 'destination': destination, + } + ) + + def update_consensus_key( + self, + pk: str = '', + source: str = '', + counter: int = 0, + fee: int = 0, + gas_limit: int = 0, + storage_limit: int = 0): + """Build a Tezos update-consensus-key.""" + return self.operation( + { + 'kind': 'update_consensus_key', + 'source': source, + 'fee': format_mutez(fee), + 'counter': str(counter), + 'gas_limit': str(gas_limit), + 'storage_limit': str(storage_limit), + 'pk': pk, + } + ) + + def smart_rollup_originate( + self, + pvm_kind: str = '', + kernel: str = '', + parameters_ty: Micheline = Default.DefaultMicheline.TYPE, + whitelist: Optional[List[str]] = None, + source: str = '', + counter: int = 0, + fee: int = 0, + gas_limit: int = 0, + storage_limit: int = 0): + """Build a Tezos smart rollup originate.""" + content = { + 'kind': 'smart_rollup_originate', + 'source': source, + 'fee': format_mutez(fee), + 'counter': str(counter), + 'gas_limit': str(gas_limit), + 'storage_limit': str(storage_limit), + 'pvm_kind': pvm_kind, + 'kernel': kernel, + 'parameters_ty': parameters_ty, + } - return blake2b( - self.value, - digest_size=Message.HASH_SIZE - ).digest() + if whitelist is not None: + content['whitelist'] = whitelist + + return self.operation(content) + +class OperationForge: + """Class to helps forging Tezos operation.""" + + # Insert new reserved entrypoint + reserved_entrypoints['stake'] = b'\x06' + reserved_entrypoints['unstake'] = b'\x07' + reserved_entrypoints['finalize_unstake'] = b'\x08' + reserved_entrypoints['delegate_parameters'] = b'\x09' + + # Insert new operation tag + operation_tags['set_deposit_limit'] = 112 + operation_tags['increase_paid_storage'] = 113 + operation_tags['update_consensus_key'] = 114 + operation_tags['smart_rollup_originate'] = 200 + + failing_noop = forge_operation.forge_failing_noop + reveal = forge_operation.forge_reveal + transaction = forge_operation.forge_transaction + origination = forge_operation.forge_origination + delegation = forge_operation.forge_delegation + register_global_constant = forge_operation.forge_register_global_constant + transfer_ticket = forge_operation.forge_transfer_ticket + smart_rollup_add_messages = forge_operation.forge_smart_rollup_add_messages + smart_rollup_execute_outbox_message = forge_operation.forge_smart_rollup_execute_outbox_message + + @staticmethod + def proposals(content: Dict[str, Any]) -> bytes: + """Forge a Tezos proposals.""" + res = forge_tag(operation_tags[content['kind']]) + res += forge_address(content['source'], tz_only=True) + res += forge_int32(int(content['period'])) + res += forge_array(b''.join(map(forge_base58, content['proposals']))) + return res + + BALLOT_TAG = { 'yay': 0, 'nay': 1, 'pass': 2 } + + @staticmethod + def ballot(content: Dict[str, Any]) -> bytes: + """Forge a Tezos ballot.""" + res = forge_tag(operation_tags[content['kind']]) + res += forge_address(content['source'], tz_only=True) + res += forge_int32(int(content['period'])) + res += forge_base58(content['proposal']) + res += forge_int_fixed(OperationForge.BALLOT_TAG[content['ballot']], 1) + return res + + @staticmethod + def set_deposit_limit(content: Dict[str, Any]) -> bytes: + """Forge a Tezos set-deposit-limit.""" + res = forge_tag(operation_tags[content['kind']]) + res += forge_address(content['source'], tz_only=True) + res += forge_nat(int(content['fee'])) + res += forge_nat(int(content['counter'])) + res += forge_nat(int(content['gas_limit'])) + res += forge_nat(int(content['storage_limit'])) + + if content.get('limit'): + res += forge_bool(True) + res += forge_nat(int(content['limit'])) + else: + res += forge_bool(False) + + return res + + @staticmethod + def increase_paid_storage(content: Dict[str, Any]) -> bytes: + """Forge a Tezos increase-paid-storage.""" + res = forge_tag(operation_tags[content['kind']]) + res += forge_address(content['source'], tz_only=True) + res += forge_nat(int(content['fee'])) + res += forge_nat(int(content['counter'])) + res += forge_nat(int(content['gas_limit'])) + res += forge_nat(int(content['storage_limit'])) + res += forge_nat(int(content['amount'])) + res += forge_address(content['destination']) + return res + + @staticmethod + def update_consensus_key(content: Dict[str, Any]) -> bytes: + """Forge a Tezos update-consensus-key.""" + res = forge_tag(operation_tags[content['kind']]) + res += forge_address(content['source'], tz_only=True) + res += forge_nat(int(content['fee'])) + res += forge_nat(int(content['counter'])) + res += forge_nat(int(content['gas_limit'])) + res += forge_nat(int(content['storage_limit'])) + res += forge_public_key(content['pk']) + return res + + PVM_KIND_TAG = { 'arith': 0, 'wasm_2_0_0': 1, 'riscv': 2 } + + @staticmethod + def smart_rollup_originate(content: Dict[str, Any]) -> bytes: + """Forge a Tezos smart rollup originate.""" + res = forge_tag(operation_tags[content['kind']]) + res += forge_address(content['source'], tz_only=True) + res += forge_nat(int(content['fee'])) + res += forge_nat(int(content['counter'])) + res += forge_nat(int(content['gas_limit'])) + res += forge_nat(int(content['storage_limit'])) + res += forge_int_fixed( + OperationForge.PVM_KIND_TAG[content['pvm_kind']], 1 + ) + res += forge_array(bytes.fromhex(content['kernel'])) + res += forge_array(forge_micheline(content['parameters_ty'])) + + if content.get('whitelist') is not None: + res += forge_bool(True) + res += forge_array(b''.join( + forge_address(pkh, tz_only=True) + for pkh in content['whitelist'] + )) + else: + res += forge_bool(False) + + return res + +class Operation(Message, OperationBuilder): + """Class representing a tezos operation.""" + + branch: str + + def __init__(self, branch: str = Default.BLOCK_HASH): + self.branch = branch + + @abstractmethod + def forge(self) -> bytes: + """Forge the operation.""" + raise NotImplementedError def __bytes__(self) -> bytes: - return self.value + raw = b'' + raw += forge_int_fixed(Watermark.MANAGER_OPERATION, 1) + raw += forge_base58(self.branch) + raw += self.forge() + return raw + +class Proposals(Operation): + """Class representing a tezos proposals.""" + + proposals_: List[str] + source: str + period: int + + def __init__(self, + proposals: List[str] = [Default.PROTOCOL_HASH], + source: str = Default.ED25519_PUBLIC_KEY_HASH, + period: int = 0, + **kwargs): + self.proposals_ = proposals + self.source = source + self.period = period + Operation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return OperationForge.proposals( + self.proposals( + self.proposals_, + self.source, + self.period + ) + ) + +class Ballot(Operation): + """Class representing a tezos ballot.""" + + proposal : str + ballot_ : str + source : str + period: int + + def __init__(self, + proposal: str = Default.PROTOCOL_HASH, + ballot: str = Default.BALLOT, + source: str = Default.ED25519_PUBLIC_KEY_HASH, + period: int = 0, + **kwargs): + self.proposal = proposal + self.ballot_ = ballot + self.source = source + self.period = period + Operation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return OperationForge.ballot( + self.ballot( + self.proposal, + self.ballot_, + self.source, + self.period + ) + ) + +class FailingNoop(Operation): + """Class representing a tezos failing-noop.""" + + message: str + + def __init__(self, message: str = "", **kwargs): + self.message = message + Operation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return OperationForge.failing_noop(self.failing_noop(self.message)) + +class ManagerOperation(Operation): + """Class representing a tezos manager operation.""" + + source: str + fee: int + counter: int + gas_limit: int + storage_limit: int + + def __init__(self, + source: str = Default.ED25519_PUBLIC_KEY_HASH, + fee: int = 0, + counter: int = 0, + gas_limit: int = 0, + storage_limit: int = 0, + **kwargs): + self.source = source + self.fee = fee + self.counter = counter + self.gas_limit = gas_limit + self.storage_limit = storage_limit + Operation.__init__(self, **kwargs) + +class OperationGroup(Operation): + """Class representing a group of tezos manager operation.""" + + operations: List[ManagerOperation] + + def __init__(self, + operations: List[ManagerOperation] = [], + **kwargs): + self.operations = operations + Operation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return b''.join(map(lambda op: op.forge(), self.operations)) + +class Reveal(ManagerOperation): + """Class representing a tezos reveal.""" + + public_key: str + + def __init__(self, + public_key: str = Default.ED25519_PUBLIC_KEY, + **kwargs): + self.public_key = public_key + ManagerOperation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return OperationForge.reveal( + self.reveal( + self.public_key, + self.source, + self.counter, + self.fee, + self.gas_limit, + self.storage_limit + ) + ) + +class Transaction(ManagerOperation): + """Class representing a tezos transaction.""" + + destination: str + amount: int + entrypoint: str + parameter: Micheline + + def __init__(self, + destination: str = Default.ED25519_PUBLIC_KEY_HASH, + amount: int = 0, + entrypoint: str = Default.ENTRYPOINT, + parameter: Micheline = Default.DefaultMicheline.VALUE, + **kwargs): + self.destination = destination + self.amount = amount + self.entrypoint = entrypoint + self.parameter = parameter + ManagerOperation.__init__(self, **kwargs) + + def forge(self) -> bytes: + parameters = { "entrypoint": self.entrypoint, "value": self.parameter } + return OperationForge.transaction( + self.transaction( + self.destination, + self.amount, + parameters, + self.source, + self.counter, + self.fee, + self.gas_limit, + self.storage_limit + ) + ) + +class Origination(ManagerOperation): + """Class representing a tezos origination.""" + + code: Micheline + storage: Micheline + balance: int + delegate: Optional[str] + + def __init__(self, + code: Micheline = Default.DefaultMicheline.CODE, + storage: Micheline = Default.DefaultMicheline.TYPE, + balance: int = 0, + delegate: Optional[str] = None, + **kwargs): + self.code = code + self.storage = storage + self.balance = balance + self.delegate = delegate + ManagerOperation.__init__(self, **kwargs) + + def forge(self) -> bytes: + script = { "code": self.code, "storage": self.storage } + return OperationForge.origination( + self.origination( + script, + self.balance, + self.delegate, + self.source, + self.counter, + self.fee, + self.gas_limit, + self.storage_limit + ) + ) + +class Delegation(ManagerOperation): + """Class representing a tezos delegation.""" + + delegate: Optional[str] + + def __init__(self, + delegate: Optional[str] = None, + **kwargs): + self.delegate = delegate + ManagerOperation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return OperationForge.delegation( + self.delegation( + self.delegate, + self.source, + self.counter, + self.fee, + self.gas_limit, + self.storage_limit + ) + ) + +class RegisterGlobalConstant(ManagerOperation): + """Class representing a tezos register global constant.""" + + value: Micheline + + def __init__(self, + value: Micheline = Default.DefaultMicheline.VALUE, + **kwargs): + self.value = value + ManagerOperation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return OperationForge.register_global_constant( + self.register_global_constant( + self.value, + self.source, + self.counter, + self.fee, + self.gas_limit, + self.storage_limit + ) + ) + +class SetDepositLimit(ManagerOperation): + """Class representing a tezos set deposit limit.""" + + limit: Optional[int] + + def __init__(self, + limit: Optional[int] = None, + **kwargs): + self.limit = limit + ManagerOperation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return OperationForge.set_deposit_limit( + self.set_deposit_limit( + self.limit, + self.source, + self.counter, + self.fee, + self.gas_limit, + self.storage_limit + ) + ) + +class IncreasePaidStorage(ManagerOperation): + """Class representing a tezos increase paid storage.""" + + amount: int + destination: str + + def __init__(self, + amount: int = 0, + destination: str = Default.ORIGINATED_ADDRESS, + **kwargs): + self.amount = amount + self.destination = destination + ManagerOperation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return OperationForge.increase_paid_storage( + self.increase_paid_storage( + self.amount, + self.destination, + self.source, + self.counter, + self.fee, + self.gas_limit, + self.storage_limit + ) + ) + +class UpdateConsensusKey(ManagerOperation): + """Class representing a tezos update consensus key.""" + + pk: str + + def __init__(self, + pk: str = Default.ED25519_PUBLIC_KEY, + **kwargs): + self.pk = pk + ManagerOperation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return OperationForge.update_consensus_key( + self.update_consensus_key( + self.pk, + self.source, + self.counter, + self.fee, + self.gas_limit, + self.storage_limit + ) + ) + +class TransferTicket(ManagerOperation): + """Class representing a tezos transfer ticket.""" + + ticket_contents: Micheline + ticket_ty: Micheline + ticket_ticketer: str + ticket_amount: int + destination: str + entrypoint: str + + def __init__(self, + ticket_contents: Micheline = Default.DefaultMicheline.VALUE, + ticket_ty: Micheline = Default.DefaultMicheline.TYPE, + ticket_ticketer: str = Default.ORIGINATED_ADDRESS, + ticket_amount: int = 0, + destination: str = Default.ORIGINATED_ADDRESS, + entrypoint: str = Default.ENTRYPOINT, + **kwargs): + self.ticket_contents = ticket_contents + self.ticket_ty = ticket_ty + self.ticket_ticketer = ticket_ticketer + self.ticket_amount = ticket_amount + self.destination = destination + self.entrypoint = entrypoint + ManagerOperation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return OperationForge.transfer_ticket( + self.transfer_ticket( + self.ticket_contents, + self.ticket_ty, + self.ticket_ticketer, + self.ticket_amount, + self.destination, + self.entrypoint, + self.source, + self.counter, + self.fee, + self.gas_limit, + self.storage_limit + ) + ) + +class ScRollupOriginate(ManagerOperation): + """Class representing a tezos smart rollup originate.""" + + pvm_kind: str + kernel: str + parameters_ty: Micheline + whitelist: Optional[List[str]] + + def __init__(self, + pvm_kind: str = Default.SMART_ROLLUP_KIND, + kernel: str = "", + parameters_ty: Micheline = Default.DefaultMicheline.TYPE, + whitelist: Optional[List[str]] = None, + **kwargs): + self.pvm_kind = pvm_kind + self.kernel = kernel + self.parameters_ty = parameters_ty + self.whitelist = whitelist + ManagerOperation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return OperationForge.smart_rollup_originate( + self.smart_rollup_originate( + self.pvm_kind, + self.kernel, + self.parameters_ty, + self.whitelist, + self.source, + self.counter, + self.fee, + self.gas_limit, + self.storage_limit + ) + ) + +class ScRollupAddMessage(ManagerOperation): + """Class representing a tezos smart rollup add message.""" + + message: List[bytes] + + def __init__(self, + message: List[bytes] = [b''], + **kwargs): + self.message = message + ManagerOperation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return OperationForge.smart_rollup_add_messages( + self.smart_rollup_add_messages( + self.message, + self.source, + self.counter, + self.fee, + self.gas_limit, + self.storage_limit + ) + ) + +class ScRollupExecuteOutboxMessage(ManagerOperation): + """Class representing a tezos smart rollup execute outbox message.""" + + rollup: str + cemented_commitment: str + output_proof: bytes + + def __init__(self, + rollup: str = Default.ORIGINATED_SMART_ROLLUP_ADDRESS, + cemented_commitment: str = Default.SMART_ROLLUP_COMMITMENT_HASH, + output_proof: bytes = b'', + **kwargs): + self.rollup = rollup + self.cemented_commitment = cemented_commitment + self.output_proof = output_proof + ManagerOperation.__init__(self, **kwargs) + + def forge(self) -> bytes: + return OperationForge.smart_rollup_execute_outbox_message( + self.smart_rollup_execute_outbox_message( + self.rollup, + self.cemented_commitment, + self.output_proof, + self.source, + self.counter, + self.fee, + self.gas_limit, + self.storage_limit + ) + )