From 6eaa00fe20206baedc0d8ade5bb8d066ea615704 Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Fri, 31 Oct 2025 12:01:04 +0100 Subject: [PATCH] test: clarify submitBlock() mutates the template PR #33374 proposed a new Mining IPC method applySolution() which could be used by clients to obtain the reconstructed block for inspection, especially in the case of a rejected block. However it was pointed out during review that submitBlock() modified the template CBlock in place, so the client can just call getBlock() and no new method is needed. This commit adds a test to document that (now intentional) behavior. --- test/functional/interface_ipc.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/functional/interface_ipc.py b/test/functional/interface_ipc.py index e905c7753be..cce56e3294b 100755 --- a/test/functional/interface_ipc.py +++ b/test/functional/interface_ipc.py @@ -215,11 +215,20 @@ class IPCInterfaceTest(BitcoinTestFramework): res = await mining.result.checkBlock(block.serialize(), check_opts) assert_equal(res.result, True) + # The remote template block will be mutated, capture the original: + remote_block_before = await self.parse_and_deserialize_block(template, ctx) + self.log.debug("Submitted coinbase must include witness") assert_not_equal(coinbase.serialize_without_witness().hex(), coinbase.serialize().hex()) res = await template.result.submitSolution(ctx, block.nVersion, block.nTime, block.nNonce, coinbase.serialize_without_witness()) assert_equal(res.result, False) + self.log.debug("Even a rejected submitBlock() mutates the template's block") + # Can be used by clients to download and inspect the (rejected) + # reconstructed block. + remote_block_after = await self.parse_and_deserialize_block(template, ctx) + assert_not_equal(remote_block_before.serialize().hex(), remote_block_after.serialize().hex()) + self.log.debug("Submit again, with the witness") res = await template.result.submitSolution(ctx, block.nVersion, block.nTime, block.nNonce, coinbase.serialize()) assert_equal(res.result, True)