Skip to content

Commit 3aa343c

Browse files
ryanofskySjors
authored andcommitted
ipc test: Add workaround to block_reserved_weight exception test
libmultiprocess currently handles uncaught exceptions from IPC methods badly when an `mp.Context` parameter is passed and the IPC call executes on an a worker thread, with the uncaught exceptions leading to std::terminate call. bitcoin-core/libmultiprocess#218 was created to fix this, but before before that change is available, update an IPC test which can trigger this behavior to handle it and recover when mp.Context parameters are added in the next commit.
1 parent 1f1b089 commit 3aa343c

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

test/functional/interface_ipc_mining.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import asyncio
77
from contextlib import AsyncExitStack
88
from io import BytesIO
9+
import re
910
from test_framework.blocktools import NULL_OUTPOINT
1011
from test_framework.messages import (
1112
MAX_BLOCK_WEIGHT,
@@ -257,12 +258,21 @@ async def async_routine():
257258
empty_block = await mining_get_block(empty_template, ctx)
258259
assert_equal(len(empty_block.vtx), 1)
259260

260-
self.log.debug("Enforce minimum reserved weight for IPC clients too")
261-
opts.blockReservedWeight = 0
262-
try:
263-
await mining.createNewBlock(opts)
264-
raise AssertionError("createNewBlock unexpectedly succeeded")
265-
except capnp.lib.capnp.KjException as e:
261+
self.log.debug("Enforce minimum reserved weight for IPC clients too")
262+
opts.blockReservedWeight = 0
263+
try:
264+
await mining.createNewBlock(opts)
265+
raise AssertionError("createNewBlock unexpectedly succeeded")
266+
except capnp.lib.capnp.KjException as e:
267+
if e.type == "DISCONNECTED":
268+
# The remote exception isn't caught currently and leads to a
269+
# std::terminate call. Just detect and restart in this case.
270+
# This bug is fixed with
271+
# https://github.com/bitcoin-core/libmultiprocess/pull/218
272+
assert_equal(e.description, "Peer disconnected.")
273+
self.nodes[0].wait_until_stopped(expected_ret_code=(-11, -6, 1, 66), expected_stderr=re.compile(""))
274+
self.start_node(0)
275+
else:
266276
assert_equal(e.description, "remote exception: std::exception: block_reserved_weight (0) must be at least 2000 weight units")
267277
assert_equal(e.type, "FAILED")
268278

0 commit comments

Comments
 (0)