6 #include <chainparams.h> 10 #include <validation.h> 12 #include <boost/test/unit_test.hpp> 14 BOOST_AUTO_TEST_SUITE(txindex_tests)
19 BOOST_REQUIRE(txindex.
Init());
25 for (
const auto& txn : m_coinbase_txns) {
30 BOOST_CHECK(!txindex.BlockUntilSyncedToCurrentChain());
36 for (
const auto& txn : genesis_block.
vtx) {
41 for (
const auto& txn : m_coinbase_txns) {
42 if (!txindex.
FindTx(txn->GetHash(), block_hash, tx_disk)) {
43 BOOST_ERROR(
"FindTx failed");
44 }
else if (tx_disk->GetHash() != txn->GetHash()) {
45 BOOST_ERROR(
"Read incorrect tx");
50 for (
int i = 0; i < 10; i++) {
52 std::vector<CMutableTransaction> no_txns;
53 const CBlock& block = CreateAndProcessBlock(no_txns, coinbase_script_pub_key);
56 BOOST_CHECK(txindex.BlockUntilSyncedToCurrentChain());
58 BOOST_ERROR(
"FindTx failed");
59 }
else if (tx_disk->GetHash() != txn.
GetHash()) {
60 BOOST_ERROR(
"Read incorrect tx");
std::shared_ptr< const CTransaction > CTransactionRef
bool Init()
Initializes the sync state and registers the instance to the validation interface so that it stays in...
const CBlock & GenesisBlock() const
BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
void Stop()
Stops the instance from staying in sync with blockchain updates.
BOOST_AUTO_TEST_SUITE_END()
void Sync()
Sync the index with the block index starting from the current best block.
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::vector< CTransactionRef > vtx
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
bool FindTx(const Txid &tx_hash, uint256 &block_hash, CTransactionRef &tx) const
Look up a transaction by hash.
const CChainParams & Params()
Return the currently selected parameters.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks. ...
TxIndex is used to look up transactions included in the blockchain by hash.
const Txid & GetHash() const LIFETIMEBOUND
#define BOOST_CHECK(expr)