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_transfer_mixed_up_sender_and_value(sender, receiver): """ Testing the case where the user mixes up the argument order, it should show a nicer error than it was previously, as this is a common and easy mistake. """ expected = ( r"Cannot use integer-type for the `receiver` " ...
Testing the case where the user mixes up the argument order, it should show a nicer error than it was previously, as this is a common and easy mistake.
test_transfer_mixed_up_sender_and_value
python
ApeWorX/ape
tests/functional/test_accounts.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_accounts.py
Apache-2.0
def test_deploy_instance(owner, vyper_contract_instance): """ Tests against a confusing scenario where you would get a SignatureError when trying to deploy a ContractInstance because Ape would attempt to create a tx by calling the contract's default handler. """ expected = ( r"contract ...
Tests against a confusing scenario where you would get a SignatureError when trying to deploy a ContractInstance because Ape would attempt to create a tx by calling the contract's default handler.
test_deploy_instance
python
ApeWorX/ape
tests/functional/test_accounts.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_accounts.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_accounts.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_accounts.py
Apache-2.0
def test_unlock_and_reload(runner, account_manager, keyfile_account, message): """ Tests against a condition where reloading after unlocking would not honor unlocked state. """ keyfile_account.unlock(passphrase=PASSPHRASE) reloaded_account = account_manager.load(keyfile_account.alias) # y: ...
Tests against a condition where reloading after unlocking would not honor unlocked state.
test_unlock_and_reload
python
ApeWorX/ape
tests/functional/test_accounts.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_accounts.py
Apache-2.0
def test_repr(account_manager): """ NOTE: __repr__ should be simple and fast! Previously, we showed the repr of all the accounts. That was a bad idea, as that can be very unnecessarily slow. Hence, this test exists to ensure care is taken. """ actual = repr(account_manager) assert ...
NOTE: __repr__ should be simple and fast! Previously, we showed the repr of all the accounts. That was a bad idea, as that can be very unnecessarily slow. Hence, this test exists to ensure care is taken.
test_repr
python
ApeWorX/ape
tests/functional/test_accounts.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_accounts.py
Apache-2.0
def test_ipython_integration_defaults(manager, fn_name): """ Test default behavior for IPython integration methods. The base-manager short-circuits to NotImplementedError to avoid dealing with any custom `__getattr__` logic entirely. This prevents side-effects such as unnecessary compiling in the Pr...
Test default behavior for IPython integration methods. The base-manager short-circuits to NotImplementedError to avoid dealing with any custom `__getattr__` logic entirely. This prevents side-effects such as unnecessary compiling in the ProjectManager.
test_ipython_integration_defaults
python
ApeWorX/ape
tests/functional/test_base_manager.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_base_manager.py
Apache-2.0
def test_model_validate_web3_block(): """ Show we have good compatibility with web3.py native types. """ data = BlockData(number=123, timestamp=123, gasLimit=123, gasUsed=100) # type: ignore actual = Block.model_validate(data) assert actual.number == 123
Show we have good compatibility with web3.py native types.
test_model_validate_web3_block
python
ApeWorX/ape
tests/functional/test_block.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_block.py
Apache-2.0
def test_snapshot_and_restore_switched_chains(networks, chain): """ Ensuring things work as expected when we switch chains after snapshotting and before restoring. """ snapshot = chain.snapshot() # Switch chains. with networks.ethereum.local.use_provider( "test", provider_settings={"...
Ensuring things work as expected when we switch chains after snapshotting and before restoring.
test_snapshot_and_restore_switched_chains
python
ApeWorX/ape
tests/functional/test_chain.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_chain.py
Apache-2.0
def test_network_option_with_other_option(runner): """ To prove can use the `@network_option` with other options in the same command (was issue during production where could not!). """ # Scenario: Using network_option but not using the value in the command callback. # (Potentially handling ind...
To prove can use the `@network_option` with other options in the same command (was issue during production where could not!).
test_network_option_with_other_option
python
ApeWorX/ape
tests/functional/test_cli.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_cli.py
Apache-2.0
def test_account_option_uses_single_account_as_default(runner, one_account): """ When there is only 1 test account, that is the default when no option is given. """ @click.command() @account_option(account_type=[one_account]) def cmd(account): _expected = get_expected_account_str(ac...
When there is only 1 test account, that is the default when no option is given.
test_account_option_uses_single_account_as_default
python
ApeWorX/ape
tests/functional/test_cli.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_cli.py
Apache-2.0
def test_prompt_choice(runner, opt): """ This demonstrates how to use ``PromptChoice``, as it is a little confusing, requiring a callback. """ def choice_callback(ctx, param, value): return param.type.select() choice = PromptChoice(["foo", "bar"]) assert hasattr(choice, "name") ...
This demonstrates how to use ``PromptChoice``, as it is a little confusing, requiring a callback.
test_prompt_choice
python
ApeWorX/ape
tests/functional/test_cli.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_cli.py
Apache-2.0
def test_account_prompt_name(): """ It is very important for this class to have the `name` attribute, even though it is not used. That is because some click internals expect this property to exist, and we skip the super() constructor. """ option = AccountAliasPromptChoice() assert option.nam...
It is very important for this class to have the `name` attribute, even though it is not used. That is because some click internals expect this property to exist, and we skip the super() constructor.
test_account_prompt_name
python
ApeWorX/ape
tests/functional/test_cli.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_cli.py
Apache-2.0
def test_contract_file_paths_argument_given_directory_and_file( project_with_contract, runner, contracts_paths_cmd ): """ Tests against a bug where if given a directory AND a file together, only the directory resolved and the file was lost. """ pm = project_with_contract src_stem = next(x fo...
Tests against a bug where if given a directory AND a file together, only the directory resolved and the file was lost.
test_contract_file_paths_argument_given_directory_and_file
python
ApeWorX/ape
tests/functional/test_cli.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_cli.py
Apache-2.0
def test_connected_provider_command_use_custom_options(runner): """ Ensure custom options work when using `ConnectedProviderCommand`. (There was an issue during development where we could not). """ # Scenario: Custom option and using network object. @click.command(cls=ConnectedProviderCommand) ...
Ensure custom options work when using `ConnectedProviderCommand`. (There was an issue during development where we could not).
test_connected_provider_command_use_custom_options
python
ApeWorX/ape
tests/functional/test_cli.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_cli.py
Apache-2.0
def test_flatten_contract(compilers, project_with_contract): """ Positive tests exist in compiler plugins that implement this behavior.b """ source_id = project_with_contract.ApeContract0.contract_type.source_id path = project_with_contract.contracts_folder / source_id with pytest.raises(APINot...
Positive tests exist in compiler plugins that implement this behavior.b
test_flatten_contract
python
ApeWorX/ape
tests/functional/test_compilers.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_compilers.py
Apache-2.0
def test_compile(compilers, project_with_contract, factory): """ Testing both stringified paths and path-object paths. """ path = next(iter(project_with_contract.sources.paths)) actual = compilers.compile((factory(path),), project=project_with_contract) contract_name = path.stem assert contr...
Testing both stringified paths and path-object paths.
test_compile
python
ApeWorX/ape
tests/functional/test_compilers.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_compilers.py
Apache-2.0
def test_compile_multiple_errors( mock_compiler, make_mock_compiler, compilers, project_with_contract ): """ Simulating getting errors from multiple compilers. We should get all the errors. """ second_mock_compiler = make_mock_compiler("mock2") new_contract_0 = project_with_contract.path / f...
Simulating getting errors from multiple compilers. We should get all the errors.
test_compile_multiple_errors
python
ApeWorX/ape
tests/functional/test_compilers.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_compilers.py
Apache-2.0
def test_compile_in_project_where_source_id_matches_local_project(project, compilers): """ Tests against a bug where if you had two projects with the same source IDs but different content, it always compiled the local project's source. """ new_abi = { "inputs": [], "name": "retrieve"...
Tests against a bug where if you had two projects with the same source IDs but different content, it always compiled the local project's source.
test_compile_in_project_where_source_id_matches_local_project
python
ApeWorX/ape
tests/functional/test_compilers.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_compilers.py
Apache-2.0
def test_config_exclude_regex_serialize(): """ Show we can to-and-fro with exclude regexes. """ raw_value = 'r"FooBar"' cfg = Config(exclude=[raw_value]) excl = [x for x in cfg.exclude if isinstance(x, Pattern)] assert len(excl) == 1 assert excl[0].pattern == "FooBar" # NOTE: Use jso...
Show we can to-and-fro with exclude regexes.
test_config_exclude_regex_serialize
python
ApeWorX/ape
tests/functional/test_compilers.py
https://github.com/ApeWorX/ape/blob/master/tests/functional/test_compilers.py
Apache-2.0
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_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_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