diff --git a/src/ape_test/accounts.py b/src/ape_test/accounts.py index b1e2ec22c4..b3b40777c2 100644 --- a/src/ape_test/accounts.py +++ b/src/ape_test/accounts.py @@ -1,5 +1,6 @@ import warnings from collections.abc import Iterator +from functools import cached_property from typing import TYPE_CHECKING, Any, Optional, Union, cast from eip712.messages import EIP712Message @@ -115,7 +116,7 @@ class TestAccount(TestAccountAPI): def alias(self) -> str: return f"TEST::{self.index}" - @property + @cached_property def address(self) -> AddressType: return self.network_manager.ethereum.decode_address(self.address_str) @@ -125,7 +126,7 @@ def public_key(self) -> "HexBytes": @log_instead_of_fail(default="") def __repr__(self) -> str: - return f"<{self.__class__.__name__}_{self.index} {self.address_str}>" + return f"<{self.__class__.__name__}_{self.index} {self.address}>" def sign_authorization( self, diff --git a/tests/functional/test_accounts.py b/tests/functional/test_accounts.py index 864b0fe0a9..c2df02e37e 100644 --- a/tests/functional/test_accounts.py +++ b/tests/functional/test_accounts.py @@ -681,6 +681,10 @@ def test_test_accounts_repr(accounts, config): actual = repr(accounts) assert config.get_config("test").hd_path in actual + # Show actual test-account repr (address should be checksummed). + actual = repr(accounts[0]) + assert accounts[0].address in actual + def test_account_comparison_to_non_account(core_account): # Before, would get a ConversionError.