diff --git a/src/miner.cpp b/src/miner.cpp index 31cd7af2b..8b802ce72 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff --git a/src/miner.h b/src/miner.h index 8cdcf7133..2fab20976 100644 --- a/src/miner.h +++ b/src/miner.h @@ -8,7 +8,6 @@ #include #include -#include #include #include diff --git a/src/test/blockchain_tests.cpp b/src/test/blockchain_tests.cpp index 1d7ee8a01..19eb3d23e 100644 --- a/src/test/blockchain_tests.cpp +++ b/src/test/blockchain_tests.cpp @@ -4,6 +4,7 @@ #include #include +#include /* Equality between doubles is imprecise. Comparison should be done * with a small threshold of tolerance, rather than exact equality. diff --git a/src/test/blockencodings_tests.cpp b/src/test/blockencodings_tests.cpp index dee7cd763..b86b3f3ea 100644 --- a/src/test/blockencodings_tests.cpp +++ b/src/test/blockencodings_tests.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include @@ -19,6 +20,8 @@ struct RegtestingSetup : public TestingSetup { RegtestingSetup() : TestingSetup(CBaseChainParams::REGTEST) {} }; +extern CTxMemPoolEntry FromTx(CTransactionRef tx, const TestMemPoolEntryHelper& entry); + BOOST_FIXTURE_TEST_SUITE(blockencodings_tests, RegtestingSetup) static CBlock BuildBlockTestCase() { @@ -64,7 +67,7 @@ BOOST_AUTO_TEST_CASE(SimpleRoundTripTest) CBlock block(BuildBlockTestCase()); LOCK(pool.cs); - pool.addUnchecked(block.vtx[2]->GetHash(), entry.FromTx(block.vtx[2])); + pool.addUnchecked(block.vtx[2]->GetHash(), FromTx(block.vtx[2], entry)); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0); // Do a simple ShortTxIDs RT @@ -164,7 +167,7 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest) CBlock block(BuildBlockTestCase()); LOCK(pool.cs); - pool.addUnchecked(block.vtx[2]->GetHash(), entry.FromTx(block.vtx[2])); + pool.addUnchecked(block.vtx[2]->GetHash(), FromTx(block.vtx[2], entry)); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0); uint256 txhash; @@ -234,7 +237,7 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest) CBlock block(BuildBlockTestCase()); LOCK(pool.cs); - pool.addUnchecked(block.vtx[1]->GetHash(), entry.FromTx(block.vtx[1])); + pool.addUnchecked(block.vtx[1]->GetHash(), FromTx(block.vtx[1], entry)); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0); uint256 txhash; diff --git a/src/test/claimtriebranching_tests.cpp b/src/test/claimtriebranching_tests.cpp index 78de6120b..e69a2ac03 100644 --- a/src/test/claimtriebranching_tests.cpp +++ b/src/test/claimtriebranching_tests.cpp @@ -3,6 +3,7 @@ // file COPYING or http://opensource.org/licenses/mit-license.php #include +#include using namespace std; diff --git a/src/test/claimtriecache_tests.cpp b/src/test/claimtriecache_tests.cpp index d389cb370..299bfd026 100644 --- a/src/test/claimtriecache_tests.cpp +++ b/src/test/claimtriecache_tests.cpp @@ -1,5 +1,4 @@ -#include #include #include #include diff --git a/src/test/claimtrieexpirationfork_tests.cpp b/src/test/claimtrieexpirationfork_tests.cpp index eeea2ec46..5deac8e75 100644 --- a/src/test/claimtrieexpirationfork_tests.cpp +++ b/src/test/claimtrieexpirationfork_tests.cpp @@ -3,6 +3,7 @@ // file COPYING or http://opensource.org/licenses/mit-license.php #include +#include using namespace std; diff --git a/src/test/claimtriefixture.cpp b/src/test/claimtriefixture.cpp index 633a1bf8e..068b18ef9 100644 --- a/src/test/claimtriefixture.cpp +++ b/src/test/claimtriefixture.cpp @@ -3,7 +3,10 @@ // file COPYING or http://opensource.org/licenses/mit-license.php #include +#include +#include #include +#include using namespace std; @@ -267,7 +270,7 @@ CMutableTransaction ClaimTrieChainFixture::MakeUpdate(const CTransaction &prev, return tx; } -CTransaction ClaimTrieChainFixture::GetCoinbase() +CTransaction& ClaimTrieChainFixture::GetCoinbase() { return coinbase_txs.at(coinbase_txs_used++); } diff --git a/src/test/claimtriefixture.h b/src/test/claimtriefixture.h index e93b88b58..dd010ee82 100644 --- a/src/test/claimtriefixture.h +++ b/src/test/claimtriefixture.h @@ -10,33 +10,30 @@ #include #include #include -#include #include #include #include -#include #include #include #include #include #include -#include #include -#include #include #include -extern ::CChainState g_chainstate; extern ::ArgsManager gArgs; extern std::vector random_strings(std::size_t count); - +class CTransaction; CMutableTransaction BuildTransaction(const uint256& prevhash); CMutableTransaction BuildTransaction(const CTransaction& prev, uint32_t prevout=0, unsigned int numOutputs=1, int locktime=0); +class BlockAssembler; BlockAssembler AssemblerForTest(); +class CBlockTemplate; // Test Fixtures struct ClaimTrieChainFixture: public CClaimTrieCache { @@ -85,7 +82,7 @@ struct ClaimTrieChainFixture: public CClaimTrieCache // make update at the current block CMutableTransaction MakeUpdate(const CTransaction &prev, const std::string& name, const std::string& value, const uint160& claimId, CAmount quantity); - CTransaction GetCoinbase(); + CTransaction& GetCoinbase(); // create i blocks void IncrementBlocks(int num_blocks, bool mark = false); diff --git a/src/test/claimtriehashfork_tests.cpp b/src/test/claimtriehashfork_tests.cpp index ae3f81d99..d37628a24 100644 --- a/src/test/claimtriehashfork_tests.cpp +++ b/src/test/claimtriehashfork_tests.cpp @@ -2,7 +2,9 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://opensource.org/licenses/mit-license.php +#include #include +#include using namespace std; diff --git a/src/test/claimtrienormalization_tests.cpp b/src/test/claimtrienormalization_tests.cpp index 8f5ade985..263a8fbf6 100644 --- a/src/test/claimtrienormalization_tests.cpp +++ b/src/test/claimtrienormalization_tests.cpp @@ -3,6 +3,9 @@ // file COPYING or http://opensource.org/licenses/mit-license.php #include +#include + +extern ::CChainState g_chainstate; using namespace std; diff --git a/src/test/claimtrierpc_tests.cpp b/src/test/claimtrierpc_tests.cpp index d235974be..268436ce4 100644 --- a/src/test/claimtrierpc_tests.cpp +++ b/src/test/claimtrierpc_tests.cpp @@ -4,6 +4,7 @@ #include #include +#include using namespace std; diff --git a/src/test/hash_tests.cpp b/src/test/hash_tests.cpp index 38177fca9..5100ddd01 100644 --- a/src/test/hash_tests.cpp +++ b/src/test/hash_tests.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp index e416de098..afb398974 100644 --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -573,20 +573,20 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest) SetMockTime(0); } -inline CTransactionRef make_tx(std::vector&& output_values, std::vector&& inputs=std::vector(), std::vector&& input_indices=std::vector()) +inline CMutableTransaction make_tx(std::vector&& output_values, std::vector&& inputs=std::vector(), std::vector&& input_indices=std::vector()) { CMutableTransaction tx = CMutableTransaction(); tx.vin.resize(inputs.size()); tx.vout.resize(output_values.size()); for (size_t i = 0; i < inputs.size(); ++i) { - tx.vin[i].prevout.hash = inputs[i]->GetHash(); + tx.vin[i].prevout.hash = inputs[i].GetHash(); tx.vin[i].prevout.n = input_indices.size() > i ? input_indices[i] : 0; } for (size_t i = 0; i < output_values.size(); ++i) { tx.vout[i].scriptPubKey = CScript() << OP_11 << OP_EQUAL; tx.vout[i].nValue = output_values[i]; } - return MakeTransactionRef(tx); + return tx; } @@ -602,11 +602,11 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests) // // [tx1] // - CTransactionRef tx1 = make_tx(/* output_values */ {10 * COIN}); - pool.addUnchecked(tx1->GetHash(), entry.Fee(10000LL).FromTx(tx1)); + auto tx1 = make_tx(/* output_values */ {10 * COIN}); + pool.addUnchecked(tx1.GetHash(), entry.Fee(10000LL).FromTx(tx1)); // Ancestors / descendants should be 1 / 1 (itself / itself) - pool.GetTransactionAncestry(tx1->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx1.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 1ULL); BOOST_CHECK_EQUAL(descendants, 1ULL); @@ -614,18 +614,18 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests) // // [tx1].0 <- [tx2] // - CTransactionRef tx2 = make_tx(/* output_values */ {495 * CENT, 5 * COIN}, /* inputs */ {tx1}); - pool.addUnchecked(tx2->GetHash(), entry.Fee(10000LL).FromTx(tx2)); + auto tx2 = make_tx(/* output_values */ {495 * CENT, 5 * COIN}, /* inputs */ {tx1}); + pool.addUnchecked(tx2.GetHash(), entry.Fee(10000LL).FromTx(tx2)); // Ancestors / descendants should be: // transaction ancestors descendants // ============ =========== =========== // tx1 1 (tx1) 2 (tx1,2) // tx2 2 (tx1,2) 2 (tx1,2) - pool.GetTransactionAncestry(tx1->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx1.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 1ULL); BOOST_CHECK_EQUAL(descendants, 2ULL); - pool.GetTransactionAncestry(tx2->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx2.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 2ULL); BOOST_CHECK_EQUAL(descendants, 2ULL); @@ -633,8 +633,8 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests) // // [tx1].0 <- [tx2].0 <- [tx3] // - CTransactionRef tx3 = make_tx(/* output_values */ {290 * CENT, 200 * CENT}, /* inputs */ {tx2}); - pool.addUnchecked(tx3->GetHash(), entry.Fee(10000LL).FromTx(tx3)); + auto tx3 = make_tx(/* output_values */ {290 * CENT, 200 * CENT}, /* inputs */ {tx2}); + pool.addUnchecked(tx3.GetHash(), entry.Fee(10000LL).FromTx(tx3)); // Ancestors / descendants should be: // transaction ancestors descendants @@ -642,13 +642,13 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests) // tx1 1 (tx1) 3 (tx1,2,3) // tx2 2 (tx1,2) 3 (tx1,2,3) // tx3 3 (tx1,2,3) 3 (tx1,2,3) - pool.GetTransactionAncestry(tx1->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx1.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 1ULL); BOOST_CHECK_EQUAL(descendants, 3ULL); - pool.GetTransactionAncestry(tx2->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx2.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 2ULL); BOOST_CHECK_EQUAL(descendants, 3ULL); - pool.GetTransactionAncestry(tx3->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx3.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 3ULL); BOOST_CHECK_EQUAL(descendants, 3ULL); @@ -658,8 +658,8 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests) // | // \---1 <- [tx4] // - CTransactionRef tx4 = make_tx(/* output_values */ {290 * CENT, 250 * CENT}, /* inputs */ {tx2}, /* input_indices */ {1}); - pool.addUnchecked(tx4->GetHash(), entry.Fee(10000LL).FromTx(tx4)); + auto tx4 = make_tx(/* output_values */ {290 * CENT, 250 * CENT}, /* inputs */ {tx2}, /* input_indices */ {1}); + pool.addUnchecked(tx4.GetHash(), entry.Fee(10000LL).FromTx(tx4)); // Ancestors / descendants should be: // transaction ancestors descendants @@ -668,16 +668,16 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests) // tx2 2 (tx1,2) 4 (tx1,2,3,4) // tx3 3 (tx1,2,3) 4 (tx1,2,3,4) // tx4 3 (tx1,2,4) 4 (tx1,2,3,4) - pool.GetTransactionAncestry(tx1->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx1.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 1ULL); BOOST_CHECK_EQUAL(descendants, 4ULL); - pool.GetTransactionAncestry(tx2->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx2.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 2ULL); BOOST_CHECK_EQUAL(descendants, 4ULL); - pool.GetTransactionAncestry(tx3->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx3.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 3ULL); BOOST_CHECK_EQUAL(descendants, 4ULL); - pool.GetTransactionAncestry(tx4->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx4.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 3ULL); BOOST_CHECK_EQUAL(descendants, 4ULL); @@ -689,20 +689,20 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests) // | // \---1 <- [tx4] // - CTransactionRef ty1, ty2, ty3, ty4, ty5; - CTransactionRef* ty[5] = {&ty1, &ty2, &ty3, &ty4, &ty5}; + CMutableTransaction ty1, ty2, ty3, ty4, ty5; + CMutableTransaction* ty[5] = {&ty1, &ty2, &ty3, &ty4, &ty5}; CAmount v = 5 * COIN; for (uint64_t i = 0; i < 5; i++) { - CTransactionRef& tyi = *ty[i]; - tyi = make_tx(/* output_values */ {v}, /* inputs */ i > 0 ? std::vector{*ty[i - 1]} : std::vector{}); + auto& tyi = *ty[i]; + tyi = make_tx(/* output_values */ {v}, /* inputs */ i > 0 ? std::vector{*ty[i - 1]} : std::vector{}); v -= 50 * CENT; - pool.addUnchecked(tyi->GetHash(), entry.Fee(10000LL).FromTx(tyi)); - pool.GetTransactionAncestry(tyi->GetHash(), ancestors, descendants); + pool.addUnchecked(tyi.GetHash(), entry.Fee(10000LL).FromTx(tyi)); + pool.GetTransactionAncestry(tyi.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, i+1); BOOST_CHECK_EQUAL(descendants, i+1); } - CTransactionRef ty6 = make_tx(/* output_values */ {5 * COIN}, /* inputs */ {tx3, ty5}); - pool.addUnchecked(ty6->GetHash(), entry.Fee(10000LL).FromTx(ty6)); + auto ty6 = make_tx(/* output_values */ {5 * COIN}, /* inputs */ {tx3, ty5}); + pool.addUnchecked(ty6.GetHash(), entry.Fee(10000LL).FromTx(ty6)); // Ancestors / descendants should be: // transaction ancestors descendants @@ -717,34 +717,34 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests) // ty4 4 (y1234) 6 (ty1,2,3,4,5,6) // ty5 5 (y12345) 6 (ty1,2,3,4,5,6) // ty6 9 (tx123, ty123456) 6 (ty1,2,3,4,5,6) - pool.GetTransactionAncestry(tx1->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx1.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 1ULL); BOOST_CHECK_EQUAL(descendants, 5ULL); - pool.GetTransactionAncestry(tx2->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx2.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 2ULL); BOOST_CHECK_EQUAL(descendants, 5ULL); - pool.GetTransactionAncestry(tx3->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx3.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 3ULL); BOOST_CHECK_EQUAL(descendants, 5ULL); - pool.GetTransactionAncestry(tx4->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(tx4.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 3ULL); BOOST_CHECK_EQUAL(descendants, 5ULL); - pool.GetTransactionAncestry(ty1->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(ty1.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 1ULL); BOOST_CHECK_EQUAL(descendants, 6ULL); - pool.GetTransactionAncestry(ty2->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(ty2.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 2ULL); BOOST_CHECK_EQUAL(descendants, 6ULL); - pool.GetTransactionAncestry(ty3->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(ty3.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 3ULL); BOOST_CHECK_EQUAL(descendants, 6ULL); - pool.GetTransactionAncestry(ty4->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(ty4.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 4ULL); BOOST_CHECK_EQUAL(descendants, 6ULL); - pool.GetTransactionAncestry(ty5->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(ty5.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 5ULL); BOOST_CHECK_EQUAL(descendants, 6ULL); - pool.GetTransactionAncestry(ty6->GetHash(), ancestors, descendants); + pool.GetTransactionAncestry(ty6.GetHash(), ancestors, descendants); BOOST_CHECK_EQUAL(ancestors, 9ULL); BOOST_CHECK_EQUAL(descendants, 6ULL); } diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp index 61e579ed3..44ea5da03 100644 --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -12,7 +12,7 @@ #include