Skip to content

Commit d94c3aa

Browse files
authored
Run sign_for_fee_estimate tests on devnet (#1286)
1 parent c44e782 commit d94c3aa

File tree

2 files changed

+50
-71
lines changed

2 files changed

+50
-71
lines changed

starknet_py/tests/e2e/account/account_test.py

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
DeployAccountTransactionV3,
1717
EstimatedFee,
1818
InvokeTransactionV3,
19+
PriceUnit,
1920
ResourceBounds,
2021
ResourceBoundsMapping,
2122
SierraContractClass,
@@ -615,10 +616,53 @@ async def test_deploy_account_uses_custom_calldata(
615616
assert tx.constructor_calldata == calldata
616617

617618

618-
# TODO (#1219): investigate why this test fails
619-
@pytest.mark.skip
620619
@pytest.mark.asyncio
621-
async def test_sign_deploy_account_tx_for_fee_estimation(
620+
async def test_sign_invoke_v1_for_fee_estimation(account, map_contract):
621+
call = map_contract.functions["put"].prepare_invoke_v1(key=1, value=2)
622+
transaction = await account.sign_invoke_v1(calls=call, max_fee=MAX_FEE)
623+
624+
estimate_fee_transaction = await account.sign_for_fee_estimate(transaction)
625+
assert estimate_fee_transaction.version == transaction.version + 2**128
626+
627+
estimation = await account.client.estimate_fee(estimate_fee_transaction)
628+
assert isinstance(estimation, EstimatedFee)
629+
assert estimation.unit == PriceUnit.WEI
630+
assert estimation.overall_fee > 0
631+
632+
633+
@pytest.mark.asyncio
634+
async def test_sign_invoke_v3_for_fee_estimation(account, map_contract):
635+
call = map_contract.functions["put"].prepare_invoke_v3(key=1, value=2)
636+
transaction = await account.sign_invoke_v3(
637+
calls=call, l1_resource_bounds=MAX_RESOURCE_BOUNDS_L1
638+
)
639+
640+
estimate_fee_transaction = await account.sign_for_fee_estimate(transaction)
641+
assert estimate_fee_transaction.version == transaction.version + 2**128
642+
643+
estimation = await account.client.estimate_fee(estimate_fee_transaction)
644+
assert isinstance(estimation, EstimatedFee)
645+
assert estimation.unit == PriceUnit.FRI
646+
assert estimation.overall_fee > 0
647+
648+
649+
@pytest.mark.asyncio
650+
async def test_sign_declare_v1_for_fee_estimation(account, map_compiled_contract):
651+
transaction = await account.sign_declare_v1(
652+
compiled_contract=map_compiled_contract, max_fee=MAX_FEE
653+
)
654+
655+
estimate_fee_transaction = await account.sign_for_fee_estimate(transaction)
656+
assert estimate_fee_transaction.version == transaction.version + 2**128
657+
658+
estimation = await account.client.estimate_fee(estimate_fee_transaction)
659+
assert isinstance(estimation, EstimatedFee)
660+
assert estimation.unit == PriceUnit.WEI
661+
assert estimation.overall_fee > 0
662+
663+
664+
@pytest.mark.asyncio
665+
async def test_sign_deploy_account_v1_for_fee_estimation(
622666
client, deploy_account_details_factory
623667
):
624668
address, key_pair, salt, class_hash = await deploy_account_details_factory.get()
@@ -638,19 +682,13 @@ async def test_sign_deploy_account_tx_for_fee_estimation(
638682
)
639683

640684
estimate_fee_transaction = await account.sign_for_fee_estimate(transaction)
685+
assert estimate_fee_transaction.version == transaction.version + 2**128
641686

642-
estimation = await account.client.estimate_fee(transaction)
687+
estimation = await account.client.estimate_fee(estimate_fee_transaction)
643688
assert isinstance(estimation, EstimatedFee)
689+
assert estimation.unit == PriceUnit.WEI
644690
assert estimation.overall_fee > 0
645691

646-
# Verify that the transaction signed for fee estimation cannot be sent
647-
with pytest.raises(ClientError):
648-
await account.client.deploy_account(estimate_fee_transaction)
649-
650-
# Verify that original transaction can be sent
651-
result = await account.client.deploy_account(transaction)
652-
await account.client.wait_for_tx(result.transaction_hash)
653-
654692

655693
@pytest.mark.asyncio
656694
async def test_sign_transaction_custom_nonce(account, cairo1_hello_starknet_class_hash):

starknet_py/tests/e2e/tests_on_networks/account_test.py

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)