mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-21 06:43:34 +01:00
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.
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user