6#include <chainparams.h>
11#include <validation.h>
13#include <boost/test/unit_test.hpp>
15BOOST_AUTO_TEST_SUITE(txindex_tests)
20 BOOST_REQUIRE(txindex.
Init());
26 for (
const auto& txn : m_coinbase_txns) {
31 BOOST_CHECK(!txindex.BlockUntilSyncedToCurrentChain());
40 for (
const auto& txn : genesis_block.
vtx) {
45 for (
const auto& txn : m_coinbase_txns) {
46 if (!txindex.
FindTx(txn->GetHash(), block_hash, tx_disk)) {
47 BOOST_ERROR(
"FindTx failed");
48 }
else if (tx_disk->GetHash() != txn->GetHash()) {
49 BOOST_ERROR(
"Read incorrect tx");
54 for (
int i = 0; i < 10; i++) {
56 std::vector<CMutableTransaction> no_txns;
57 const CBlock& block = CreateAndProcessBlock(no_txns, coinbase_script_pub_key);
60 BOOST_CHECK(txindex.BlockUntilSyncedToCurrentChain());
62 BOOST_ERROR(
"FindTx failed");
63 }
else if (tx_disk->GetHash() != txn.
GetHash()) {
64 BOOST_ERROR(
"Read incorrect tx");
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
void Stop()
Stops the instance from staying in sync with blockchain updates.
bool Init()
Initializes the sync state and registers the instance to the validation interface so that it stays in...
bool StartBackgroundSync()
Starts the initial sync process on a background thread.
std::vector< CTransactionRef > vtx
const CBlock & GenesisBlock() const
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
const Txid & GetHash() const LIFETIMEBOUND
TxIndex is used to look up transactions included in the blockchain by hash.
bool FindTx(const uint256 &tx_hash, uint256 &block_hash, CTransactionRef &tx) const
Look up a transaction by hash.
BOOST_AUTO_TEST_SUITE_END()
void IndexWaitSynced(const BaseIndex &index, const util::SignalInterrupt &interrupt)
Block until the index is synced to the current chain.
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
#define BOOST_CHECK(expr)
std::shared_ptr< const CTransaction > CTransactionRef
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
std::unique_ptr< ValidationSignals > validation_signals
Issues calls about blocks and transactions.
util::SignalInterrupt * shutdown_signal
Interrupt object used to track whether node shutdown was requested.
BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)