Skip to content

Commit 35ddda0

Browse files
committed
Add new line delimiter to all IPCProvider writes
1 parent b3ca75c commit 35ddda0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

tests/core/providers/test_ipc_provider.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
)
1010
import time
1111
from unittest.mock import (
12+
Mock,
1213
patch,
1314
)
1415

@@ -185,3 +186,14 @@ def test_web3_auto_gethdev(request_mocker):
185186

186187
assert "extraData" not in block
187188
assert block.proofOfAuthorityData == b"\xff" * 33
189+
190+
191+
def test_ipc_provider_write_messages_end_with_new_line_delimiter(jsonrpc_ipc_pipe_path):
192+
provider = IPCProvider(pathlib.Path(jsonrpc_ipc_pipe_path), timeout=3)
193+
provider._socket.sock = Mock()
194+
provider._socket.sock.recv.return_value = b'{"id":1, "result": {}}\n'
195+
196+
provider.make_request("method", [])
197+
198+
request_data = b'{"jsonrpc": "2.0", "method": "method", "params": [], "id": 0}'
199+
provider._socket.sock.sendall.assert_called_with(request_data + b"\n")

web3/providers/ipc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def __str__(self) -> str:
164164
def _make_request(self, request: bytes) -> RPCResponse:
165165
with self._lock, self._socket as sock:
166166
try:
167-
sock.sendall(request)
167+
sock.sendall(request + b"\n")
168168
except BrokenPipeError:
169169
# one extra attempt, then give up
170170
sock = self._socket.reset()

0 commit comments

Comments
 (0)