11 #include <validation.h>
13 #include <boost/test/unit_test.hpp>
25 for (
const auto& txn : m_coinbase_txns) {
30 BOOST_CHECK(!txindex.BlockUntilSyncedToCurrentChain());
32 BOOST_REQUIRE(txindex.
Start());
35 constexpr int64_t timeout_ms = 10 * 1000;
37 while (!txindex.BlockUntilSyncedToCurrentChain()) {
44 for (
const auto& txn : genesis_block.
vtx) {
49 for (
const auto& txn : m_coinbase_txns) {
50 if (!txindex.
FindTx(txn->GetHash(), block_hash, tx_disk)) {
51 BOOST_ERROR(
"FindTx failed");
52 }
else if (tx_disk->GetHash() != txn->GetHash()) {
53 BOOST_ERROR(
"Read incorrect tx");
58 for (
int i = 0; i < 10; i++) {
60 std::vector<CMutableTransaction> no_txns;
61 const CBlock& block = CreateAndProcessBlock(no_txns, coinbase_script_pub_key);
64 BOOST_CHECK(txindex.BlockUntilSyncedToCurrentChain());
66 BOOST_ERROR(
"FindTx failed");
67 }
else if (tx_disk->GetHash() != txn.
GetHash()) {
68 BOOST_ERROR(
"Read incorrect tx");
const CChainParams & Params()
Return the currently selected parameters.
void Stop()
Stops the instance from staying in sync with blockchain updates.
bool Start()
Start initializes the sync state and registers the instance as a ValidationInterface so that it stays...
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 uint256 & GetHash() const
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(cuckoocache_tests)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
#define BOOST_CHECK(expr)
std::shared_ptr< const CTransaction > CTransactionRef
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
int64_t GetTimeMillis()
Returns the system time (not mockable)
void UninterruptibleSleep(const std::chrono::microseconds &n)
BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
void SyncWithValidationInterfaceQueue()
This is a synonym for the following, which asserts certain locks are not held: std::promise<void> pro...