41
41
MAX_RESOURCE_BOUNDS ,
42
42
MAX_RESOURCE_BOUNDS_L1 ,
43
43
)
44
+ from starknet_py .transaction_errors import (
45
+ TransactionRevertedError ,
46
+ )
44
47
45
48
46
49
@pytest .mark .run_on_devnet
@@ -857,7 +860,7 @@ async def test_account_execute_v3(account, deployed_balance_contract):
857
860
assert initial_balance + 100 == balance_after_increase
858
861
859
862
@pytest .mark .asyncio
860
- async def test_account_outside_execution (
863
+ async def test_account_outside_execution_any_caller (
861
864
client ,
862
865
argent_account_class_hash ,
863
866
deployed_balance_contract ,
@@ -890,7 +893,7 @@ async def test_account_outside_execution(
890
893
calldata = [100 ],
891
894
)
892
895
893
- call = await account .sign_execute_outside_call (
896
+ call = await account .sign_outside_execution_call (
894
897
calls = [
895
898
increase_balance_call ,
896
899
increase_balance_call ,
@@ -905,3 +908,58 @@ async def test_account_outside_execution(
905
908
906
909
tx = await account .execute_v1 (calls = [call ], max_fee = MAX_FEE )
907
910
await account .client .wait_for_tx (tx .transaction_hash )
911
+
912
+
913
+ @pytest .mark .asyncio
914
+ async def test_account_outside_execution_for_invalid_caller (
915
+ client ,
916
+ argent_account_class_hash ,
917
+ deployed_balance_contract ,
918
+ deploy_account_details_factory ,
919
+ ):
920
+ address , key_pair , salt , class_hash = await deploy_account_details_factory .get (
921
+ class_hash = argent_account_class_hash , argent_calldata = True
922
+ )
923
+
924
+ deploy_result = await Account .deploy_account_v1 (
925
+ address = address ,
926
+ class_hash = class_hash ,
927
+ salt = salt ,
928
+ key_pair = key_pair ,
929
+ client = client ,
930
+ constructor_calldata = [key_pair .public_key , 0 ],
931
+ max_fee = MAX_FEE ,
932
+ )
933
+ await deploy_result .wait_for_acceptance ()
934
+ account = deploy_result .account
935
+
936
+ assert any ([
937
+ await account .supports_interface (SNIP9InterfaceVersion .V1 ),
938
+ await account .supports_interface (SNIP9InterfaceVersion .V2 ),
939
+ ])
940
+
941
+ increase_balance_call = Call (
942
+ to_addr = deployed_balance_contract .address ,
943
+ selector = get_selector_from_name ("increase_balance" ),
944
+ calldata = [100 ],
945
+ )
946
+
947
+ call = await account .sign_outside_execution_call (
948
+ calls = [
949
+ increase_balance_call ,
950
+ increase_balance_call ,
951
+ increase_balance_call ,
952
+ ],
953
+ execution_time_bounds = ExecutionTimeBounds (
954
+ execute_after = datetime .datetime .now () - datetime .timedelta (hours = 1 ),
955
+ execute_before = datetime .datetime .now () + datetime .timedelta (hours = 1 ),
956
+ ),
957
+ caller = deployed_balance_contract .address ,
958
+ )
959
+
960
+ tx = await account .execute_v1 (calls = [call ], max_fee = MAX_FEE )
961
+
962
+ with pytest .raises (TransactionRevertedError ) as err :
963
+ await account .client .wait_for_tx (tx .transaction_hash )
964
+
965
+ assert 'argent/invalid-caller' in err .value .message
0 commit comments