code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def test_merge_configs(): """ The test covers most cases in `merge_config()`. See comment below explaining `expected`. """ global_config = { "ethereum": { "mainnet": {"default_provider": "node"}, "local": {"default_provider": "test", "required_confirmations": 5}, ...
The test covers most cases in `merge_config()`. See comment below explaining `expected`.
test_merge_configs
python
ApeWorX/ape
tests/functional/test_config.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_config.py
Apache-2.0
def test_contracts_folder_invalid(project): """ Show that we can still attempt to use `.get_config()` when config is invalid. """ with pytest.raises(ConfigError): with project.temp_config(**{"contracts_folder": {}}): _ = project.contracts_folder # Ensure config is fine _after_ s...
Show that we can still attempt to use `.get_config()` when config is invalid.
test_contracts_folder_invalid
python
ApeWorX/ape
tests/functional/test_config.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_config.py
Apache-2.0
def test_get_config_hyphen_in_plugin_name(config): """ Tests against a bug noticed with ape-polygon-zkevm installed on Ape 0.8.0 release where the config no longer worked. """ class CustomConfig(PluginConfig): x: int = 123 mock_cfg_with_hyphens = CustomConfig original_method = conf...
Tests against a bug noticed with ape-polygon-zkevm installed on Ape 0.8.0 release where the config no longer worked.
test_get_config_hyphen_in_plugin_name
python
ApeWorX/ape
tests/functional/test_config.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_config.py
Apache-2.0
def test_get_config_unknown_plugin(config): """ Simulating reading plugin configs w/o those plugins installed. """ actual = config.get_config("thisshouldnotbeinstalled") assert isinstance(actual, PluginConfig)
Simulating reading plugin configs w/o those plugins installed.
test_get_config_unknown_plugin
python
ApeWorX/ape
tests/functional/test_config.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_config.py
Apache-2.0
def test_project_level_settings(project): """ Settings can be configured in an ape-config.yaml file that are not part of any plugin. This test ensures that works. """ # NOTE: Using strings for the values to show simple validation occurs. with project.temp_config(my_string="my_string", my_int...
Settings can be configured in an ape-config.yaml file that are not part of any plugin. This test ensures that works.
test_project_level_settings
python
ApeWorX/ape
tests/functional/test_config.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_config.py
Apache-2.0
def test_console_extras_uses_ape_namespace(mocker, mock_console): """ Test that if console is given extras, those are included in the console but not as args to the extras files, as those files expect items from the default ape namespace. """ namespace_patch = mocker.patch("ape_console._cli._cre...
Test that if console is given extras, those are included in the console but not as args to the extras files, as those files expect items from the default ape namespace.
test_console_extras_uses_ape_namespace
python
ApeWorX/ape
tests/functional/test_console.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_console.py
Apache-2.0
def test_custom_exception_handler_handles_non_ape_project(mocker): """ If the user has assigned the variable ``project`` to something else in their active ``ape console`` session, the exception handler **SHOULD NOT** attempt to use its ``.path``. """ session = mocker.MagicMock() session.user...
If the user has assigned the variable ``project`` to something else in their active ``ape console`` session, the exception handler **SHOULD NOT** attempt to use its ``.path``.
test_custom_exception_handler_handles_non_ape_project
python
ApeWorX/ape
tests/functional/test_console.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_console.py
Apache-2.0
def test_Contract_from_json_str_retrieval_check_fails(mocker, chain, vyper_contract_instance): """ Tests a bug when providing an abi= but fetch-attempt raises that we don't raise since the abi was already given. """ # Make `.get()` fail. orig = chain.contracts.get mock_get = mocker.MagicMock...
Tests a bug when providing an abi= but fetch-attempt raises that we don't raise since the abi was already given.
test_Contract_from_json_str_retrieval_check_fails
python
ApeWorX/ape
tests/functional/test_contract.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract.py
Apache-2.0
def test_Contract_from_file(contract_instance): """ need feedback about the json file specifications """ PROJECT_PATH = Path(__file__).parent CONTRACTS_FOLDER = PROJECT_PATH / "data" / "contracts" / "ethereum" / "abi" json_abi_file = f"{CONTRACTS_FOLDER}/contract_abi.json" address = contrac...
need feedback about the json file specifications
test_Contract_from_file
python
ApeWorX/ape
tests/functional/test_contract.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract.py
Apache-2.0
def test_cache_non_checksum_address(chain, vyper_contract_instance): """ When caching a non-checksum address, it should use its checksum form automatically. """ if vyper_contract_instance.address in chain.contracts: del chain.contracts[vyper_contract_instance.address] lowered_address = ...
When caching a non-checksum address, it should use its checksum form automatically.
test_cache_non_checksum_address
python
ApeWorX/ape
tests/functional/test_contracts_cache.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contracts_cache.py
Apache-2.0
def test_get_proxy_implementation_missing(chain, owner, vyper_contract_container): """ Proxy is cached but implementation is missing. """ placeholder = vyper_contract_container.deploy(1001, sender=owner) assert chain.contracts[placeholder.address] # This must be cached! proxy_container = _make...
Proxy is cached but implementation is missing.
test_get_proxy_implementation_missing
python
ApeWorX/ape
tests/functional/test_contracts_cache.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contracts_cache.py
Apache-2.0
def test_get_proxy_pass_proxy_info_and_no_explorer( chain, owner, proxy_contract_container, ethereum, dummy_live_network_with_explorer ): """ Tests the condition of both passing `proxy_info=` and setting `use_explorer=False` when getting the ContractType of a proxy. """ explorer = dummy_live_net...
Tests the condition of both passing `proxy_info=` and setting `use_explorer=False` when getting the ContractType of a proxy.
test_get_proxy_pass_proxy_info_and_no_explorer
python
ApeWorX/ape
tests/functional/test_contracts_cache.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contracts_cache.py
Apache-2.0
def test_deploy_no_deployment_bytecode(owner, bytecode): """ https://github.com/ApeWorX/ape/issues/1904 """ expected = ( r"Cannot deploy: contract 'Apes' has no deployment-bytecode\. " r"Are you attempting to deploy an interface\?" ) contract_type = ContractType.model_validate( ...
ERROR: type should be string, got "\n https://github.com/ApeWorX/ape/issues/1904\n "
test_deploy_no_deployment_bytecode
python
ApeWorX/ape
tests/functional/test_contract_container.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_container.py
Apache-2.0
def test_contract_decode_logs_falsy_check(owner, vyper_contract_instance): """ Verifies a bug fix where false-y values differing were ignored. """ tx = vyper_contract_instance.setNumber(1, sender=owner) with pytest.raises(AssertionError): assert tx.events == [vyper_contract_instance.NumberC...
Verifies a bug fix where false-y values differing were ignored.
test_contract_decode_logs_falsy_check
python
ApeWorX/ape
tests/functional/test_contract_event.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_event.py
Apache-2.0
def test_contract_call(vyper_contract_instance): """ By default, calls returndata gets decoded into Python types. """ result = vyper_contract_instance.myNumber() assert isinstance(result, int)
By default, calls returndata gets decoded into Python types.
test_contract_call
python
ApeWorX/ape
tests/functional/test_contract_instance.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_instance.py
Apache-2.0
def test_contract_call_decode_false(vyper_contract_instance): """ Use decode=False to get the raw bytes returndata of a function call. """ result = vyper_contract_instance.myNumber(decode=False) assert not isinstance(result, int) assert isinstance(result, bytes)
Use decode=False to get the raw bytes returndata of a function call.
test_contract_call_decode_false
python
ApeWorX/ape
tests/functional/test_contract_instance.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_instance.py
Apache-2.0
def test_transact_specify_auto_gas(vyper_contract_instance, owner): """ Tests that we can specify "auto" gas even though "max" is the default for local networks. """ receipt = vyper_contract_instance.setNumber(111, sender=owner, gas="auto") assert not receipt.failed
Tests that we can specify "auto" gas even though "max" is the default for local networks.
test_transact_specify_auto_gas
python
ApeWorX/ape
tests/functional/test_contract_instance.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_instance.py
Apache-2.0
def test_decode_call_input_no_method_id(contract_instance, calldata): """ Ensure Ape can figure out the method if the ID is missing. """ anonymous_calldata = calldata[4:] method = contract_instance.setNumber.call actual = method.decode_input(anonymous_calldata) expected = "setNumber(uint256)...
Ensure Ape can figure out the method if the ID is missing.
test_decode_call_input_no_method_id
python
ApeWorX/ape
tests/functional/test_contract_instance.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_instance.py
Apache-2.0
def test_decode_transaction_input_no_method_id(contract_instance, calldata): """ Ensure Ape can figure out the method if the ID is missing. """ anonymous_calldata = calldata[4:] method = contract_instance.setNumber actual = method.decode_input(anonymous_calldata) expected = "setNumber(uint25...
Ensure Ape can figure out the method if the ID is missing.
test_decode_transaction_input_no_method_id
python
ApeWorX/ape
tests/functional/test_contract_instance.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_instance.py
Apache-2.0
def test_is_contract_when_code_is_str(mock_provider, owner): """ Tests the cases when an ecosystem uses str for ContractCode. """ # Set up the provider to return str instead of HexBytes for code. mock_provider._web3.eth.get_code.return_value = "0x1234" assert owner.is_contract # When the re...
Tests the cases when an ecosystem uses str for ContractCode.
test_is_contract_when_code_is_str
python
ApeWorX/ape
tests/functional/test_contract_instance.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_instance.py
Apache-2.0
def test_struct_input_web3_named_tuple(solidity_contract_instance, owner): """ Show we integrate nicely with web3 contracts notion of namedtuples. """ data = {"a": solidity_contract_instance.address, "b": HexBytes(123), "c": 321} w3_named_tuple = recursive_dict_to_namedtuple(data) assert not sol...
Show we integrate nicely with web3 contracts notion of namedtuples.
test_struct_input_web3_named_tuple
python
ApeWorX/ape
tests/functional/test_contract_instance.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_instance.py
Apache-2.0
def test_get_error_by_signature(error_contract): """ Helps in cases where multiple errors have same name. Only happens when importing or using types from interfaces. """ signature = error_contract.Unauthorized.abi.signature actual = error_contract.get_error_by_signature(signature) expected =...
Helps in cases where multiple errors have same name. Only happens when importing or using types from interfaces.
test_get_error_by_signature
python
ApeWorX/ape
tests/functional/test_contract_instance.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_instance.py
Apache-2.0
def test_fallback(fallback_contract, owner): """ Test that shows __call__ uses the contract's defined fallback method. We know this is a successful test because otherwise you would get a ContractLogicError. """ receipt = fallback_contract(sender=owner, gas=40000, data="0x123") assert not rec...
Test that shows __call__ uses the contract's defined fallback method. We know this is a successful test because otherwise you would get a ContractLogicError.
test_fallback
python
ApeWorX/ape
tests/functional/test_contract_instance.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_instance.py
Apache-2.0
def test_value_to_non_payable_fallback_and_no_receive( vyper_fallback_contract, owner, vyper_fallback_contract_type ): """ Test that shows when fallback is non-payable and there is no receive, and you try to send a value, it fails. """ # Hack to set fallback as non-payable. contract_type_dat...
Test that shows when fallback is non-payable and there is no receive, and you try to send a value, it fails.
test_value_to_non_payable_fallback_and_no_receive
python
ApeWorX/ape
tests/functional/test_contract_instance.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_instance.py
Apache-2.0
def test_fallback_with_data_and_value_and_receive(solidity_fallback_contract, owner): """ In the case when there is a fallback method and a receive method, if the user sends data, it will hit the fallback method. But if they also send a value, it would fail if the fallback is non-payable. """ ex...
In the case when there is a fallback method and a receive method, if the user sends data, it will hit the fallback method. But if they also send a value, it would fail if the fallback is non-payable.
test_fallback_with_data_and_value_and_receive
python
ApeWorX/ape
tests/functional/test_contract_instance.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_instance.py
Apache-2.0
def test_fallback_not_defined(contract_instance, owner): """ Test that shows __call__ attempts to use the Fallback method, which is not defined and results in a ContractLogicError. """ with pytest.raises(ContractLogicError): # Fails because no fallback is defined in these contracts. ...
Test that shows __call__ attempts to use the Fallback method, which is not defined and results in a ContractLogicError.
test_fallback_not_defined
python
ApeWorX/ape
tests/functional/test_contract_instance.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_contract_instance.py
Apache-2.0
def test_line_rate_when_no_statements(self): """ An edge case: when a function has no statements, its line rate it either 0% if it was not called or 100% if it called. """ function = FunctionCoverage(name="bar", full_name="bar()") assert function.hit_count == 0 fu...
An edge case: when a function has no statements, its line rate it either 0% if it was not called or 100% if it called.
test_line_rate_when_no_statements
python
ApeWorX/ape
tests/functional/test_coverage.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_coverage.py
Apache-2.0
def test_repr_manifest_project(): """ Tests against assuming the dependency manager is related to a local project (could be from a manifest-project). """ manifest = PackageManifest() project = Project.from_manifest(manifest, config_override={"name": "testname123"}) dm = project.dependencies ...
Tests against assuming the dependency manager is related to a local project (could be from a manifest-project).
test_repr_manifest_project
python
ApeWorX/ape
tests/functional/test_dependencies.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_dependencies.py
Apache-2.0
def test_dependency_with_multiple_versions(project_with_downloaded_dependencies): """ Testing the case where we have OpenZeppelin installed multiple times with different versions. """ name = "openzeppelin" dm = project_with_downloaded_dependencies.dependencies # We can get both projects at ...
Testing the case where we have OpenZeppelin installed multiple times with different versions.
test_dependency_with_multiple_versions
python
ApeWorX/ape
tests/functional/test_dependencies.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_dependencies.py
Apache-2.0
def test_get_dependency_returns_latest_updates(project, project_with_contracts): """ Integration test showing how to utilize the changes to dependencies from the config. """ cfg = [{"name": "dep", "version": "10.1.10", "local": f"{project_with_contracts.path}"}] with project.temp_config(dependencies...
Integration test showing how to utilize the changes to dependencies from the config.
test_get_dependency_returns_latest_updates
python
ApeWorX/ape
tests/functional/test_dependencies.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_dependencies.py
Apache-2.0
def test_install_already_installed(mocker, project, with_dependencies_project_path): """ Some dependencies never produce sources because of default compiler extension behavior (example: a16z_erc4626-tests repo). """ dm = project.dependencies dep = dm.install(local=with_dependencies_project_path,...
Some dependencies never produce sources because of default compiler extension behavior (example: a16z_erc4626-tests repo).
test_install_already_installed
python
ApeWorX/ape
tests/functional/test_dependencies.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_dependencies.py
Apache-2.0
def test_name_from_github(self): """ When not given a name, it is derived from the github suffix. """ dependency = GithubDependency( # type: ignore github="ApeWorX/ApeNotAThing", version="3.0.0" ) assert dependency.name == "apenotathing"
When not given a name, it is derived from the github suffix.
test_name_from_github
python
ApeWorX/ape
tests/functional/test_dependencies.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_dependencies.py
Apache-2.0
def test_fetch_missing_v_prefix(self, mock_client): """ Show if the version expects a v-prefix but you don't provide one that it still works. """ dependency = GithubDependency( github="ApeWorX/ApeNotAThing", version="3.0.0", name="apetestdep" ) depende...
Show if the version expects a v-prefix but you don't provide one that it still works.
test_fetch_missing_v_prefix
python
ApeWorX/ape
tests/functional/test_dependencies.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_dependencies.py
Apache-2.0
def test_fetch_unneeded_v_prefix(self, mock_client): """ Show if the version expects not to have a v-prefix but you provide one that it still works. """ dependency = GithubDependency( github="ApeWorX/ApeNotAThing", version="v3.0.0", name="apetestdep" ) ...
Show if the version expects not to have a v-prefix but you provide one that it still works.
test_fetch_unneeded_v_prefix
python
ApeWorX/ape
tests/functional/test_dependencies.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_dependencies.py
Apache-2.0
def test_fetch_given_version_when_expects_reference(self, mock_client): """ Show that if a user configures `version:`, but version fails, it tries `ref:` instead as a backup. """ dependency = GithubDependency( github="ApeWorX/ApeNotAThing", version="v3.0.0", name="ape...
Show that if a user configures `version:`, but version fails, it tries `ref:` instead as a backup.
test_fetch_given_version_when_expects_reference
python
ApeWorX/ape
tests/functional/test_dependencies.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_dependencies.py
Apache-2.0
def test_fetch_ref(self, mock_client): """ When specifying ref, it does not try version API at all. """ dependency = GithubDependency(github="ApeWorX/ApeNotAThing", ref="3.0.0", name="apetestdep") dependency._github_client = mock_client with create_tempdir() as path: ...
When specifying ref, it does not try version API at all.
test_fetch_ref
python
ApeWorX/ape
tests/functional/test_dependencies.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_dependencies.py
Apache-2.0
def test_fetch_existing_destination_with_read_only_files(self, mock_client): """ Show it handles when the destination contains read-only files already """ dependency = GithubDependency(github="ApeWorX/ApeNotAThing", ref="3.0.0", name="apetestdep") dependency._github_client = mock...
Show it handles when the destination contains read-only files already
test_fetch_existing_destination_with_read_only_files
python
ApeWorX/ape
tests/functional/test_dependencies.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_dependencies.py
Apache-2.0
def test_contracts_folder(self, project_from_dependency): """ The local dependency fixture uses a longer contracts folder path. This test ensures that the contracts folder field is honored, specifically In the case when it contains sub-paths. """ actual = project_from_dep...
The local dependency fixture uses a longer contracts folder path. This test ensures that the contracts folder field is honored, specifically In the case when it contains sub-paths.
test_contracts_folder
python
ApeWorX/ape
tests/functional/test_dependencies.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_dependencies.py
Apache-2.0
def test_getattr(self, project_with_downloaded_dependencies): """ Access contracts using __getattr__ from the dependency's project. """ name = "openzeppelin" oz_442 = project_with_downloaded_dependencies.dependencies.get_dependency(name, "4.4.2") contract = oz_442.project...
Access contracts using __getattr__ from the dependency's project.
test_getattr
python
ApeWorX/ape
tests/functional/test_dependencies.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_dependencies.py
Apache-2.0
def test_cache_deployment_live_network_new_ecosystem( self, zero_address, cache, contract_name, mock_sepolia, eth_tester_provider ): """ Tests the case when caching a deployment in a new ecosystem. """ ecosystem_name = mock_sepolia.ecosystem.name local = eth_tester_pr...
Tests the case when caching a deployment in a new ecosystem.
test_cache_deployment_live_network_new_ecosystem
python
ApeWorX/ape
tests/functional/test_deploymentscache.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_deploymentscache.py
Apache-2.0
def test_encode_calldata_byte_array(ethereum, sequence_type, item_type): """ Tests against a bug where we could not pass a tuple of HexStr for a byte-array. """ abi = make_method_abi( "mint", inputs=[{"name": "leaf", "type": "bytes32"}, {"name": "proof", "type": "bytes32[]"}] ) hexst...
Tests against a bug where we could not pass a tuple of HexStr for a byte-array.
test_encode_calldata_byte_array
python
ApeWorX/ape
tests/functional/test_ecosystem.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_ecosystem.py
Apache-2.0
def test_decode_block_with_hex_values(ethereum): """ When using WS providers directly, the values are all hex strings (more raw). This test ensures we can still decode blocks that are in this form. """ raw_block = { "baseFeePerGas": "0x62d76fae2", "difficulty": "0x0", "extraD...
When using WS providers directly, the values are all hex strings (more raw). This test ensures we can still decode blocks that are in this form.
test_decode_block_with_hex_values
python
ApeWorX/ape
tests/functional/test_ecosystem.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_ecosystem.py
Apache-2.0
def test_decode_logs_topics_not_first(ethereum): """ Tests against a condition where we could not decode logs if the topics were not defined first. """ abi_dict = { "anonymous": False, "inputs": [ {"indexed": False, "internalType": "address", "name": "sender", "type": "ad...
Tests against a condition where we could not decode logs if the topics were not defined first.
test_decode_logs_topics_not_first
python
ApeWorX/ape
tests/functional/test_ecosystem.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_ecosystem.py
Apache-2.0
def test_decode_receipt_misleading_blob_receipt(ethereum): """ Tests a strange situation (noticed on Tenderly nodes) where _some_ of the keys indicate blob-related fields, set to ``0``, and others are missing, because it's not actually a blob receipt. In this case, don't use the blob-receipt class. ...
Tests a strange situation (noticed on Tenderly nodes) where _some_ of the keys indicate blob-related fields, set to ``0``, and others are missing, because it's not actually a blob receipt. In this case, don't use the blob-receipt class.
test_decode_receipt_misleading_blob_receipt
python
ApeWorX/ape
tests/functional/test_ecosystem.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_ecosystem.py
Apache-2.0
def test_default_transaction_type_changed_at_class_level(ethereum): """ Simulates an L2 plugin changing the default at the definition-level. """ class L2NetworkConfig(BaseEthereumConfig): DEFAULT_TRANSACTION_TYPE: ClassVar[int] = TransactionType.STATIC.value config = L2NetworkConfig() ...
Simulates an L2 plugin changing the default at the definition-level.
test_default_transaction_type_changed_at_class_level
python
ApeWorX/ape
tests/functional/test_ecosystem.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_ecosystem.py
Apache-2.0
def test_decode_returndata_list_with_1_struct(ethereum): """ Tests a condition where an array of a list with 1 struct would be turned into a raw tuple instead of the Struct class. """ abi = make_method_abi( "getArrayOfStructs", outputs=[ ABIType( name="", ...
Tests a condition where an array of a list with 1 struct would be turned into a raw tuple instead of the Struct class.
test_decode_returndata_list_with_1_struct
python
ApeWorX/ape
tests/functional/test_ecosystem.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_ecosystem.py
Apache-2.0
def test_create_transaction_with_none_values(ethereum, eth_tester_provider): """ Tests against None being in place of values in kwargs, causing their actual defaults not to get used and ValidationErrors to occur. """ static = ethereum.create_transaction( value=None, data=None, chain_id=N...
Tests against None being in place of values in kwargs, causing their actual defaults not to get used and ValidationErrors to occur.
test_create_transaction_with_none_values
python
ApeWorX/ape
tests/functional/test_ecosystem.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_ecosystem.py
Apache-2.0
def test_default_network_name_when_not_set_and_no_local_uses_only( project, custom_networks_config_dict ): """ Tests a condition that is rare but when a default network is not set but there is a single network. In this case, it should use the single network by default. """ net = copy.deepcop...
Tests a condition that is rare but when a default network is not set but there is a single network. In this case, it should use the single network by default.
test_default_network_name_when_not_set_and_no_local_uses_only
python
ApeWorX/ape
tests/functional/test_ecosystem.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_ecosystem.py
Apache-2.0
def test_enrich_trace_handles_call_type_enum(ethereum, vyper_contract_instance, owner): """ Testing a custom trace whose call tree uses an Enum type instead of a str. """ class PluginTxTrace(TransactionTrace): def get_calltree(self) -> CallTreeNode: call = super().get_calltree() ...
Testing a custom trace whose call tree uses an Enum type instead of a str.
test_enrich_trace_handles_call_type_enum
python
ApeWorX/ape
tests/functional/test_ecosystem.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_ecosystem.py
Apache-2.0
def test_receipt_is_subclass(self, vyper_contract_instance, owner): """ Ensure TransactionError knows subclass Receipts are still receipts. (There was a bug once when it didn't, and that caused internal AttributeErrors). """ class SubclassReceipt(Receipt): pass ...
Ensure TransactionError knows subclass Receipts are still receipts. (There was a bug once when it didn't, and that caused internal AttributeErrors).
test_receipt_is_subclass
python
ApeWorX/ape
tests/functional/test_exceptions.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_exceptions.py
Apache-2.0
def test_call_with_txn_and_not_source_tb(self, failing_call): """ Simulating a failing-call, making sure it doesn't blow up if it doesn't get a source-tb. """ err = TransactionError(txn=failing_call) assert err.source_traceback is None
Simulating a failing-call, making sure it doesn't blow up if it doesn't get a source-tb.
test_call_with_txn_and_not_source_tb
python
ApeWorX/ape
tests/functional/test_exceptions.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_exceptions.py
Apache-2.0
def test_call_with_source_tb_and_not_txn(self, mocker, project_with_contract): """ Simulating a failing call, making sure the source-tb lines show up when a txn is NOT given. """ # Using mocks for simplicity. Otherwise have to use a bunch of models from ethpm-types; # mos...
Simulating a failing call, making sure the source-tb lines show up when a txn is NOT given.
test_call_with_source_tb_and_not_txn
python
ApeWorX/ape
tests/functional/test_exceptions.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_exceptions.py
Apache-2.0
def test_source_traceback_from_txn(self, owner): """ Was not given a source-traceback but showing we can deduce one from the given transaction. """ tx = owner.transfer(owner, 0) err = TransactionError(txn=tx) _ = err.source_traceback assert err._attempted_...
Was not given a source-traceback but showing we can deduce one from the given transaction.
test_source_traceback_from_txn
python
ApeWorX/ape
tests/functional/test_exceptions.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_exceptions.py
Apache-2.0
def test_local_network(self): """ Testing we are NOT mentioning explorer plugins for the local-network, as 99.9% of the time it is confusing. """ err = ContractNotFoundError(ZERO_ADDRESS, False, f"ethereum:{LOCAL_NETWORK_NAME}:test") assert str(err) == f"Failed to...
Testing we are NOT mentioning explorer plugins for the local-network, as 99.9% of the time it is confusing.
test_local_network
python
ApeWorX/ape
tests/functional/test_exceptions.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_exceptions.py
Apache-2.0
def test_isolation_supported_flag_set_after_successful_snapshot(fixtures): """ Testing the unusual case where `.supported` was changed manually after a successful snapshot and before the restore attempt. """ class CustomIsolationManager(IsolationManager): take_called = False restore...
Testing the unusual case where `.supported` was changed manually after a successful snapshot and before the restore attempt.
test_isolation_supported_flag_set_after_successful_snapshot
python
ApeWorX/ape
tests/functional/test_fixtures.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_fixtures.py
Apache-2.0
def test_config_custom_networks_default(ethereum, project, custom_networks_config_dict): """ Shows you don't get AttributeError when custom network config is not present. """ with project.temp_config(**custom_networks_config_dict): network = ethereum.apenet cfg = network.config ...
Shows you don't get AttributeError when custom network config is not present.
test_config_custom_networks_default
python
ApeWorX/ape
tests/functional/test_network_api.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_api.py
Apache-2.0
def test_providers_NAME_defined(mocker): """ Show that when a provider plugin used the NAME ClassVar, the provider's name is that instead of the plugin's name. """ ecosystem_name = "my-ecosystem" network_name = "my-network" provider_name = "my-provider" class MyProvider(ProviderAPI): ...
Show that when a provider plugin used the NAME ClassVar, the provider's name is that instead of the plugin's name.
test_providers_NAME_defined
python
ApeWorX/ape
tests/functional/test_network_api.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_api.py
Apache-2.0
def test_is_mainnet_from_config(project): """ Simulate an EVM plugin with a weird named mainnet that properly configured it. """ chain_id = 9191919191919919121177171 ecosystem_name = "ismainnettest" network_name = "primarynetwork" network_type = create_network_type(chain_id, chain_id) ...
Simulate an EVM plugin with a weird named mainnet that properly configured it.
test_is_mainnet_from_config
python
ApeWorX/ape
tests/functional/test_network_api.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_api.py
Apache-2.0
def test_explorer(networks): """ Local network does not have an explorer, by default. """ network = networks.ethereum.local network.__dict__.pop("explorer", None) # Ensure not cached yet. assert network.explorer is None
Local network does not have an explorer, by default.
test_explorer
python
ApeWorX/ape
tests/functional/test_network_api.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_api.py
Apache-2.0
def test_explorer_when_network_registered(networks, mocker): """ Tests the simple flow of having the Explorer plugin register the networks it supports. """ network = networks.ethereum.local network.__dict__.pop("explorer", None) # Ensure not cached yet. name = "my-explorer" def explore...
Tests the simple flow of having the Explorer plugin register the networks it supports.
test_explorer_when_network_registered
python
ApeWorX/ape
tests/functional/test_network_api.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_api.py
Apache-2.0
def test_explorer_when_adhoc_network_supported(networks, mocker): """ Tests the flow of when a chain is supported by an explorer but not registered in the plugin (API-flow). """ network = networks.ethereum.local network.__dict__.pop("explorer", None) # Ensure not cached yet. NAME = "my-expl...
Tests the flow of when a chain is supported by an explorer but not registered in the plugin (API-flow).
test_explorer_when_adhoc_network_supported
python
ApeWorX/ape
tests/functional/test_network_api.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_api.py
Apache-2.0
def test_getattr_evm_chains_ecosystem(networks): """ Show we can getattr evm-chains only ecosystems. """ actual = networks.moonbeam assert actual.name == "moonbeam"
Show we can getattr evm-chains only ecosystems.
test_getattr_evm_chains_ecosystem
python
ApeWorX/ape
tests/functional/test_network_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_manager.py
Apache-2.0
def test_getattr_plugin_ecosystem_same_name_as_evm_chains(mocker, networks): """ Show when an ecosystem is both in evm-chains and an installed plugin that Ape prefers the installed plugin. """ moonbeam_plugin = mocker.MagicMock() networks._plugin_ecosystems["moonbeam"] = moonbeam_plugin actu...
Show when an ecosystem is both in evm-chains and an installed plugin that Ape prefers the installed plugin.
test_getattr_plugin_ecosystem_same_name_as_evm_chains
python
ApeWorX/ape
tests/functional/test_network_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_manager.py
Apache-2.0
def test_fork_network_not_forkable(networks, eth_tester_provider): """ Show correct failure when trying to fork the local network. """ expected = "Unable to fork network 'local'." with pytest.raises(NetworkError, match=expected): with networks.fork(): pass
Show correct failure when trying to fork the local network.
test_fork_network_not_forkable
python
ApeWorX/ape
tests/functional/test_network_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_manager.py
Apache-2.0
def test_fork_no_providers(networks, mock_sepolia, disable_fork_providers): """ Show correct failure when trying to fork without ape-hardhat or ape-foundry installed. """ expected = "No providers for network 'sepolia-fork'." with pytest.raises(NetworkError, match=expected): with networks...
Show correct failure when trying to fork without ape-hardhat or ape-foundry installed.
test_fork_no_providers
python
ApeWorX/ape
tests/functional/test_network_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_manager.py
Apache-2.0
def test_fork_use_non_existing_provider(networks, mock_sepolia): """ Show correct failure when specifying a non-existing provider. """ expected = "No provider named 'NOT_EXISTS' in network 'sepolia-fork' in ecosystem 'ethereum'.*" with pytest.raises(ProviderNotFoundError, match=expected): wi...
Show correct failure when specifying a non-existing provider.
test_fork_use_non_existing_provider
python
ApeWorX/ape
tests/functional/test_network_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_manager.py
Apache-2.0
def test_fork_specify_provider(networks, mock_sepolia, mock_fork_provider): """ Happy-path fork test when specifying the provider. """ ctx = networks.fork(provider_name="mock") assert ctx._disconnect_after is True with ctx as provider: assert provider.name == "mock" assert provid...
Happy-path fork test when specifying the provider.
test_fork_specify_provider
python
ApeWorX/ape
tests/functional/test_network_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_manager.py
Apache-2.0
def test_fork_with_provider_settings(networks, mock_sepolia, mock_fork_provider): """ Show it uses the given provider settings. """ settings = {"fork": {"ethereum": {"sepolia": {"block_number": 123}}}} with networks.fork(provider_settings=settings): actual = mock_fork_provider.partial_call ...
Show it uses the given provider settings.
test_fork_with_provider_settings
python
ApeWorX/ape
tests/functional/test_network_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_manager.py
Apache-2.0
def test_custom_networks_defined_in_non_local_project(custom_networks_config_dict): """ Showing we can read and use custom networks that are not defined in the local project. """ # Ensure we are using a name that is not used anywhere else, for accurte testing. net_name = "customnetdefinedinnonlo...
Showing we can read and use custom networks that are not defined in the local project.
test_custom_networks_defined_in_non_local_project
python
ApeWorX/ape
tests/functional/test_network_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_manager.py
Apache-2.0
def test_get_ecosystem_from_evmchains(networks): """ Show we can call `.get_ecosystem()` for an ecosystem only defined in evmchains. """ moonbeam = networks.get_ecosystem("moonbeam") assert isinstance(moonbeam, EcosystemAPI) assert moonbeam.name == "moonbeam"
Show we can call `.get_ecosystem()` for an ecosystem only defined in evmchains.
test_get_ecosystem_from_evmchains
python
ApeWorX/ape
tests/functional/test_network_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_network_manager.py
Apache-2.0
def mock_python_path(tmp_path): """Create a temporary path to simulate a Python interpreter location.""" python_path = tmp_path / "python" python_path.touch() return f"{python_path}"
Create a temporary path to simulate a Python interpreter location.
mock_python_path
python
ApeWorX/ape
tests/functional/test_plugins.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_plugins.py
Apache-2.0
def test_getattr_empty_contract(tmp_project): """ Tests against a condition where would infinitely compile. """ source_id = tmp_project.Other.contract_type.source_id path = tmp_project.sources.lookup(source_id) path.unlink(missing_ok=True) path.write_text("", encoding="utf8") # Should ha...
Tests against a condition where would infinitely compile.
test_getattr_empty_contract
python
ApeWorX/ape
tests/functional/test_project.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_project.py
Apache-2.0
def test_extract_manifest_when_sources_missing(tmp_project): """ Show that if a source is missing, it is OK. This happens when changing branches after compiling and sources are only present on one of the branches. """ contract = make_contract("notreallyhere") tmp_project.manifest.contract_types ...
Show that if a source is missing, it is OK. This happens when changing branches after compiling and sources are only present on one of the branches.
test_extract_manifest_when_sources_missing
python
ApeWorX/ape
tests/functional/test_project.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_project.py
Apache-2.0
def test_load_contracts_after_deleting_same_named_contract(tmp_project, compilers, mock_compiler): """ Tests against a scenario where you: 1. Add and compile a contract 2. Delete that contract 3. Add a new contract with same name somewhere else Test such that we are able to compile successfull...
Tests against a scenario where you: 1. Add and compile a contract 2. Delete that contract 3. Add a new contract with same name somewhere else Test such that we are able to compile successfully and not get a misleading collision error from deleted files.
test_load_contracts_after_deleting_same_named_contract
python
ApeWorX/ape
tests/functional/test_project.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_project.py
Apache-2.0
def test_project_api_foundry_and_ape_config_found(foundry_toml): """ If a project is both a Foundry project and an Ape project, ensure both configs are honored. """ with create_tempdir() as tmpdir: foundry_cfg_file = tmpdir / "foundry.toml" foundry_cfg_file.write_text(foundry_toml, e...
If a project is both a Foundry project and an Ape project, ensure both configs are honored.
test_project_api_foundry_and_ape_config_found
python
ApeWorX/ape
tests/functional/test_project.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_project.py
Apache-2.0
def test_from_manifest_load_contracts(self, contract_type): """ Show if contract-types are missing but sources set, compiling will add contract-types. """ manifest = make_manifest(contract_type, include_contract_type=False) project = Project.from_manifest(manifest) ...
Show if contract-types are missing but sources set, compiling will add contract-types.
test_from_manifest_load_contracts
python
ApeWorX/ape
tests/functional/test_project.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_project.py
Apache-2.0
def test_hash(self, with_dependencies_project_path, project_from_manifest): """ Show we can use projects in sets. """ project_0 = Project(with_dependencies_project_path) project_1 = Project.from_python_library("web3") project_2 = project_from_manifest # Show we c...
Show we can use projects in sets.
test_hash
python
ApeWorX/ape
tests/functional/test_project.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_project.py
Apache-2.0
def test_lookup_same_source_id_as_local_project(self, project, tmp_project): """ Tests against a bug where if the source ID of the project matched a file in the local project, it would mistakenly return the path to the local file instead of the project's file. """ source_...
Tests against a bug where if the source ID of the project matched a file in the local project, it would mistakenly return the path to the local file instead of the project's file.
test_lookup_same_source_id_as_local_project
python
ApeWorX/ape
tests/functional/test_project.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_project.py
Apache-2.0
def test_lookup_missing_contracts_prefix(self, project_with_source_files_contract): """ Show we can exclude the `contracts/` prefix in a source ID. """ project = project_with_source_files_contract actual_from_str = project.sources.lookup("ContractA.sol") actual_from_path ...
Show we can exclude the `contracts/` prefix in a source ID.
test_lookup_missing_contracts_prefix
python
ApeWorX/ape
tests/functional/test_project.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_project.py
Apache-2.0
def test_chain_id_from_ethereum_base_provider_is_cached(mock_web3, ethereum, eth_tester_provider): """ Simulated chain ID from a plugin (using base-ethereum class) to ensure is also cached. """ def make_request(rpc, arguments): if rpc == "eth_chainId": return {"result": 11155111...
Simulated chain ID from a plugin (using base-ethereum class) to ensure is also cached.
test_chain_id_from_ethereum_base_provider_is_cached
python
ApeWorX/ape
tests/functional/test_provider.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_provider.py
Apache-2.0
def test_get_contract_logs_multiple_accounts_for_address( chain, contract_instance, owner, eth_tester_provider ): """ Tests the condition when you pass in multiple AddressAPI objects during an address-topic search. """ contract_instance.logAddressArray(sender=owner) # Create logs block = ch...
Tests the condition when you pass in multiple AddressAPI objects during an address-topic search.
test_get_contract_logs_multiple_accounts_for_address
python
ApeWorX/ape
tests/functional/test_provider.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_provider.py
Apache-2.0
def test_set_timestamp_to_same_time(eth_tester_provider): """ Eth tester normally fails when setting the timestamp to the same time. However, in Ape, we treat it as a no-op and let it pass. """ expected = eth_tester_provider.get_block("pending").timestamp eth_tester_provider.set_timestamp(expect...
Eth tester normally fails when setting the timestamp to the same time. However, in Ape, we treat it as a no-op and let it pass.
test_set_timestamp_to_same_time
python
ApeWorX/ape
tests/functional/test_provider.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_provider.py
Apache-2.0
def test_set_timestamp_handle_same_time_race_condition(mocker, eth_tester_provider): """ Ensures that when we get an error saying the timestamps are the same, we ignore it and treat it as a noop. This handles the race condition when the block advances after ``set_timestamp`` has been called but before ...
Ensures that when we get an error saying the timestamps are the same, we ignore it and treat it as a noop. This handles the race condition when the block advances after ``set_timestamp`` has been called but before the operation completes.
test_set_timestamp_handle_same_time_race_condition
python
ApeWorX/ape
tests/functional/test_provider.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_provider.py
Apache-2.0
def test_make_request_not_exists_dev_nodes(eth_tester_provider, mock_web3, msg): """ Handle an issue found from Base-sepolia where not-implemented RPCs caused HTTPErrors. """ real_web3 = eth_tester_provider._web3 mock_web3.eth = real_web3.eth def custom_make_request(rpc, params): if...
Handle an issue found from Base-sepolia where not-implemented RPCs caused HTTPErrors.
test_make_request_not_exists_dev_nodes
python
ApeWorX/ape
tests/functional/test_provider.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_provider.py
Apache-2.0
def test_make_request_handles_http_error_method_not_allowed(eth_tester_provider, mock_web3): """ Simulate what *most* of the dev providers do, like hardhat, anvil, and ganache. """ real_web3 = eth_tester_provider._web3 mock_web3.eth = real_web3.eth def custom_make_request(rpc, params): ...
Simulate what *most* of the dev providers do, like hardhat, anvil, and ganache.
test_make_request_handles_http_error_method_not_allowed
python
ApeWorX/ape
tests/functional/test_provider.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_provider.py
Apache-2.0
def test_new_when_web3_provider_uri_set(): """ Tests against a confusing case where having an env var $WEB3_PROVIDER_URI caused web3.py to only ever use that RPC URL regardless of what was said in Ape's --network or config. Now, we raise an error to avoid having users think Ape's network system ...
Tests against a confusing case where having an env var $WEB3_PROVIDER_URI caused web3.py to only ever use that RPC URL regardless of what was said in Ape's --network or config. Now, we raise an error to avoid having users think Ape's network system is broken.
test_new_when_web3_provider_uri_set
python
ApeWorX/ape
tests/functional/test_provider.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_provider.py
Apache-2.0
def test_provider_not_supports_get_storage( get_contract_type, owner, vyper_contract_instance, ethereum, chain, networks ): """ The get storage slot RPC is required to detect this proxy, so it won't work on EthTester provider. However, we can make sure that it doesn't try to call `get_storage()` mor...
The get storage slot RPC is required to detect this proxy, so it won't work on EthTester provider. However, we can make sure that it doesn't try to call `get_storage()` more than once.
test_provider_not_supports_get_storage
python
ApeWorX/ape
tests/functional/test_proxy.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_proxy.py
Apache-2.0
def test_decode_logs_not_checksummed_addresses(owner, contract_instance, assert_log_values): """ If an RPC returns non-checksummed logs with non-checksummed addresses, show we can still decode them. """ start_number = contract_instance.myNumber() tx = contract_instance.setNumber(1, sender=owner)...
If an RPC returns non-checksummed logs with non-checksummed addresses, show we can still decode them.
test_decode_logs_not_checksummed_addresses
python
ApeWorX/ape
tests/functional/test_receipt.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_receipt.py
Apache-2.0
def test_track_coverage(deploy_receipt, mocker): """ Show that deploy receipts are not tracked. """ mock_runner = mocker.MagicMock() mock_tracker = mocker.MagicMock() mock_runner.coverage_tracker = mock_tracker original = ManagerAccessMixin._test_runner ManagerAccessMixin._test_runner = ...
Show that deploy receipts are not tracked.
test_track_coverage
python
ApeWorX/ape
tests/functional/test_receipt.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_receipt.py
Apache-2.0
def test_return_value(owner, vyper_contract_instance): """ ``.return_value`` still works when using EthTester provider! It works by using eth_call to get the result rather than tracing-RPCs. """ vyper_contract_instance.loadArrays(sender=owner) receipt = vyper_contract_instance.getNestedArray...
``.return_value`` still works when using EthTester provider! It works by using eth_call to get the result rather than tracing-RPCs.
test_return_value
python
ApeWorX/ape
tests/functional/test_receipt.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_receipt.py
Apache-2.0
def test_revert_info_context(owner, reverts_contract_instance): """ Shows no two revert info objects are the same instance. """ rev = reverts() with rev as rev0: reverts_contract_instance.revertStrings(0, sender=owner) with rev as rev1: reverts_contract_instance.revertStrings(1,...
Shows no two revert info objects are the same instance.
test_revert_info_context
python
ApeWorX/ape
tests/functional/test_reverts_context_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_reverts_context_manager.py
Apache-2.0
def test_revert_error_from_container_with_expected_values( error_contract_container, error_contract, not_owner ): """ Test matching a revert custom Solidity error using the container instead of an instance, so the specific contract instance is not checked, only the ABI is. This is required for prope...
Test matching a revert custom Solidity error using the container instead of an instance, so the specific contract instance is not checked, only the ABI is. This is required for proper deploy-txn checks.
test_revert_error_from_container_with_expected_values
python
ApeWorX/ape
tests/functional/test_reverts_context_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_reverts_context_manager.py
Apache-2.0
def test_revert_unexpected_error(error_contract, not_owner): """ Test when given a different error type than what was raised. """ expected = "Expected error 'OtherError' but was 'Unauthorized'" with pytest.raises(AssertionError, match=expected): with reverts(error_contract.OtherError): ...
Test when given a different error type than what was raised.
test_revert_unexpected_error
python
ApeWorX/ape
tests/functional/test_reverts_context_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_reverts_context_manager.py
Apache-2.0
def test_revert_error_unexpected_inputs(error_contract, owner, not_owner): """ Test matching a revert custom Solidity error with unexpected inputs. """ expected = ( rf"Expected input 'addr' to be '{owner.address}' but was '{not_owner.address}'\." r"\nExpected input 'counter' to be '321' ...
Test matching a revert custom Solidity error with unexpected inputs.
test_revert_error_unexpected_inputs
python
ApeWorX/ape
tests/functional/test_reverts_context_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_reverts_context_manager.py
Apache-2.0
def test_revert_fails(owner, reverts_contract_instance): """ Test that ``AssertionError`` is raised if the supplied revert reason does not match the actual revert reason. """ with pytest.raises(AssertionError): with reverts("one"): reverts_contract_instance.revertStrings(0, sende...
Test that ``AssertionError`` is raised if the supplied revert reason does not match the actual revert reason.
test_revert_fails
python
ApeWorX/ape
tests/functional/test_reverts_context_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_reverts_context_manager.py
Apache-2.0
def test_revert_pattern_fails(owner, reverts_contract_instance): """ Test that ``AssertionError`` is raised if the actual revert reason does not match the supplied revert pattern. """ with pytest.raises(AssertionError): with reverts(re.compile(r"[^zero]+")): reverts_contract_inst...
Test that ``AssertionError`` is raised if the actual revert reason does not match the supplied revert pattern.
test_revert_pattern_fails
python
ApeWorX/ape
tests/functional/test_reverts_context_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_reverts_context_manager.py
Apache-2.0
def test_revert_partial_fails(owner, reverts_contract_instance): """ Test that ``AssertionError`` is raised if the supplied revert reason does not match the actual revert reason exactly. """ with pytest.raises(AssertionError): with reverts("ze"): reverts_contract_instance.revertS...
Test that ``AssertionError`` is raised if the supplied revert reason does not match the actual revert reason exactly.
test_revert_partial_fails
python
ApeWorX/ape
tests/functional/test_reverts_context_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_reverts_context_manager.py
Apache-2.0
def test_signable_message_module(signable_message): """ At the time of writing this, SignableMessage is a borrowed construct from `eth_account.messages`. We are changing the module manually so we are testing that it shows Ape's now. """ actual = signable_message.__module__ expected = "ape.ty...
At the time of writing this, SignableMessage is a borrowed construct from `eth_account.messages`. We are changing the module manually so we are testing that it shows Ape's now.
test_signable_message_module
python
ApeWorX/ape
tests/functional/test_signatures.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_signatures.py
Apache-2.0
def test_verbosity(self, mocker): """ Show it returns the same as pytest_config's. """ pytest_cfg = mocker.MagicMock() pytest_cfg.option.verbose = False wrapper = ConfigWrapper(pytest_cfg) assert wrapper.verbosity is False
Show it returns the same as pytest_config's.
test_verbosity
python
ApeWorX/ape
tests/functional/test_test.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_test.py
Apache-2.0
def test_verbosity_when_no_capture(self, mocker): """ Shows we enable verbose output when no-capture is set. """ def get_opt(name: str): return "no" if name == "capture" else None pytest_cfg = mocker.MagicMock() pytest_cfg.option.verbose = False # Start off...
Shows we enable verbose output when no-capture is set.
test_verbosity_when_no_capture
python
ApeWorX/ape
tests/functional/test_test.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_test.py
Apache-2.0