@@ -620,9 +620,8 @@ def test_returns_data_from_specified_block(w3, math_contract):
620620
621621
622622message_regex = (
623- r"\nCould not identify the intended function with name `.*`, "
624- r"positional argument\(s\) of type `.*` and "
625- r"keyword argument\(s\) of type `.*`."
623+ r"\nCould not identify the intended function with name `.*`, positional arguments "
624+ r"with type\(s\) `.*` and keyword arguments with type\(s\) `.*`."
626625 r"\nFound .* function\(s\) with the name `.*`: .*"
627626)
628627diagnosis_arg_regex = (
@@ -672,6 +671,52 @@ def test_function_multiple_error_diagnoses(w3, arg1, arg2, diagnosis):
672671 Contract .functions .a (arg1 ).call ()
673672
674673
674+ @pytest .mark .parametrize (
675+ "address" , (
676+ "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" , # checksummed
677+ b'\xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee ' , # noqa: E501
678+ )
679+ )
680+ def test_function_wrong_args_for_tuple_collapses_args_in_message (
681+ address , tuple_contract ,
682+ ):
683+ with pytest .raises (ValidationError ) as e :
684+ tuple_contract .functions .method (
685+ (1 , [2 , 3 ], [(4 , [True , [False ]], [address ])])
686+ ).call ()
687+
688+ # assert the user arguments are formatted as expected:
689+ # (int,(int,int),((int,(bool,(bool)),(address))))
690+ e .match ("\\ (int,\\ (int,int\\ ),\\ (\\ (int,\\ (bool,\\ (bool\\ )\\ ),\\ (address\\ )\\ )\\ )\\ )" ) # noqa: E501
691+
692+ # assert the found method signature is formatted as expected:
693+ # ['method((uint256,uint256[],(int256,bool[2],address[])[]))']
694+ e .match ("\\ ['method\\ (\\ (uint256,uint256\\ [\\ ],\\ (int256,bool\\ [2\\ ],address\\ [\\ ]\\ )\\ [\\ ]\\ )\\ )'\\ ]" ) # noqa: E501
695+
696+
697+ @pytest .mark .parametrize (
698+ "address" , (
699+ "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" , # checksummed
700+ b'\xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee \xee ' , # noqa: E501
701+ )
702+ )
703+ def test_function_wrong_args_for_tuple_collapses_kwargs_in_message (
704+ address , tuple_contract
705+ ):
706+ with pytest .raises (ValidationError ) as e :
707+ tuple_contract .functions .method (
708+ a = (1 , [2 , 3 ], [(4 , [True , [False ]], [address ])]) # noqa: E501
709+ ).call ()
710+
711+ # assert the user keyword arguments are formatted as expected:
712+ # {'a': '(int,(int,int),((int,(bool,(bool)),(address))))'}
713+ e .match ("{'a': '\\ (int,\\ (int,int\\ ),\\ (\\ (int,\\ (bool,\\ (bool\\ )\\ ),\\ (address\\ )\\ )\\ )\\ )'}" ) # noqa: E501
714+
715+ # assert the found method signature is formatted as expected:
716+ # ['method((uint256,uint256[],(int256,bool[2],address[])[]))']
717+ e .match ("\\ ['method\\ (\\ (uint256,uint256\\ [\\ ],\\ (int256,bool\\ [2\\ ],address\\ [\\ ]\\ )\\ [\\ ]\\ )\\ )'\\ ]" ) # noqa: E501
718+
719+
675720def test_function_no_abi (w3 ):
676721 contract = w3 .eth .contract ()
677722 with pytest .raises (NoABIFound ):
0 commit comments