|
1 |
| -import datetime |
2 | 1 | import sys
|
3 | 2 | from typing import cast
|
4 | 3 | from unittest.mock import AsyncMock, patch
|
5 | 4 |
|
6 | 5 | import pytest
|
7 | 6 |
|
8 |
| -from starknet_py.constants import ANY_CALLER, SNIP9InterfaceVersion |
9 | 7 | from starknet_py.hash.address import compute_address
|
10 | 8 | from starknet_py.hash.selector import get_selector_from_name
|
11 | 9 | from starknet_py.net.account.account import Account
|
|
17 | 15 | DeployAccountTransactionV1,
|
18 | 16 | DeployAccountTransactionV3,
|
19 | 17 | EstimatedFee,
|
20 |
| - ExecutionTimeBounds, |
21 | 18 | InvokeTransactionV3,
|
22 | 19 | PriceUnit,
|
23 | 20 | ResourceBounds,
|
|
41 | 38 | MAX_RESOURCE_BOUNDS,
|
42 | 39 | MAX_RESOURCE_BOUNDS_L1,
|
43 | 40 | )
|
44 |
| -from starknet_py.transaction_errors import TransactionRevertedError |
45 | 41 |
|
46 | 42 |
|
47 | 43 | @pytest.mark.run_on_devnet
|
@@ -814,16 +810,6 @@ async def test_argent_account_execute(
|
814 | 810 | assert get_balance[0] == value
|
815 | 811 |
|
816 | 812 |
|
817 |
| -@pytest.mark.asyncio |
818 |
| -async def test_argent_account_snip9_compatibility( |
819 |
| - argent_account: BaseAccount, |
820 |
| -): |
821 |
| - result = await argent_account.supports_interface(SNIP9InterfaceVersion.V1) |
822 |
| - assert result is True |
823 |
| - result = await argent_account.supports_interface(SNIP9InterfaceVersion.V2) |
824 |
| - assert result is False |
825 |
| - |
826 |
| - |
827 | 813 | @pytest.mark.asyncio
|
828 | 814 | async def test_account_execute_v3(account, deployed_balance_contract):
|
829 | 815 | get_balance_call = Call(
|
@@ -857,170 +843,3 @@ async def test_account_execute_v3(account, deployed_balance_contract):
|
857 | 843 | call=get_balance_call
|
858 | 844 | )
|
859 | 845 | assert initial_balance + 100 == balance_after_increase
|
860 |
| - |
861 |
| - |
862 |
| -@pytest.mark.asyncio |
863 |
| -async def test_account_outside_execution_any_caller( |
864 |
| - client, |
865 |
| - argent_account_class_hash, |
866 |
| - deployed_balance_contract, |
867 |
| - deploy_account_details_factory, |
868 |
| -): |
869 |
| - address, key_pair, salt, class_hash = await deploy_account_details_factory.get( |
870 |
| - class_hash=argent_account_class_hash, argent_calldata=True |
871 |
| - ) |
872 |
| - |
873 |
| - deploy_result = await Account.deploy_account_v1( |
874 |
| - address=address, |
875 |
| - class_hash=class_hash, |
876 |
| - salt=salt, |
877 |
| - key_pair=key_pair, |
878 |
| - client=client, |
879 |
| - constructor_calldata=[key_pair.public_key, 0], |
880 |
| - max_fee=MAX_FEE, |
881 |
| - ) |
882 |
| - await deploy_result.wait_for_acceptance() |
883 |
| - account = deploy_result.account |
884 |
| - |
885 |
| - assert any( |
886 |
| - [ |
887 |
| - await account.supports_interface(SNIP9InterfaceVersion.V1), |
888 |
| - await account.supports_interface(SNIP9InterfaceVersion.V2), |
889 |
| - ] |
890 |
| - ) |
891 |
| - |
892 |
| - increase_balance_call = Call( |
893 |
| - to_addr=deployed_balance_contract.address, |
894 |
| - selector=get_selector_from_name("increase_balance"), |
895 |
| - calldata=[100], |
896 |
| - ) |
897 |
| - |
898 |
| - call = await account.sign_outside_execution_call( |
899 |
| - calls=[ |
900 |
| - increase_balance_call, |
901 |
| - increase_balance_call, |
902 |
| - increase_balance_call, |
903 |
| - ], |
904 |
| - execution_time_bounds=ExecutionTimeBounds( |
905 |
| - execute_after=datetime.datetime.now() - datetime.timedelta(hours=1), |
906 |
| - execute_before=datetime.datetime.now() + datetime.timedelta(hours=1), |
907 |
| - ), |
908 |
| - caller=ANY_CALLER, |
909 |
| - ) |
910 |
| - |
911 |
| - tx = await account.execute_v1(calls=[call], max_fee=MAX_FEE) |
912 |
| - await account.client.wait_for_tx(tx.transaction_hash) |
913 |
| - |
914 |
| - |
915 |
| -@pytest.mark.asyncio |
916 |
| -async def test_account_outside_execution_for_invalid_caller( |
917 |
| - client, |
918 |
| - argent_account_class_hash, |
919 |
| - deployed_balance_contract, |
920 |
| - deploy_account_details_factory, |
921 |
| -): |
922 |
| - address, key_pair, salt, class_hash = await deploy_account_details_factory.get( |
923 |
| - class_hash=argent_account_class_hash, argent_calldata=True |
924 |
| - ) |
925 |
| - |
926 |
| - deploy_result = await Account.deploy_account_v1( |
927 |
| - address=address, |
928 |
| - class_hash=class_hash, |
929 |
| - salt=salt, |
930 |
| - key_pair=key_pair, |
931 |
| - client=client, |
932 |
| - constructor_calldata=[key_pair.public_key, 0], |
933 |
| - max_fee=MAX_FEE, |
934 |
| - ) |
935 |
| - await deploy_result.wait_for_acceptance() |
936 |
| - account = deploy_result.account |
937 |
| - |
938 |
| - assert any( |
939 |
| - [ |
940 |
| - await account.supports_interface(SNIP9InterfaceVersion.V1), |
941 |
| - await account.supports_interface(SNIP9InterfaceVersion.V2), |
942 |
| - ] |
943 |
| - ) |
944 |
| - |
945 |
| - increase_balance_call = Call( |
946 |
| - to_addr=deployed_balance_contract.address, |
947 |
| - selector=get_selector_from_name("increase_balance"), |
948 |
| - calldata=[100], |
949 |
| - ) |
950 |
| - |
951 |
| - call = await account.sign_outside_execution_call( |
952 |
| - calls=[ |
953 |
| - increase_balance_call, |
954 |
| - increase_balance_call, |
955 |
| - increase_balance_call, |
956 |
| - ], |
957 |
| - execution_time_bounds=ExecutionTimeBounds( |
958 |
| - execute_after=datetime.datetime.now() - datetime.timedelta(hours=1), |
959 |
| - execute_before=datetime.datetime.now() + datetime.timedelta(hours=1), |
960 |
| - ), |
961 |
| - caller=deployed_balance_contract.address, |
962 |
| - ) |
963 |
| - |
964 |
| - tx = await account.execute_v1(calls=[call], max_fee=MAX_FEE) |
965 |
| - |
966 |
| - with pytest.raises(TransactionRevertedError) as err: |
967 |
| - await account.client.wait_for_tx(tx.transaction_hash) |
968 |
| - |
969 |
| - assert "argent/invalid-caller" in err.value.message |
970 |
| - |
971 |
| - |
972 |
| -@pytest.mark.asyncio |
973 |
| -async def test_account_outside_execution_for_impossible_timebounds( |
974 |
| - client, |
975 |
| - argent_account_class_hash, |
976 |
| - deployed_balance_contract, |
977 |
| - deploy_account_details_factory, |
978 |
| -): |
979 |
| - address, key_pair, salt, class_hash = await deploy_account_details_factory.get( |
980 |
| - class_hash=argent_account_class_hash, argent_calldata=True |
981 |
| - ) |
982 |
| - |
983 |
| - deploy_result = await Account.deploy_account_v1( |
984 |
| - address=address, |
985 |
| - class_hash=class_hash, |
986 |
| - salt=salt, |
987 |
| - key_pair=key_pair, |
988 |
| - client=client, |
989 |
| - constructor_calldata=[key_pair.public_key, 0], |
990 |
| - max_fee=MAX_FEE, |
991 |
| - ) |
992 |
| - await deploy_result.wait_for_acceptance() |
993 |
| - account = deploy_result.account |
994 |
| - |
995 |
| - assert any( |
996 |
| - [ |
997 |
| - await account.supports_interface(SNIP9InterfaceVersion.V1), |
998 |
| - await account.supports_interface(SNIP9InterfaceVersion.V2), |
999 |
| - ] |
1000 |
| - ) |
1001 |
| - |
1002 |
| - increase_balance_call = Call( |
1003 |
| - to_addr=deployed_balance_contract.address, |
1004 |
| - selector=get_selector_from_name("increase_balance"), |
1005 |
| - calldata=[100], |
1006 |
| - ) |
1007 |
| - |
1008 |
| - call = await account.sign_outside_execution_call( |
1009 |
| - calls=[ |
1010 |
| - increase_balance_call, |
1011 |
| - increase_balance_call, |
1012 |
| - increase_balance_call, |
1013 |
| - ], |
1014 |
| - execution_time_bounds=ExecutionTimeBounds( |
1015 |
| - execute_after=datetime.datetime.now() - datetime.timedelta(days=10), |
1016 |
| - execute_before=datetime.datetime.now() - datetime.timedelta(days=9), |
1017 |
| - ), |
1018 |
| - caller=ANY_CALLER, |
1019 |
| - ) |
1020 |
| - |
1021 |
| - tx = await account.execute_v1(calls=[call], max_fee=MAX_FEE) |
1022 |
| - |
1023 |
| - with pytest.raises(TransactionRevertedError) as err: |
1024 |
| - await account.client.wait_for_tx(tx.transaction_hash) |
1025 |
| - |
1026 |
| - assert "argent/invalid-timestamp" in err.value.message |
0 commit comments