Reorg includes

Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
Anthony Fieroni 2019-12-11 20:36:52 +02:00 committed by Brannon King
parent b074ed0d79
commit 8a35d5a15e
22 changed files with 87 additions and 72 deletions

View file

@ -25,6 +25,7 @@
#include <timedata.h>
#include <util.h>
#include <utilmoneystr.h>
#include <validation.h>
#include <validationinterface.h>
#include <algorithm>

View file

@ -8,7 +8,6 @@
#include <primitives/block.h>
#include <txmempool.h>
#include <validation.h>
#include <stdint.h>
#include <memory>

View file

@ -4,6 +4,7 @@
#include <rpc/blockchain.h>
#include <test/test_bitcoin.h>
#include <txdb.h>
/* Equality between doubles is imprecise. Comparison should be done
* with a small threshold of tolerance, rather than exact equality.

View file

@ -8,6 +8,7 @@
#include <pow.h>
#include <random.h>
#include <streams.h>
#include <txmempool.h>
#include <test/test_bitcoin.h>
@ -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;

View file

@ -3,6 +3,7 @@
// file COPYING or http://opensource.org/licenses/mit-license.php
#include <test/claimtriefixture.h>
#include <validation.h>
using namespace std;

View file

@ -1,5 +1,4 @@
#include <claimtrie/forks.h>
#include <nameclaim.h>
#include <uint256.h>
#include <validation.h>

View file

@ -3,6 +3,7 @@
// file COPYING or http://opensource.org/licenses/mit-license.php
#include <test/claimtriefixture.h>
#include <validation.h>
using namespace std;

View file

@ -3,7 +3,10 @@
// file COPYING or http://opensource.org/licenses/mit-license.php
#include <functional>
#include <miner.h>
#include <primitives/transaction.h>
#include <test/claimtriefixture.h>
#include <validation.h>
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++);
}

View file

@ -10,33 +10,30 @@
#include <coins.h>
#include <consensus/merkle.h>
#include <consensus/validation.h>
#include <miner.h>
#include <nameclaim.h>
#include <policy/policy.h>
#include <pow.h>
#include <primitives/transaction.h>
#include <random.h>
#include <rpc/claimrpchelp.h>
#include <rpc/server.h>
#include <streams.h>
#include <test/test_bitcoin.h>
#include <txmempool.h>
#include <util.h>
#include <validation.h>
#include <boost/test/unit_test.hpp>
#include <iostream>
extern ::CChainState g_chainstate;
extern ::ArgsManager gArgs;
extern std::vector<std::string> 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);

View file

@ -2,7 +2,9 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://opensource.org/licenses/mit-license.php
#include <miner.h>
#include <test/claimtriefixture.h>
#include <validation.h>
using namespace std;

View file

@ -3,6 +3,9 @@
// file COPYING or http://opensource.org/licenses/mit-license.php
#include <test/claimtriefixture.h>
#include <validation.h>
extern ::CChainState g_chainstate;
using namespace std;

View file

@ -4,6 +4,7 @@
#include <test/claimtriefixture.h>
#include <utilstrencodings.h>
#include <validation.h>
using namespace std;

View file

@ -4,6 +4,7 @@
#include <clientversion.h>
#include <hash.h>
#include <primitives/transaction.h>
#include <utilstrencodings.h>
#include <test/test_bitcoin.h>

View file

@ -573,20 +573,20 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
SetMockTime(0);
}
inline CTransactionRef make_tx(std::vector<CAmount>&& output_values, std::vector<CTransactionRef>&& inputs=std::vector<CTransactionRef>(), std::vector<uint32_t>&& input_indices=std::vector<uint32_t>())
inline CMutableTransaction make_tx(std::vector<CAmount>&& output_values, std::vector<CMutableTransaction>&& inputs=std::vector<CMutableTransaction>(), std::vector<uint32_t>&& input_indices=std::vector<uint32_t>())
{
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<CTransactionRef>{*ty[i - 1]} : std::vector<CTransactionRef>{});
auto& tyi = *ty[i];
tyi = make_tx(/* output_values */ {v}, /* inputs */ i > 0 ? std::vector<CMutableTransaction>{*ty[i - 1]} : std::vector<CMutableTransaction>{});
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);
}

View file

@ -12,7 +12,7 @@
#include <script/ismine.h>
#include <uint256.h>
#include <test/test_bitcoin.h>
#include <tinyformat.h>
#include <boost/test/unit_test.hpp>

View file

@ -6,6 +6,7 @@
#include <streams.h>
#include <hash.h>
#include <utilstrencodings.h>
#include <primitives/transaction.h>
#include <test/test_bitcoin.h>

View file

@ -2,6 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <coins.h>
#include <consensus/tx_verify.h>
#include <consensus/validation.h>
#include <pubkey.h>

View file

@ -19,6 +19,7 @@
#include <rpc/server.h>
#include <rpc/register.h>
#include <script/sigcache.h>
#include <txdb.h>
#include <boost/test/unit_test.hpp>
#include <boost/test/unit_test_parameters.hpp>
@ -205,7 +206,7 @@ TestChain100Setup::TestChain100Setup() : TestingSetup(CBaseChainParams::REGTEST)
{
std::vector<CMutableTransaction> noTxns;
CBlock b = CreateAndProcessBlock(noTxns, scriptPubKey);
m_coinbase_txns.push_back(b.vtx[0]);
m_coinbase_txns.emplace_back(*b.vtx[0]);
}
}
@ -258,14 +259,15 @@ RegTestingSetup::~RegTestingSetup()
minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
}
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction &tx) {
return FromTx(MakeTransactionRef(tx));
CTxMemPoolEntry FromTx(CTransactionRef tx, const TestMemPoolEntryHelper& entry)
{
return CTxMemPoolEntry(tx, entry.nFee, entry.nTime, entry.nHeight,
entry.spendsCoinbase, entry.sigOpCost, LockPoints{});
}
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CTransactionRef& tx)
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction &tx)
{
return CTxMemPoolEntry(tx, nFee, nTime, nHeight,
spendsCoinbase, sigOpCost, lp);
return ::FromTx(MakeTransactionRef(tx), *this);
}
/**

View file

@ -5,14 +5,13 @@
#ifndef BITCOIN_TEST_TEST_BITCOIN_H
#define BITCOIN_TEST_TEST_BITCOIN_H
#include <amount.h>
#include <chainparamsbase.h>
#include <fs.h>
#include <key.h>
#include <pubkey.h>
#include <random.h>
#include <scheduler.h>
#include <txdb.h>
#include <txmempool.h>
#include <memory>
@ -91,7 +90,7 @@ struct TestChain100Setup : public TestingSetup {
~TestChain100Setup() override;
std::vector<CTransactionRef> m_coinbase_txns; // For convenience, coinbase transactions
std::vector<CMutableTransaction> m_coinbase_txns; // For convenience, coinbase transactions
CKey coinbaseKey; // private/public key needed to spend coinbase transactions
};
@ -110,14 +109,12 @@ struct TestMemPoolEntryHelper
unsigned int nHeight;
bool spendsCoinbase;
unsigned int sigOpCost;
LockPoints lp;
TestMemPoolEntryHelper() :
nFee(0), nTime(0), nHeight(1),
spendsCoinbase(false), sigOpCost(4) { }
CTxMemPoolEntry FromTx(const CMutableTransaction& tx);
CTxMemPoolEntry FromTx(const CTransactionRef& tx);
// Change the default value
TestMemPoolEntryHelper &Fee(CAmount _fee) { nFee = _fee; return *this; }
@ -130,8 +127,11 @@ struct TestMemPoolEntryHelper
CBlock getTestBlock();
// define an implicit conversion here so that uint256 may be used directly in BOOST_CHECK_*
std::ostream& operator<<(std::ostream& os, const uint256& num);
std::ostream& operator<<(std::ostream& os, const uint160& num);
class COutPoint;
std::ostream& operator<<(std::ostream& os, const COutPoint& point);
std::ostream& operator<<(std::ostream& os, const CUint256& num);

View file

@ -48,7 +48,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
{
spends[i].nVersion = 1;
spends[i].vin.resize(1);
spends[i].vin[0].prevout.hash = m_coinbase_txns[0]->GetHash();
spends[i].vin[0].prevout.hash = m_coinbase_txns[0].GetHash();
spends[i].vin[0].prevout.n = 0;
spends[i].vout.resize(1);
spends[i].vout[0].nValue = 11*CENT;
@ -167,7 +167,7 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
spend_tx.nVersion = 1;
spend_tx.vin.resize(1);
spend_tx.vin[0].prevout.hash = m_coinbase_txns[0]->GetHash();
spend_tx.vin[0].prevout.hash = m_coinbase_txns[0].GetHash();
spend_tx.vin[0].prevout.n = 0;
spend_tx.vout.resize(4);
spend_tx.vout[0].nValue = 11*CENT;

View file

@ -7,7 +7,6 @@
#define BITCOIN_UNDO_H
#include <compressor.h>
#include <claimtrie/forks.h>
#include <primitives/transaction.h>
#include <serialize.h>

View file

@ -120,14 +120,14 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
// will pick up both blocks, not just the first.
const int64_t BLOCK_TIME = chainActive.Tip()->GetBlockTimeMax() + 5;
SetMockTime(BLOCK_TIME);
m_coinbase_txns.emplace_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
m_coinbase_txns.emplace_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
m_coinbase_txns.emplace_back(*CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
m_coinbase_txns.emplace_back(*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]);
m_coinbase_txns.emplace_back(*CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
LOCK(cs_main);
@ -164,7 +164,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
BOOST_CHECK_EQUAL(wallet->mapWallet.size(), 3U);
BOOST_CHECK_EQUAL(m_coinbase_txns.size(), 103U);
for (size_t i = 0; i < m_coinbase_txns.size(); ++i) {
bool found = wallet->GetWalletTx(m_coinbase_txns[i]->GetHash());
bool found = wallet->GetWalletTx(m_coinbase_txns[i].GetHash());
bool expected = i >= 100;
BOOST_CHECK_EQUAL(found, expected);
}
@ -182,7 +182,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
BOOST_FIXTURE_TEST_CASE(coin_mark_dirty_immature_credit, TestChain100Setup)
{
CWallet wallet(WalletLocation(), WalletDatabase::CreateDummy());
CWalletTx wtx(&wallet, m_coinbase_txns.back());
CWalletTx wtx(&wallet, MakeTransactionRef(m_coinbase_txns.back()));
LOCK2(cs_main, wallet.cs_wallet);
wtx.hashBlock = chainActive.Tip()->GetBlockHash();
wtx.nIndex = 0;