diff --git a/src/test/test_bitcoin.h b/src/test/test_bitcoin.h --- a/src/test/test_bitcoin.h +++ b/src/test/test_bitcoin.h @@ -62,7 +62,8 @@ ~BasicTestingSetup(); }; -/** Testing setup that configures a complete environment. +/** + * Testing setup that configures a complete environment. * Included are data directory, coins database, script check threads setup. */ class CConnman; @@ -104,7 +105,7 @@ ~TestChain100Setup(); // For convenience, coinbase transactions. - std::vector m_coinbase_txns; + std::vector m_coinbase_txns; // private/public key needed to spend coinbase transactions. CKey coinbaseKey; }; diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -155,7 +155,7 @@ for (int i = 0; i < COINBASE_MATURITY; i++) { std::vector noTxns; CBlock b = CreateAndProcessBlock(noTxns, scriptPubKey); - m_coinbase_txns.push_back(*b.vtx[0]); + m_coinbase_txns.push_back(b.vtx[0]); } } diff --git a/src/test/txindex_tests.cpp b/src/test/txindex_tests.cpp --- a/src/test/txindex_tests.cpp +++ b/src/test/txindex_tests.cpp @@ -21,7 +21,7 @@ // Transaction should not be found in the index before it is started. for (const auto &txn : m_coinbase_txns) { - BOOST_CHECK(!txindex.FindTx(txn.GetHash(), block_hash, tx_disk)); + BOOST_CHECK(!txindex.FindTx(txn->GetId(), block_hash, tx_disk)); } // BlockUntilSyncedToCurrentChain should return false before txindex is @@ -40,9 +40,9 @@ // Check that txindex has all txs that were in the chain before it started. for (const auto &txn : m_coinbase_txns) { - if (!txindex.FindTx(txn.GetHash(), block_hash, tx_disk)) { + if (!txindex.FindTx(txn->GetId(), block_hash, tx_disk)) { BOOST_ERROR("FindTx failed"); - } else if (tx_disk->GetHash() != txn.GetHash()) { + } else if (tx_disk->GetId() != txn->GetId()) { BOOST_ERROR("Read incorrect tx"); } } @@ -54,12 +54,12 @@ std::vector no_txns; const CBlock &block = CreateAndProcessBlock(no_txns, coinbase_script_pub_key); - const CTransaction &txn = *block.vtx[0]; + const CTransactionRef &txn = block.vtx[0]; BOOST_CHECK(txindex.BlockUntilSyncedToCurrentChain()); - if (!txindex.FindTx(txn.GetHash(), block_hash, tx_disk)) { + if (!txindex.FindTx(txn->GetId(), block_hash, tx_disk)) { BOOST_ERROR("FindTx failed"); - } else if (tx_disk->GetHash() != txn.GetHash()) { + } else if (tx_disk->GetId() != txn->GetId()) { BOOST_ERROR("Read incorrect tx"); } } diff --git a/src/test/txvalidationcache_tests.cpp b/src/test/txvalidationcache_tests.cpp --- a/src/test/txvalidationcache_tests.cpp +++ b/src/test/txvalidationcache_tests.cpp @@ -47,7 +47,7 @@ for (int i = 0; i < 2; i++) { spends[i].nVersion = 1; spends[i].vin.resize(1); - spends[i].vin[0].prevout = COutPoint(m_coinbase_txns[0].GetId(), 0); + spends[i].vin[0].prevout = COutPoint(m_coinbase_txns[0]->GetId(), 0); spends[i].vout.resize(1); spends[i].vout[0].nValue = 11 * CENT; spends[i].vout[0].scriptPubKey = scriptPubKey; @@ -56,7 +56,7 @@ std::vector vchSig; uint256 hash = SignatureHash(scriptPubKey, CTransaction(spends[i]), 0, SigHashType().withForkId(), - m_coinbase_txns[0].vout[0].nValue); + m_coinbase_txns[0]->vout[0].nValue); BOOST_CHECK(coinbaseKey.SignECDSA(hash, vchSig)); vchSig.push_back(uint8_t(SIGHASH_ALL | SIGHASH_FORKID)); spends[i].vin[0].scriptSig << vchSig; @@ -178,7 +178,7 @@ mutableFunding_tx.nVersion = 1; mutableFunding_tx.vin.resize(1); mutableFunding_tx.vin[0].prevout = - COutPoint(m_coinbase_txns[0].GetId(), 0); + COutPoint(m_coinbase_txns[0]->GetId(), 0); mutableFunding_tx.vout.resize(1); mutableFunding_tx.vout[0].nValue = 50 * COIN; @@ -191,7 +191,7 @@ std::vector nullDummyVchSig; uint256 nulldummySigHash = SignatureHash( p2pk_scriptPubKey, CTransaction(mutableFunding_tx), 0, - SigHashType().withForkId(), m_coinbase_txns[0].vout[0].nValue); + SigHashType().withForkId(), m_coinbase_txns[0]->vout[0].nValue); BOOST_CHECK(coinbaseKey.SignECDSA(nulldummySigHash, nullDummyVchSig)); nullDummyVchSig.push_back(uint8_t(SIGHASH_ALL | SIGHASH_FORKID)); mutableFunding_tx.vin[0].scriptSig << nullDummyVchSig; diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -127,22 +127,22 @@ const int64_t BLOCK_TIME = chainActive.Tip()->GetBlockTimeMax() + 5; SetMockTime(BLOCK_TIME); m_coinbase_txns.emplace_back( - *CreateAndProcessBlock({}, - GetScriptForRawPubKey(coinbaseKey.GetPubKey())) - .vtx[0]); + CreateAndProcessBlock({}, + GetScriptForRawPubKey(coinbaseKey.GetPubKey())) + .vtx[0]); m_coinbase_txns.emplace_back( - *CreateAndProcessBlock({}, - GetScriptForRawPubKey(coinbaseKey.GetPubKey())) - .vtx[0]); + CreateAndProcessBlock({}, + GetScriptForRawPubKey(coinbaseKey.GetPubKey())) + .vtx[0]); // Set key birthday to block time increased by the timestamp window, so // rescan will start at the block time. const int64_t KEY_TIME = BLOCK_TIME + TIMESTAMP_WINDOW; SetMockTime(KEY_TIME); m_coinbase_txns.emplace_back( - *CreateAndProcessBlock({}, - GetScriptForRawPubKey(coinbaseKey.GetPubKey())) - .vtx[0]); + CreateAndProcessBlock({}, + GetScriptForRawPubKey(coinbaseKey.GetPubKey())) + .vtx[0]); LOCK(cs_main); @@ -176,7 +176,7 @@ BOOST_CHECK_EQUAL(wallet.mapWallet.size(), 3); BOOST_CHECK_EQUAL(m_coinbase_txns.size(), 103); for (size_t i = 0; i < m_coinbase_txns.size(); ++i) { - bool found = wallet.GetWalletTx(m_coinbase_txns[i].GetId()); + bool found = wallet.GetWalletTx(m_coinbase_txns[i]->GetId()); bool expected = i >= 100; BOOST_CHECK_EQUAL(found, expected); } @@ -194,7 +194,7 @@ // debit functions. BOOST_FIXTURE_TEST_CASE(coin_mark_dirty_immature_credit, TestChain100Setup) { CWallet wallet(Params(), "dummy", CWalletDBWrapper::CreateDummy()); - CWalletTx wtx(&wallet, MakeTransactionRef(m_coinbase_txns.back())); + CWalletTx wtx(&wallet, m_coinbase_txns.back()); LOCK2(cs_main, wallet.cs_wallet); wtx.hashBlock = chainActive.Tip()->GetBlockHash(); wtx.nIndex = 0;