diff --git a/src/test/blockcheck_tests.cpp b/src/test/blockcheck_tests.cpp --- a/src/test/blockcheck_tests.cpp +++ b/src/test/blockcheck_tests.cpp @@ -39,6 +39,10 @@ BOOST_CHECK_EQUAL(state.GetRejectReason(), reason); } +static COutPoint InsecureRandOutPoint() { + return COutPoint(TxId(InsecureRand256()), 0); +} + BOOST_AUTO_TEST_CASE(blockfail) { SelectParams(CBaseChainParams::MAIN); @@ -63,7 +67,7 @@ RunCheckOnBlock(config, block); // No coinbase - tx.vin[0].prevout = COutPoint(InsecureRand256(), 0); + tx.vin[0].prevout = InsecureRandOutPoint(); block.vtx[0] = MakeTransactionRef(tx); RunCheckOnBlock(config, block, "bad-cb-missing"); @@ -82,7 +86,7 @@ auto maxTxCount = ((DEFAULT_MAX_BLOCK_SIZE - 1) / txSize) - 1; for (size_t i = 1; i < maxTxCount; i++) { - tx.vin[0].prevout = COutPoint(InsecureRand256(), 0); + tx.vin[0].prevout = InsecureRandOutPoint(); block.vtx.push_back(MakeTransactionRef(tx)); } @@ -91,7 +95,7 @@ // But reject it with one more transaction as it goes over the maximum // allowed block size. - tx.vin[0].prevout = COutPoint(InsecureRand256(), 0); + tx.vin[0].prevout = InsecureRandOutPoint(); block.vtx.push_back(MakeTransactionRef(tx)); RunCheckOnBlock(config, block, "bad-blk-length"); } diff --git a/src/test/blockencodings_tests.cpp b/src/test/blockencodings_tests.cpp --- a/src/test/blockencodings_tests.cpp +++ b/src/test/blockencodings_tests.cpp @@ -23,6 +23,10 @@ BOOST_FIXTURE_TEST_SUITE(blockencodings_tests, RegtestingSetup) +static COutPoint InsecureRandOutPoint() { + return COutPoint(TxId(InsecureRand256()), 0); +} + static CBlock BuildBlockTestCase() { CBlock block; CMutableTransaction tx; @@ -37,12 +41,12 @@ block.hashPrevBlock = InsecureRand256(); block.nBits = 0x207fffff; - tx.vin[0].prevout = COutPoint(InsecureRand256(), 0); + tx.vin[0].prevout = InsecureRandOutPoint(); block.vtx[1] = MakeTransactionRef(tx); tx.vin.resize(10); for (size_t i = 0; i < tx.vin.size(); i++) { - tx.vin[i].prevout = COutPoint(InsecureRand256(), 0); + tx.vin[i].prevout = InsecureRandOutPoint(); } block.vtx[2] = MakeTransactionRef(tx);