0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-09 10:43:19 -05:00

test: Move doxygen comment to header

Also, unrelated formatting fixups.

Can be reviewed with --word-diff-regex=.
This commit is contained in:
MarcoFalke 2020-08-21 15:37:38 +02:00
parent d254e6e795
commit fa96574b0d
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
2 changed files with 15 additions and 18 deletions

View file

@ -204,27 +204,24 @@ TestChain100Setup::TestChain100Setup()
// Generate a 100-block chain: // Generate a 100-block chain:
coinbaseKey.MakeNewKey(true); coinbaseKey.MakeNewKey(true);
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG; CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
for (int i = 0; i < COINBASE_MATURITY; i++) for (int i = 0; i < COINBASE_MATURITY; i++) {
{
std::vector<CMutableTransaction> noTxns; std::vector<CMutableTransaction> noTxns;
CBlock b = CreateAndProcessBlock(noTxns, scriptPubKey); CBlock b = CreateAndProcessBlock(noTxns, scriptPubKey);
m_coinbase_txns.push_back(b.vtx[0]); m_coinbase_txns.push_back(b.vtx[0]);
} }
} }
// 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<CMutableTransaction>& txns, const CScript& scriptPubKey) CBlock TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransaction>& txns, const CScript& scriptPubKey)
{ {
const CChainParams& chainparams = Params(); const CChainParams& chainparams = Params();
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler(*m_node.mempool, chainparams).CreateNewBlock(scriptPubKey); CBlock block = BlockAssembler(*m_node.mempool, chainparams).CreateNewBlock(scriptPubKey)->block;
CBlock& block = pblocktemplate->block;
// Replace mempool-selected txns with just coinbase plus passed-in txns: // Replace mempool-selected txns with just coinbase plus passed-in txns:
block.vtx.resize(1); block.vtx.resize(1);
for (const CMutableTransaction& tx : txns) for (const CMutableTransaction& tx : txns) {
block.vtx.push_back(MakeTransactionRef(tx)); block.vtx.push_back(MakeTransactionRef(tx));
}
// IncrementExtraNonce creates a valid coinbase and merkleRoot // IncrementExtraNonce creates a valid coinbase and merkleRoot
{ {
LOCK(cs_main); LOCK(cs_main);
@ -237,8 +234,7 @@ CBlock TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransa
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(block); std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(block);
Assert(m_node.chainman)->ProcessNewBlock(chainparams, shared_pblock, true, nullptr); Assert(m_node.chainman)->ProcessNewBlock(chainparams, shared_pblock, true, nullptr);
CBlock result = block; return block;
return result;
} }
TestChain100Setup::~TestChain100Setup() TestChain100Setup::~TestChain100Setup()
@ -246,8 +242,8 @@ TestChain100Setup::~TestChain100Setup()
gArgs.ForceSetArg("-segwitheight", "0"); gArgs.ForceSetArg("-segwitheight", "0");
} }
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction& tx)
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction &tx) { {
return FromTx(MakeTransactionRef(tx)); return FromTx(MakeTransactionRef(tx));
} }

View file

@ -102,15 +102,16 @@ class CBlock;
struct CMutableTransaction; struct CMutableTransaction;
class CScript; class CScript;
// /**
// Testing fixture that pre-creates a * Testing fixture that pre-creates a 100-block REGTEST-mode block chain
// 100-block REGTEST-mode block chain */
//
struct TestChain100Setup : public RegTestingSetup { struct TestChain100Setup : public RegTestingSetup {
TestChain100Setup(); 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<CMutableTransaction>& txns, CBlock CreateAndProcessBlock(const std::vector<CMutableTransaction>& txns,
const CScript& scriptPubKey); const CScript& scriptPubKey);