Merge bitcoin/bitcoin#18933: rpc: Add submit option to generateblock

fa18504d57 rpc: Add submit option to generateblock (MarcoFalke)
fab9a08e14 refactor: Replace block_hash with block_out (MarcoFalke)

Pull request description:

  When submit is turned off, a block can be generated and returned as hex, to be used for further tests. For example, it can be submitted on a different node, on a different interface (like p2p), or just never submitted and be used for other testing purposes.

ACKs for top commit:
  instagibbs:
    ACK fa18504d57
  TheCharlatan:
    tACK fa18504d57

Tree-SHA512: 1b2ab6b71bb7e155c6482d75f5373f4e77de6446cb16bc2dfd19e7a4075b3a6ad87d7ad7a049a9eed934cb71574acfd27202f54c8bb3b03fac869f2e95db7ee5
This commit is contained in:
fanquake
2023-03-23 13:28:07 +00:00
3 changed files with 29 additions and 14 deletions

View File

@@ -29,8 +29,13 @@ class RPCGenerateTest(BitcoinTestFramework):
node = self.nodes[0]
miniwallet = MiniWallet(node)
self.log.info('Generate an empty block to address')
self.log.info('Mine an empty block to address and return the hex')
address = miniwallet.get_address()
generated_block = self.generateblock(node, output=address, transactions=[], submit=False)
node.submitblock(hexdata=generated_block['hex'])
assert_equal(generated_block['hash'], node.getbestblockhash())
self.log.info('Generate an empty block to address')
hash = self.generateblock(node, output=address, transactions=[])['hash']
block = node.getblock(blockhash=hash, verbose=2)
assert_equal(len(block['tx']), 1)