| 16 | #include <vector> |
| 17 | |
| 18 | static void AssembleBlock(benchmark::Bench& bench) |
| 19 | { |
| 20 | const auto test_setup = MakeNoLogFileContext<const TestingSetup>(); |
| 21 | |
| 22 | CScriptWitness witness; |
| 23 | witness.stack.push_back(WITNESS_STACK_ELEM_OP_TRUE); |
| 24 | |
| 25 | // Collect some loose transactions that spend the coinbases of our mined blocks |
| 26 | constexpr size_t NUM_BLOCKS{200}; |
| 27 | std::array<CTransactionRef, NUM_BLOCKS - COINBASE_MATURITY + 1> txs; |
| 28 | for (size_t b{0}; b < NUM_BLOCKS; ++b) { |
| 29 | CMutableTransaction tx; |
| 30 | tx.vin.push_back(MineBlock(test_setup->m_node, P2WSH_OP_TRUE)); |
| 31 | tx.witness.vtxinwit.resize(1); |
| 32 | tx.witness.vtxinwit.back().scriptWitness = witness; |
| 33 | tx.vout.emplace_back(CTxOut(CAsset(), 1337, P2WSH_OP_TRUE)); |
| 34 | if (NUM_BLOCKS - b >= COINBASE_MATURITY) |
| 35 | txs.at(b) = MakeTransactionRef(tx); |
| 36 | } |
| 37 | { |
| 38 | LOCK(::cs_main); |
| 39 | |
| 40 | for (const auto& txr : txs) { |
| 41 | const MempoolAcceptResult res = test_setup->m_node.chainman->ProcessTransaction(txr); |
| 42 | assert(res.m_result_type == MempoolAcceptResult::ResultType::VALID); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | bench.run([&] { |
| 47 | PrepareBlock(test_setup->m_node, P2WSH_OP_TRUE); |
| 48 | }); |
| 49 | } |
| 50 | |
| 51 | BENCHMARK(AssembleBlock); |
nothing calls this directly
no test coverage detected