File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
2- # Copyright (c) 2020-2022 The Bitcoin Core developers
2+ # Copyright (c) 2020-present The Bitcoin Core developers
33# Distributed under the MIT software license, see the accompanying
44# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55"""Test generate* RPCs."""
66
7+ from concurrent .futures import ThreadPoolExecutor
8+
79from test_framework .test_framework import BitcoinTestFramework
810from test_framework .wallet import MiniWallet
911from test_framework .util import (
@@ -83,6 +85,13 @@ def test_generateblock(self):
8385 txid = block ['tx' ][1 ]
8486 assert_equal (node .getrawtransaction (txid = txid , verbose = False , blockhash = hash ), rawtx )
8587
88+ # Ensure that generateblock can be called concurrently by many threads.
89+ self .log .info ('Generate blocks in parallel' )
90+ generate_50_blocks = lambda n : [n .generateblock (output = address , transactions = []) for _ in range (50 )]
91+ rpcs = [node .cli for _ in range (6 )]
92+ with ThreadPoolExecutor (max_workers = len (rpcs )) as threads :
93+ list (threads .map (generate_50_blocks , rpcs ))
94+
8695 self .log .info ('Fail to generate block with out of order txs' )
8796 txid1 = miniwallet .send_self_transfer (from_node = node )['txid' ]
8897 utxo1 = miniwallet .get_utxo (txid = txid1 )
You can’t perform that action at this time.
0 commit comments