Skip to content

Commit 4e7142f

Browse files
committed
test: Update interface_ipc.py after fixes from bitcoin-core/libmultiprocess#240
1 parent 578755f commit 4e7142f

1 file changed

Lines changed: 13 additions & 24 deletions

File tree

test/functional/interface_ipc.py

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test the IPC (multiprocess) interface."""
66
import asyncio
7-
import http.client
8-
import re
97

108
from contextlib import ExitStack
119
from test_framework.test_framework import BitcoinTestFramework
@@ -89,9 +87,9 @@ async def async_routine():
8987
=======
9088
def run_unclean_disconnect_test(self):
9189
"""Test behavior when disconnecting during an IPC call that later
92-
returns a non-null interface pointer. Currently this behavior causes a
93-
crash as reported https://github.com/bitcoin/bitcoin/issues/34250, but a
94-
followup will change this behavior."""
90+
returns a non-null interface pointer. This used to cause a crash as
91+
reported https://github.com/bitcoin/bitcoin/issues/34250, but now just
92+
results in a cancellation log message"""
9593
node = self.nodes[0]
9694
self.log.info("Running disconnect during BlockTemplate.waitNext")
9795
timeout = self.rpc_timeout * 1000.0
@@ -116,28 +114,22 @@ async def async_routine():
116114
with node.assert_debug_log(expected_msgs=["BlockTemplate.waitNext", "IPC server post request"], timeout=2):
117115
promise = template.waitNext(ctx, waitoptions)
118116
await asyncio.sleep(0.1)
119-
disconnected_log_check.enter_context(node.assert_debug_log(expected_msgs=["IPC server: socket disconnected"], timeout=2))
117+
disconnected_log_check.enter_context(node.assert_debug_log(expected_msgs=["IPC server: socket disconnected", "canceled while executing"], timeout=2))
120118
del promise
121119

122120
asyncio.run(capnp.run(async_routine()))
123121

124122
# Wait for socket disconnected log message, then generate a block to
125-
# cause the waitNext() call to return a new template. This will cause a
126-
# crash and disconnect with error output.
127-
disconnected_log_check.close()
128-
try:
123+
# cause the waitNext() call to return a new template. Look for a
124+
# canceled IPC log message after waitNext returns.
125+
with node.assert_debug_log(expected_msgs=["interrupted (canceled)"]):
126+
disconnected_log_check.close()
129127
self.generate(node, 1)
130-
except (http.client.RemoteDisconnected, BrokenPipeError, ConnectionResetError):
131-
pass
132-
node.wait_until_stopped(expected_ret_code=(-11, -6, 1, 66), expected_stderr=re.compile(""))
133-
self.start_node(0)
134128

135129
def run_thread_busy_test(self):
136130
"""Test behavior when sending multiple calls to the same server thread
137131
which used to cause a crash as reported
138-
https://github.com/bitcoin/bitcoin/issues/33923 and currently causes a
139-
thread busy error. A future change will make this just queue the calls
140-
for execution and not trigger any error"""
132+
https://github.com/bitcoin/bitcoin/issues/33923."""
141133
node = self.nodes[0]
142134
self.log.info("Running thread busy test")
143135
timeout = self.rpc_timeout * 1000.0
@@ -168,19 +160,16 @@ async def async_routine():
168160
with node.assert_debug_log(expected_msgs=["BlockTemplate.waitNext", "IPC server post request"], timeout=2):
169161
promise2 = template.waitNext(ctx, waitoptions)
170162
await asyncio.sleep(0.1)
171-
try:
172-
await template.waitNext(ctx, waitoptions)
173-
except capnp.lib.capnp.KjException as e:
174-
assert_equal(e.description, "remote exception: std::exception: thread busy")
175-
assert_equal(e.type, "FAILED")
176-
else:
177-
raise AssertionError("Expected thread busy exception")
163+
with node.assert_debug_log(expected_msgs=["BlockTemplate.waitNext", "IPC server post request"]):
164+
promise3 = template.waitNext(ctx, waitoptions)
165+
await asyncio.sleep(0.1)
178166

179167
# Generate a new block to make the active waitNext calls return, then clean up.
180168
with node.assert_debug_log(expected_msgs=["IPC server send response"], timeout=2):
181169
self.generate(node, 1, sync_fun=self.no_op)
182170
await ((await promise1).result).destroy(ctx)
183171
await ((await promise2).result).destroy(ctx)
172+
await ((await promise3).result).destroy(ctx)
184173
await template.destroy(ctx)
185174

186175
asyncio.run(capnp.run(async_routine()))

0 commit comments

Comments
 (0)