|
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,28 +63,18 @@ 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 | 76 | txCoinbase.witness.vtxoutwit.resize(2); |
88 | | - txCoinbase.vout[1].scriptPubKey = pubKey; |
| 77 | + txCoinbase.vout[1].scriptPubKey = P2WSH_OP_TRUE; |
89 | 78 | txCoinbase.vout[1].nValue = txCoinbase.vout[0].nValue; |
90 | 79 | txCoinbase.vout[0].nValue = 0; |
91 | 80 | txCoinbase.witness.vtxinwit.resize(1); |
@@ -257,7 +246,7 @@ BOOST_AUTO_TEST_CASE(mempool_locks_reorg) |
257 | 246 | CMutableTransaction mtx; |
258 | 247 | mtx.vin.push_back(CTxIn{COutPoint{last_mined->vtx[0]->GetHash(), 1}, CScript{}}); |
259 | 248 | mtx.witness.vtxinwit.resize(1); |
260 | | - mtx.witness.vtxinwit[0].scriptWitness.stack.push_back(V_OP_TRUE); |
| 249 | + mtx.witness.vtxinwit[0].scriptWitness.stack.push_back(WITNESS_STACK_ELEM_OP_TRUE); |
261 | 250 | mtx.vout.push_back(last_mined->vtx[0]->vout[1]); |
262 | 251 | mtx.vout[0].nValue = mtx.vout[0].nValue.GetAmount() - 1000; |
263 | 252 | txs.push_back(MakeTransactionRef(mtx)); |
|
0 commit comments