From fddeb2d507a57e9a78e27f681c8539361efeade8 Mon Sep 17 00:00:00 2001 From: Bartosz Rybarski Date: Thu, 18 May 2023 11:49:14 +0200 Subject: [PATCH] Created constants for declare tx versions. --- test/rpc/test_rpc_estimate_fee.py | 19 +++++++++---------- test/rpc/test_rpc_transactions.py | 11 ++++++----- test/shared.py | 3 +++ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/test/rpc/test_rpc_estimate_fee.py b/test/rpc/test_rpc_estimate_fee.py index 5ec5ebfd0..e00798aeb 100644 --- a/test/rpc/test_rpc_estimate_fee.py +++ b/test/rpc/test_rpc_estimate_fee.py @@ -9,9 +9,11 @@ from test.rpc.rpc_utils import rpc_call_background_devnet from test.rpc.test_rpc_transactions import pad_zero_entry_points from test.shared import ( + DEPRECATED_RPC_DECLARE_TX_VERSION, PREDEPLOY_ACCOUNT_CLI_ARGS, PREDEPLOYED_ACCOUNT_ADDRESS, PREDEPLOYED_ACCOUNT_PRIVATE_KEY, + SUPPORTED_RPC_DECLARE_TX_VERSION, SUPPORTED_RPC_TX_VERSION, ) from test.test_account import deploy_empty_contract @@ -181,14 +183,14 @@ def test_estimate_fee_declare_v1(declare_content): sender_address=int(PREDEPLOYED_ACCOUNT_ADDRESS, 16), max_fee=0, nonce=nonce, - version=SUPPORTED_RPC_TX_VERSION, + version=DEPRECATED_RPC_DECLARE_TX_VERSION, ) signature = _get_signature(tx_hash, PREDEPLOYED_ACCOUNT_PRIVATE_KEY) declare_transaction = RpcBroadcastedDeclareTxnV1( type=declare_content["type"], max_fee=rpc_felt(0), - version=hex(SUPPORTED_RPC_TX_VERSION), + version=hex(DEPRECATED_RPC_DECLARE_TX_VERSION), signature=[rpc_felt(sig) for sig in signature], nonce=rpc_felt(nonce), contract_class=_rpc_contract_class, @@ -209,7 +211,6 @@ def test_estimate_fee_declare_v2(): """ contract_class, _, compiled_class_hash = load_cairo1_contract() - version = 2 nonce = get_nonce(PREDEPLOYED_ACCOUNT_ADDRESS) tx_hash = calculate_declare_transaction_hash( @@ -218,7 +219,7 @@ def test_estimate_fee_declare_v2(): chain_id=StarknetChainId.TESTNET.value, sender_address=int(PREDEPLOYED_ACCOUNT_ADDRESS, 16), max_fee=0, - version=version, + version=SUPPORTED_RPC_DECLARE_TX_VERSION, nonce=nonce, ) @@ -229,7 +230,7 @@ def test_estimate_fee_declare_v2(): sender_address=PREDEPLOYED_ACCOUNT_ADDRESS, compiled_class_hash=rpc_felt(compiled_class_hash), type="DECLARE", - version=rpc_felt(version), + version=rpc_felt(SUPPORTED_RPC_DECLARE_TX_VERSION), nonce=rpc_felt(nonce), max_fee=rpc_felt(0), signature=list(map(rpc_felt, signature)), @@ -254,7 +255,7 @@ def test_estimate_multiple_transactions(): invoke_transaction = RpcBroadcastedInvokeTxnV1( type="INVOKE", max_fee=rpc_felt(0), - version=hex(SUPPORTED_RPC_TX_VERSION), + version=hex(DEPRECATED_RPC_DECLARE_TX_VERSION), signature=[rpc_felt(sig) for sig in signature], nonce=rpc_felt(nonce), sender_address=rpc_felt(PREDEPLOYED_ACCOUNT_ADDRESS), @@ -262,8 +263,6 @@ def test_estimate_multiple_transactions(): ) contract_class, _, compiled_class_hash = load_cairo1_contract() - - version = 2 nonce += 1 tx_hash = calculate_declare_transaction_hash( @@ -272,7 +271,7 @@ def test_estimate_multiple_transactions(): chain_id=StarknetChainId.TESTNET.value, sender_address=int(PREDEPLOYED_ACCOUNT_ADDRESS, 16), max_fee=0, - version=version, + version=SUPPORTED_RPC_DECLARE_TX_VERSION, nonce=nonce, ) @@ -283,7 +282,7 @@ def test_estimate_multiple_transactions(): sender_address=PREDEPLOYED_ACCOUNT_ADDRESS, compiled_class_hash=rpc_felt(compiled_class_hash), type="DECLARE", - version=rpc_felt(version), + version=rpc_felt(SUPPORTED_RPC_DECLARE_TX_VERSION), nonce=rpc_felt(nonce), max_fee=rpc_felt(0), signature=list(map(rpc_felt, signature)), diff --git a/test/rpc/test_rpc_transactions.py b/test/rpc/test_rpc_transactions.py index 2714c6563..b2bc713f3 100644 --- a/test/rpc/test_rpc_transactions.py +++ b/test/rpc/test_rpc_transactions.py @@ -21,11 +21,13 @@ from test.shared import ( ABI_PATH, CONTRACT_PATH, + DEPRECATED_RPC_DECLARE_TX_VERSION, EXPECTED_UDC_ADDRESS, INCORRECT_GENESIS_BLOCK_HASH, PREDEPLOYED_ACCOUNT_ADDRESS, PREDEPLOYED_ACCOUNT_PRIVATE_KEY, STARKNET_CLI_ACCOUNT_ABI_PATH, + SUPPORTED_RPC_DECLARE_TX_VERSION, SUPPORTED_RPC_TX_VERSION, ) from test.test_declare_v2 import load_cairo1_contract @@ -549,7 +551,7 @@ def test_add_declare_transaction_on_incorrect_contract(declare_content): declare_transaction = RpcBroadcastedDeclareTxnV1( type=declare_content["type"], max_fee=rpc_felt(declare_content["max_fee"]), - version=hex(SUPPORTED_RPC_TX_VERSION), + version=hex(DEPRECATED_RPC_DECLARE_TX_VERSION), signature=[rpc_felt(sig) for sig in declare_content["signature"]], nonce=rpc_felt(declare_content["nonce"]), contract_class=contract_class, @@ -570,7 +572,6 @@ def test_add_declare_transaction_v2(): contract_class, _, compiled_class_hash = load_cairo1_contract() max_fee = int(4e16) - version = 2 nonce = get_nonce(PREDEPLOYED_ACCOUNT_ADDRESS) tx_hash = calculate_declare_transaction_hash( @@ -579,7 +580,7 @@ def test_add_declare_transaction_v2(): chain_id=StarknetChainId.TESTNET.value, sender_address=int(PREDEPLOYED_ACCOUNT_ADDRESS, 16), max_fee=max_fee, - version=version, + version=SUPPORTED_RPC_DECLARE_TX_VERSION, nonce=nonce, ) @@ -590,7 +591,7 @@ def test_add_declare_transaction_v2(): sender_address=PREDEPLOYED_ACCOUNT_ADDRESS, compiled_class_hash=rpc_felt(compiled_class_hash), type="DECLARE", - version=rpc_felt(version), + version=rpc_felt(SUPPORTED_RPC_DECLARE_TX_VERSION), nonce=rpc_felt(nonce), max_fee=rpc_felt(max_fee), signature=list(map(rpc_felt, signature)), @@ -635,7 +636,7 @@ def _add_declare_transaction(): declare_transaction = RpcBroadcastedDeclareTxnV1( type="DECLARE", max_fee=rpc_felt(max_fee), - version=hex(SUPPORTED_RPC_TX_VERSION), + version=hex(DEPRECATED_RPC_DECLARE_TX_VERSION), signature=[rpc_felt(sig) for sig in signature], nonce=rpc_felt(nonce), contract_class=_rpc_contract_class, diff --git a/test/shared.py b/test/shared.py index 073041fee..bc1df89ab 100644 --- a/test/shared.py +++ b/test/shared.py @@ -54,6 +54,9 @@ SUPPORTED_TX_VERSION = 1 SUPPORTED_RPC_TX_VERSION = 1 +SUPPORTED_RPC_DECLARE_TX_VERSION = 2 +DEPRECATED_RPC_DECLARE_TX_VERSION = 1 + PREDEPLOY_ACCOUNT_CLI_ARGS = ("--seed", "42", "--accounts", "1") PREDEPLOYED_ACCOUNT_ADDRESS = ( "0x347be35996a21f6bf0623e75dbce52baba918ad5ae8d83b6f416045ab22961a"