From ff995b50cf9e1ea521f3cf546339f05d10b79a4d Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Wed, 11 Feb 2026 21:34:08 -0500 Subject: [PATCH] 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 exception leading to a std::terminate call. https://github.com/bitcoin-core/libmultiprocess/pull/218 was created to fix this, but 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 an upcoming commit. Having this workaround makes the test a little more complicated and less strict but reduces dependencies between pending PRs so they don't need to be reviewed or merged in a particular order. --- test/functional/interface_ipc_mining.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/test/functional/interface_ipc_mining.py b/test/functional/interface_ipc_mining.py index 61c050e74fe..d4a0d87e767 100755 --- a/test/functional/interface_ipc_mining.py +++ b/test/functional/interface_ipc_mining.py @@ -6,6 +6,7 @@ import asyncio from contextlib import AsyncExitStack from io import BytesIO +import re from test_framework.blocktools import NULL_OUTPOINT from test_framework.messages import ( MAX_BLOCK_WEIGHT, @@ -257,12 +258,21 @@ class IPCMiningTest(BitcoinTestFramework): empty_block = await mining_get_block(empty_template, ctx) assert_equal(len(empty_block.vtx), 1) - self.log.debug("Enforce minimum reserved weight for IPC clients too") - opts.blockReservedWeight = 0 - try: - await mining.createNewBlock(opts) - raise AssertionError("createNewBlock unexpectedly succeeded") - except capnp.lib.capnp.KjException as e: + self.log.debug("Enforce minimum reserved weight for IPC clients too") + opts.blockReservedWeight = 0 + try: + await mining.createNewBlock(opts) + raise AssertionError("createNewBlock unexpectedly succeeded") + except capnp.lib.capnp.KjException as e: + if e.type == "DISCONNECTED": + # The remote exception isn't caught currently and leads to a + # std::terminate call. Just detect and restart in this case. + # This bug is fixed with + # https://github.com/bitcoin-core/libmultiprocess/pull/218 + assert_equal(e.description, "Peer disconnected.") + self.nodes[0].wait_until_stopped(expected_ret_code=(-11, -6, 1, 66), expected_stderr=re.compile("")) + self.start_node(0) + else: assert_equal(e.description, "remote exception: std::exception: block_reserved_weight (0) must be at least 2000 weight units") assert_equal(e.type, "FAILED")