Skip to content

Commit 0aa252d

Browse files
committed
removal: Remove the deprecated LegacyWebSocketProvider
- As promised, we should remove the `LegacyWebSocketProvider` class in `v8`. This commit removes the class and all test cases for it.
1 parent 7171cc5 commit 0aa252d

File tree

16 files changed

+0
-412
lines changed

16 files changed

+0
-412
lines changed

.circleci/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ workflows:
240240
"integration-goethereum-ipc_async",
241241
"integration-goethereum-http",
242242
"integration-goethereum-http_async",
243-
"integration-goethereum-legacy_ws",
244243
"integration-goethereum-ws",
245244
"integration-ethtester"
246245
]

docs/overview.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ following built-in providers:
2222

2323
- :class:`~web3.providers.rpc.HTTPProvider` for connecting to http and https based JSON-RPC servers.
2424
- :class:`~web3.providers.ipc.IPCProvider` for connecting to ipc socket based JSON-RPC servers.
25-
- :class:`~web3.providers.legacy_websocket.LegacyWebSocketProvider` (deprecated) for connecting to websocket based JSON-RPC servers.
2625
- :class:`~web3.providers.async_rpc.AsyncHTTPProvider` for connecting to http and https based JSON-RPC servers asynchronously.
2726
- :class:`~web3.providers.persistent.AsyncIPCProvider` for connecting to ipc socket based JSON-RPC servers asynchronously via a persistent connection.
2827
- :class:`~web3.providers.persistent.WebSocketProvider` for connecting to websocket based JSON-RPC servers asynchronously via a persistent connection.

docs/providers.rst

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -527,48 +527,6 @@ Interacting with the Persistent Connection
527527
For example, use ``w3.eth.get_block("latest")`` instead of
528528
``w3.socket.make_request("eth_getBlockByNumber", ["latest", True])``.
529529

530-
531-
LegacyWebSocketProvider
532-
~~~~~~~~~~~~~~~~~~~~~~~
533-
534-
.. warning::
535-
536-
``LegacyWebSocketProvider`` is deprecated and is likely to be removed in a
537-
future major release. Please use ``WebSocketProvider`` instead.
538-
539-
.. py:class:: web3.providers.legacy_websocket.LegacyWebSocketProvider(endpoint_uri[, websocket_timeout, websocket_kwargs])
540-
541-
This provider handles interactions with an WS or WSS based JSON-RPC server.
542-
543-
* ``endpoint_uri`` should be the full URI to the RPC endpoint such as
544-
``'ws://localhost:8546'``.
545-
* ``websocket_timeout`` is the timeout in seconds, used when receiving or
546-
sending data over the connection. Defaults to 10.
547-
* ``websocket_kwargs`` this should be a dictionary of keyword arguments which
548-
will be passed onto the ws/wss websocket connection.
549-
550-
.. code-block:: python
551-
552-
>>> from web3 import Web3
553-
>>> w3 = Web3(Web3.LegacyWebSocketProvider("ws://127.0.0.1:8546"))
554-
555-
Under the hood, ``LegacyWebSocketProvider`` uses the python ``websockets`` library for
556-
making requests. If you would like to modify how requests are made, you can
557-
use the ``websocket_kwargs`` to do so. See the `websockets documentation`_ for
558-
available arguments.
559-
560-
.. _`websockets documentation`: https://websockets.readthedocs.io/en/stable/reference/asyncio/client.html#websockets.client.WebSocketClientProtocol
561-
562-
Unlike HTTP connections, the timeout for WS connections is controlled by a
563-
separate ``websocket_timeout`` argument, as shown below.
564-
565-
566-
.. code-block:: python
567-
568-
>>> from web3 import Web3
569-
>>> w3 = Web3(Web3.LegacyWebSocketProvider("ws://127.0.0.1:8546", websocket_timeout=60))
570-
571-
572530
AutoProvider
573531
~~~~~~~~~~~~
574532

tests/core/caching-utils/test_request_caching.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
AsyncWeb3,
1717
HTTPProvider,
1818
IPCProvider,
19-
LegacyWebSocketProvider,
2019
PersistentConnectionProvider,
2120
Web3,
2221
WebSocketProvider,
@@ -48,7 +47,6 @@
4847
SYNC_PROVIDERS = [
4948
HTTPProvider,
5049
IPCProvider,
51-
LegacyWebSocketProvider, # deprecated
5250
]
5351
ASYNC_PROVIDERS = [
5452
AsyncHTTPProvider,

tests/core/providers/test_auto_provider.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from web3.providers import (
55
HTTPProvider,
66
IPCProvider,
7-
LegacyWebSocketProvider,
87
)
98
from web3.providers.auto import (
109
load_provider_from_environment,
@@ -39,11 +38,6 @@ def delete_environment_variables(monkeypatch):
3938
IPCProvider,
4039
{"ipc_path": "/root/path/to/file.ipc"},
4140
),
42-
(
43-
"ws://1.2.3.4:5679",
44-
LegacyWebSocketProvider,
45-
{"endpoint_uri": "ws://1.2.3.4:5679"},
46-
),
4741
),
4842
)
4943
def test_load_provider_from_env(monkeypatch, uri, expected_type, expected_attrs):

tests/core/providers/test_legacy_websocket_provider.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/core/providers/test_provider_init.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
EthereumTesterProvider,
1111
HTTPProvider,
1212
IPCProvider,
13-
LegacyWebSocketProvider,
1413
Web3,
1514
WebSocketProvider,
1615
)
@@ -49,7 +48,6 @@ def test_init_web3_with_async_provider(provider_class):
4948
BaseProvider,
5049
ExtendsBaseProvider,
5150
HTTPProvider,
52-
LegacyWebSocketProvider,
5351
IPCProvider,
5452
EthereumTesterProvider,
5553
),

tests/integration/common.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,2 @@
1-
import pytest
2-
3-
from websockets.exceptions import (
4-
ConnectionClosed,
5-
)
6-
7-
from web3 import (
8-
Web3,
9-
)
10-
111
# use same coinbase value as in `web3.py/tests/integration/generate_fixtures/common.py`
122
COINBASE = "0xdc544d1aa88ff8bbd2f2aec754b1f1e99e1812fd"
13-
14-
15-
class MiscWebSocketTest:
16-
def test_websocket_max_size_error(self, w3):
17-
w3_ = Web3(
18-
Web3.LegacyWebSocketProvider(
19-
endpoint_uri=w3.provider.endpoint_uri, websocket_kwargs={"max_size": 1}
20-
)
21-
)
22-
with pytest.raises((OSError, ConnectionClosed)):
23-
w3_.eth.get_block(0)

tests/integration/go_ethereum/test_goethereum_legacy_ws.py

Lines changed: 0 additions & 102 deletions
This file was deleted.

tests/utils.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import asyncio
22
import socket
3-
import time
4-
5-
from websockets import (
6-
WebSocketException,
7-
)
8-
from websockets.legacy.client import (
9-
connect,
10-
)
113

124
from web3._utils.threads import (
135
Timeout,
@@ -44,30 +36,6 @@ def get_open_port():
4436
return str(port)
4537

4638

47-
async def wait_for_ws(endpoint_uri, timeout=10):
48-
start = time.time()
49-
while time.time() < start + timeout:
50-
try:
51-
async with connect(uri=endpoint_uri) as ws:
52-
await ws.send(
53-
'{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}'
54-
)
55-
r = await ws.recv()
56-
if isinstance(r, bytes):
57-
r = r.decode("utf-8")
58-
59-
if "geth" in r.lower():
60-
return
61-
except (OSError, WebSocketException):
62-
pass
63-
except Exception:
64-
raise
65-
await asyncio.sleep(0.01)
66-
raise TimeoutError(
67-
f"Geth WebSocket did not respond on {endpoint_uri} within {timeout} seconds."
68-
)
69-
70-
7139
async def _async_wait_for_block_fixture_logic(async_w3, block_number=1, timeout=None):
7240
if not timeout:
7341
current_block_number = await async_w3.eth.block_number # type:ignore

0 commit comments

Comments
 (0)