From f02d539178660bf8a7c175c8fdababaa7479ccfe Mon Sep 17 00:00:00 2001 From: Aviksaikat Date: Sun, 18 Aug 2024 23:05:51 +0530 Subject: [PATCH] chore: reconnect refactored to disconnect --- ape_infura/provider.py | 9 ++------- tests/test_provider.py | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/ape_infura/provider.py b/ape_infura/provider.py index 7e75749..37f681e 100644 --- a/ape_infura/provider.py +++ b/ape_infura/provider.py @@ -52,8 +52,7 @@ def load_api_keys(self): def __get_random_api_key(self) -> str: """ - Get a random api key a private method. As self.api_keys are unhashable so have to typecast into list - to make it hashable + Get a random api key a private method. """ return random.choice(list(self.api_keys)) @@ -104,16 +103,12 @@ def connect(self): self._web3.eth.set_gas_price_strategy(rpc_gas_price_strategy) def disconnect(self): - self._web3 = None - - def reconnect(self): """ Disconnect the connected API. Refresh the API keys from environment variable. Make the self.network_uris empty otherwise the old network_uri will be returned. - Connect again. """ - self.disconnect() + self._web3 = None self.load_api_keys() self.network_uris = {} diff --git a/tests/test_provider.py b/tests/test_provider.py index b5fa35b..cd9f2aa 100644 --- a/tests/test_provider.py +++ b/tests/test_provider.py @@ -66,7 +66,7 @@ def test_uri_with_random_api_key(provider, mocker): provider.load_api_keys() uris = set() for _ in range(100): # Generate multiple URIs - provider.reconnect() # connect to a new URI + provider.disconnect() # connect to a new URI uri = provider.uri uris.add(uri) assert uri.startswith("https")