diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -132,15 +132,16 @@ class CMutableTransaction; class CScript; -// -// Testing fixture that pre-creates a -// 100-block REGTEST-mode block chain -// +/** + * Testing fixture that pre-creates a 100-block REGTEST-mode block chain + */ struct TestChain100Setup : public RegTestingSetup { TestChain100Setup(); - // Create a new block with just given transactions, coinbase paying to - // scriptPubKey, and try to add it to the current chain. + /** + * Create a new block with just given transactions, coinbase paying to + * scriptPubKey, and try to add it to the current chain. + */ CBlock CreateAndProcessBlock(const std::vector &txns, const CScript &scriptPubKey); diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -249,19 +249,14 @@ } } -// -// Create a new block with just given transactions, coinbase paying to -// scriptPubKey, and try to add it to the current chain. -// CBlock TestChain100Setup::CreateAndProcessBlock( const std::vector &txns, const CScript &scriptPubKey) { const Config &config = GetConfig(); - std::unique_ptr pblocktemplate = - BlockAssembler(config, *m_node.mempool).CreateNewBlock(scriptPubKey); - CBlock &block = pblocktemplate->block; + CTxMemPool empty_pool; + CBlock block = + BlockAssembler(config, empty_pool).CreateNewBlock(scriptPubKey)->block; - // Replace mempool-selected txns with just coinbase plus passed-in txns: - block.vtx.resize(1); + Assert(block.vtx.size() == 1); for (const CMutableTransaction &tx : txns) { block.vtx.push_back(MakeTransactionRef(tx)); } @@ -291,8 +286,7 @@ Assert(m_node.chainman) ->ProcessNewBlock(config, shared_pblock, true, nullptr); - CBlock result = block; - return result; + return block; } TestChain100Setup::~TestChain100Setup() {}