From 646e2f5b11fc646297731d427201aa5dcbb8e4e5 Mon Sep 17 00:00:00 2001 From: derekpierre Date: Wed, 4 Sep 2024 07:55:35 -0400 Subject: [PATCH] Remove is_connected in favour of is_initialized for clarity. --- nucypher/blockchain/eth/interfaces.py | 14 +++++++------- tests/unit/test_blockchain_interface.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/nucypher/blockchain/eth/interfaces.py b/nucypher/blockchain/eth/interfaces.py index 8fb1cff63..d6dbf60d5 100644 --- a/nucypher/blockchain/eth/interfaces.py +++ b/nucypher/blockchain/eth/interfaces.py @@ -253,7 +253,7 @@ class BlockchainInterface: self.gas_strategy = gas_strategy or self.DEFAULT_GAS_STRATEGY self.max_gas_price = max_gas_price - self.__is_connected = False + self.__is_initialized = False def __repr__(self): r = "{name}({uri})".format(name=self.__class__.__name__, uri=self.endpoint) @@ -263,8 +263,8 @@ class BlockchainInterface: return self.client.get_blocktime() @property - def is_connected(self) -> bool: - return self.__is_connected + def is_initialized(self) -> bool: + return self.__is_initialized @classmethod def get_gas_strategy(cls, gas_strategy: Union[str, Callable] = None) -> Callable: @@ -307,7 +307,7 @@ class BlockchainInterface: # self.log.debug(f"Gas strategy currently reports a gas price of {gwei_gas_price} gwei.") def connect(self): - if self.__is_connected: + if self.__is_initialized: # safety check - connect was already previously called return @@ -358,8 +358,8 @@ class BlockchainInterface: f"Blockchain: {client.chain_name} (chain_id={chain_id}, block_num={latest_block_number})" ) - self.__is_connected = True - return self.__is_connected + self.__is_initialized = True + return self.__is_initialized @property def provider(self) -> BaseProvider: @@ -844,7 +844,7 @@ class BlockchainInterfaceFactory: # Connect and Sync interface, emitter = cached_interface - if not interface.is_connected: + if not interface.is_initialized: interface.connect() return interface diff --git a/tests/unit/test_blockchain_interface.py b/tests/unit/test_blockchain_interface.py index af724569c..ef0bc3829 100644 --- a/tests/unit/test_blockchain_interface.py +++ b/tests/unit/test_blockchain_interface.py @@ -136,11 +136,11 @@ def test_connect_handle_connectivity_issues(mocker): endpoint="https://public-node.io:8445" ) - assert not blockchain_interface.is_connected + assert not blockchain_interface.is_initialized # connect() is called with no connectivity issues and executes successfully blockchain_interface.connect() - assert blockchain_interface.is_connected + assert blockchain_interface.is_initialized # poa, retry, simplecache current_middlewares = blockchain_interface.w3.middleware_onion.middlewares