@@ -573,9 +573,8 @@ def test_returns_data_from_specified_block(w3, math_contract):
573
573
574
574
575
575
message_regex = (
576
- r"\nCould not identify the intended function with name `.*`, "
577
- r"positional argument\(s\) of type `.*` and "
578
- r"keyword argument\(s\) of type `.*`."
576
+ r"\nCould not identify the intended function with name `.*`, positional arguments "
577
+ r"with type\(s\) `.*` and keyword arguments with type\(s\) `.*`."
579
578
r"\nFound .* function\(s\) with the name `.*`: .*"
580
579
)
581
580
diagnosis_arg_regex = (
@@ -625,6 +624,52 @@ def test_function_multiple_error_diagnoses(w3, arg1, arg2, diagnosis):
625
624
Contract .functions .a (arg1 ).call ()
626
625
627
626
627
+ @pytest .mark .parametrize (
628
+ "address" , (
629
+ "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" , # checksummed
630
+ b'\xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee ' , # noqa: E501
631
+ )
632
+ )
633
+ def test_function_wrong_args_for_tuple_collapses_args_in_message (
634
+ address , tuple_contract ,
635
+ ):
636
+ with pytest .raises (ValidationError ) as e :
637
+ tuple_contract .functions .method (
638
+ (1 , [2 , 3 ], [(4 , [True , [False ]], [address ])])
639
+ ).call ()
640
+
641
+ # assert the user arguments are formatted as expected:
642
+ # (int,(int,int),((int,(bool,(bool)),(address))))
643
+ e .match ("\\ (int,\\ (int,int\\ ),\\ (\\ (int,\\ (bool,\\ (bool\\ )\\ ),\\ (address\\ )\\ )\\ )\\ )" ) # noqa: E501
644
+
645
+ # assert the found method signature is formatted as expected:
646
+ # ['method((uint256,uint256[],(int256,bool[2],address[])[]))']
647
+ e .match ("\\ ['method\\ (\\ (uint256,uint256\\ [\\ ],\\ (int256,bool\\ [2\\ ],address\\ [\\ ]\\ )\\ [\\ ]\\ )\\ )'\\ ]" ) # noqa: E501
648
+
649
+
650
+ @pytest .mark .parametrize (
651
+ "address" , (
652
+ "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" , # checksummed
653
+ b'\xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee ' , # noqa: E501
654
+ )
655
+ )
656
+ def test_function_wrong_args_for_tuple_collapses_kwargs_in_message (
657
+ address , tuple_contract
658
+ ):
659
+ with pytest .raises (ValidationError ) as e :
660
+ tuple_contract .functions .method (
661
+ a = (1 , [2 , 3 ], [(4 , [True , [False ]], [address ])]) # noqa: E501
662
+ ).call ()
663
+
664
+ # assert the user keyword arguments are formatted as expected:
665
+ # {'a': '(int,(int,int),((int,(bool,(bool)),(address))))'}
666
+ e .match ("{'a': '\\ (int,\\ (int,int\\ ),\\ (\\ (int,\\ (bool,\\ (bool\\ )\\ ),\\ (address\\ )\\ )\\ )\\ )'}" ) # noqa: E501
667
+
668
+ # assert the found method signature is formatted as expected:
669
+ # ['method((uint256,uint256[],(int256,bool[2],address[])[]))']
670
+ e .match ("\\ ['method\\ (\\ (uint256,uint256\\ [\\ ],\\ (int256,bool\\ [2\\ ],address\\ [\\ ]\\ )\\ [\\ ]\\ )\\ )'\\ ]" ) # noqa: E501
671
+
672
+
628
673
def test_function_no_abi (w3 ):
629
674
contract = w3 .eth .contract ()
630
675
with pytest .raises (NoABIFound ):
@@ -1291,7 +1336,8 @@ async def test_async_no_functions_match_identifier(async_arrays_contract):
1291
1336
1292
1337
@pytest .mark .asyncio
1293
1338
async def test_async_function_1_match_identifier_wrong_number_of_args (
1294
- async_arrays_contract ):
1339
+ async_arrays_contract
1340
+ ):
1295
1341
regex = message_regex + diagnosis_arg_regex
1296
1342
with pytest .raises (ValidationError , match = regex ):
1297
1343
await async_arrays_contract .functions .setBytes32Value ().call ()
0 commit comments