From d33688159b98dec299559d248aaa8c16d2f26155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Palmer?= Date: Mon, 5 Feb 2024 16:13:54 +0100 Subject: [PATCH] Tests: add a test check transaction cannot be signed --- test/python/test_instructions.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/python/test_instructions.py b/test/python/test_instructions.py index d2cca551..6d92cf23 100644 --- a/test/python/test_instructions.py +++ b/test/python/test_instructions.py @@ -3,6 +3,7 @@ from pathlib import Path from typing import Callable, Tuple import pytest +from pytezos import pytezos from ragger.firmware import Firmware from ragger.navigator import NavInsID from utils.client import TezosClient, Version, Hwm, StatusCode @@ -10,6 +11,7 @@ from utils.helper import get_current_commit from utils.message import ( Message, + UnsafeOp, Delegation, Preattestation, Attestation, @@ -709,6 +711,36 @@ def test_sign_not_authorized_key( client.sign_message(account_2, attestation) +def test_sign_transaction( + client: TezosClient, + tezos_navigator: TezosNavigator) -> None: + """Check that signing a transaction is not allowed.""" + + account_1 = DEFAULT_ACCOUNT + account_2 = DEFAULT_ACCOUNT_2 + + main_chain_id = DEFAULT_CHAIN_ID + + tezos_navigator.setup_app_context( + account_1, + main_chain_id, + main_hwm=Hwm(0), + test_hwm=Hwm(0) + ) + + ctxt = pytezos.using() + transaction = UnsafeOp( + ctxt.transaction( + source=account_1.public_key_hash, + destination=account_2.public_key_hash, + amount=10_000, + ) + ).forge() + + with StatusCode.PARSE_ERROR.expected(): + client.sign_message(account_1, transaction) + + def test_sign_when_no_chain_setup( client: TezosClient, tezos_navigator: TezosNavigator) -> None: