|
11 | 11 | #include <pow.h>
|
12 | 12 | #include <random.h>
|
13 | 13 | #include <script/standard.h>
|
| 14 | +#include <test/util/script.h> |
14 | 15 | #include <test/util/setup_common.h>
|
15 | 16 | #include <util/time.h>
|
16 | 17 | #include <validation.h>
|
17 | 18 | #include <validationinterface.h>
|
18 | 19 |
|
19 | 20 | #include <thread>
|
20 | 21 |
|
21 |
| -static const std::vector<unsigned char> V_OP_TRUE{OP_TRUE}; |
22 |
| - |
23 | 22 | namespace validation_block_tests {
|
24 | 23 | struct MinerTestingSetup : public RegTestingSetup {
|
25 | 24 | std::shared_ptr<CBlock> Block(const uint256& prev_hash);
|
@@ -64,27 +63,17 @@ std::shared_ptr<CBlock> MinerTestingSetup::Block(const uint256& prev_hash)
|
64 | 63 | static int i = 0;
|
65 | 64 | static uint64_t time = Params().GenesisBlock().nTime;
|
66 | 65 |
|
67 |
| - CScript pubKey; |
68 |
| - pubKey << i++ << OP_TRUE; |
69 |
| - |
70 |
| - auto ptemplate = BlockAssembler(*m_node.mempool, Params()).CreateNewBlock(pubKey); |
| 66 | + auto ptemplate = BlockAssembler(*m_node.mempool, Params()).CreateNewBlock(CScript{} << i++ << OP_TRUE); |
71 | 67 | auto pblock = std::make_shared<CBlock>(ptemplate->block);
|
72 | 68 | pblock->hashPrevBlock = prev_hash;
|
73 | 69 | pblock->nTime = ++time;
|
74 | 70 |
|
75 |
| - pubKey.clear(); |
76 |
| - { |
77 |
| - WitnessV0ScriptHash witness_program; |
78 |
| - CSHA256().Write(&V_OP_TRUE[0], V_OP_TRUE.size()).Finalize(witness_program.begin()); |
79 |
| - pubKey << OP_0 << ToByteVector(witness_program); |
80 |
| - } |
81 |
| - |
82 | 71 | // Make the coinbase transaction with two outputs:
|
83 | 72 | // One zero-value one that has a unique pubkey to make sure that blocks at the same height can have a different hash
|
84 | 73 | // Another one that has the coinbase reward in a P2WSH with OP_TRUE as witness program to make it easy to spend
|
85 | 74 | CMutableTransaction txCoinbase(*pblock->vtx[0]);
|
86 | 75 | txCoinbase.vout.resize(2);
|
87 |
| - txCoinbase.vout[1].scriptPubKey = pubKey; |
| 76 | + txCoinbase.vout[1].scriptPubKey = P2WSH_OP_TRUE; |
88 | 77 | txCoinbase.vout[1].nValue = txCoinbase.vout[0].nValue;
|
89 | 78 | txCoinbase.vout[0].nValue = 0;
|
90 | 79 | txCoinbase.vin[0].scriptWitness.SetNull();
|
@@ -254,7 +243,7 @@ BOOST_AUTO_TEST_CASE(mempool_locks_reorg)
|
254 | 243 | for (int num_txs = 22; num_txs > 0; --num_txs) {
|
255 | 244 | CMutableTransaction mtx;
|
256 | 245 | mtx.vin.push_back(CTxIn{COutPoint{last_mined->vtx[0]->GetHash(), 1}, CScript{}});
|
257 |
| - mtx.vin[0].scriptWitness.stack.push_back(V_OP_TRUE); |
| 246 | + mtx.vin[0].scriptWitness.stack.push_back(WITNESS_STACK_ELEM_OP_TRUE); |
258 | 247 | mtx.vout.push_back(last_mined->vtx[0]->vout[1]);
|
259 | 248 | mtx.vout[0].nValue -= 1000;
|
260 | 249 | txs.push_back(MakeTransactionRef(mtx));
|
|
0 commit comments