From e17fa601fd39e948b0a4634e6ca7adbc933926ab Mon Sep 17 00:00:00 2001 From: antazoey Date: Tue, 18 Feb 2025 10:18:30 -0600 Subject: [PATCH] fix: dont cache none --- src/ape/managers/_contractscache.py | 9 ++++++--- tests/functional/test_contracts_cache.py | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ape/managers/_contractscache.py b/src/ape/managers/_contractscache.py index d83a484250..dfb6a6d575 100644 --- a/src/ape/managers/_contractscache.py +++ b/src/ape/managers/_contractscache.py @@ -577,15 +577,18 @@ def get( if fetch_from_explorer else None ) + contract_type_to_cache = None + if proxy_contract_type: contract_type_to_cache = _get_combined_contract_type( proxy_contract_type, proxy_info, implementation_contract_type ) - else: + elif implementation_contract_type is not None: contract_type_to_cache = implementation_contract_type - self.contract_types[address_key] = contract_type_to_cache - return contract_type_to_cache + if contract_type_to_cache is not None: + self.contract_types[address_key] = contract_type_to_cache + return contract_type_to_cache # Also gets cached to disk for faster lookup next time. if fetch_from_explorer: diff --git a/tests/functional/test_contracts_cache.py b/tests/functional/test_contracts_cache.py index 69fe605f6e..85f188d2e6 100644 --- a/tests/functional/test_contracts_cache.py +++ b/tests/functional/test_contracts_cache.py @@ -503,6 +503,9 @@ def test_get_pass_along_proxy_info(chain, owner, minimal_proxy_container, ethere actual = chain.contracts.get(minimal_proxy.address, proxy_info=info) assert actual is None # It can't find the contact anymore. + # Ensure it does store 'None' (was a bug where it did). + assert minimal_proxy.address not in chain.contracts.contract_types + def test_get_creation_metadata(chain, vyper_contract_instance, owner): address = vyper_contract_instance.address