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