test: verify IPC error handling for invalid coinbase

Add a test case to interface_ipc_mining.py to verify that the IPC
server correctly handles and reports serialization errors rather than
crashing the node.

This covers the scenario where submitSolution is called with data
that cannot be deserialized, as discussed in #33341

Also introduces the assert_capnp_failed helper in ipc_util.py to
cleanly handle macOS-specific Cap'n Proto exception strings, and
refactors an existing block weight test to use it.
This commit is contained in:
Enoch Azariah
2026-03-09 11:06:55 +01:00
parent 63684d6922
commit e7a918b69a
2 changed files with 24 additions and 10 deletions

View File

@@ -10,9 +10,13 @@ from dataclasses import dataclass
from io import BytesIO
from pathlib import Path
import shutil
import platform
from typing import Optional
from test_framework.messages import CBlock
from test_framework.util import (
assert_equal
)
# Test may be skipped and not have capnp installed
try:
@@ -155,3 +159,14 @@ async def make_mining_ctx(self):
self.log.debug("Create Mining proxy object")
mining = init.makeMining(ctx).result
return ctx, mining
def assert_capnp_failed(e, description_prefix):
if e.description == "remote exception: unknown non-KJ exception of type: kj::Exception":
# macOS + REDUCE_EXPORTS bug: Cap'n Proto fails to recognize
# its own exception type and returns a generic error instead.
# https://github.com/bitcoin/bitcoin/pull/34422#discussion_r2863852691
# Assert this only occurs on Darwin until fixed.
assert_equal(platform.system(), "Darwin")
else:
assert e.description.startswith(description_prefix), f"Expected description starting with '{description_prefix}', got '{e.description}'"
assert_equal(e.type, "FAILED")