7#include <chainparams.h>
38#include <boost/test/unit_test.hpp>
52 db.WriteBestBlock(batch, locator);
61 std::pair<uint64_t, uint64_t>
salt;
68 std::vector<txindex::BlockTxPosition>
positions;
71 for (it->Seek(key); it->Valid() && it->GetKey(key) && key.hash_prefix ==
prefix; it->Next()) {
87 const auto result{
txindex.FindTx(txid)};
90 return result->block_hash;
106 {{0, 0},
"00000000"},
107 {{1, 2},
"01000002"},
108 {{10'000'000, 123},
"83e1ac0000007b"},
109 {{456, 3'999'999},
"82483d08ff"},
123 "78010203040501000002");
133 Txid{
"1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100"}),
143 for (
const auto& txn : m_coinbase_txns) {
159 for (
const auto& txn : m_coinbase_txns) {
164 for (
int i = 0; i < 10; i++) {
166 std::vector<CMutableTransaction>
no_txns;
335 chainman.ActiveChainstate().ResetBlockFailureFlags(chainman.m_blockman.LookupBlockIndex(
stale_block_hash));
340 BOOST_REQUIRE(chainman.ActiveChainstate().ActivateBestChain(state));
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
int64_t CAmount
Amount in satoshis (Can be negative)
constexpr CAmount COIN
The amount of satoshis in one BTC.
void InvalidateBlock(ChainstateManager &chainman, const uint256 block_hash)
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
fs::path GetDataDirNet() const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Get data directory path with appended network identifier.
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
const CBlock & GenesisBlock() const
Batch of changes queued to be written to a CDBWrapper.
bool Read(const K &key, V &value) const
Wrapper around TryRead() that preserves the original Read() semantics: returns true on success,...
CDBIterator * NewIterator()
void Erase(const K &key, bool fSync=false)
void WriteBatch(CDBBatch &batch, bool fSync=false)
void Write(const K &key, const V &value, bool fSync=false)
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
Interface for managing multiple Chainstate objects, where each chainstate is associated with chainsta...
Chainstate & ActiveChainstate() const
Alternatives to CurrentChainstate() used by older code to query latest chainstate information without...
CChain & ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
Double ended buffer combining vector and stream-like interfaces.
A custom weaker variant of SipHash-1-3 without padding, and supporting "jumbo" inputs.
TxIndex is used to look up transactions included in the blockchain by hash.
static CBlockLocator ReadBestBlock(const TxIndex &txindex)
static CDBWrapper & GetDB(const TxIndex &txindex)
static void WriteBestBlock(const TxIndex &txindex, const CBlockLocator &locator)
CBlockIndex * LookupBlockIndex(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
BOOST_AUTO_TEST_SUITE_END()
std::string HexStr(const std::span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
const std::string DB_TXID_HASH_SALT
constexpr std::array< std::byte, 0 > EMPTY_VALUE
Empty value of a hashed txindex row, whose position is encoded in its key.
TxHashKeyPrefix CreateKeyPrefix(const SipHasher13UJ &hasher, const Txid &txid)
constexpr uint32_t BLOCK_HEADER_SIZE
Serialized size of a block header, the offset of the first byte after it.
std::pair< uint8_t, uint256 > LegacyTxKey(const Txid &txid)
Key of a legacy (pre-hashing) txindex row: the full txid under the 't' prefix.
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::vector< unsigned char > ToByteVector(const T &in)
uint64_t GetSerializeSize(const T &t)
std::vector< Byte > ParseHex(std::string_view hex_str)
Like TryParseHex, but returns an empty vector on invalid input.
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
std::vector< uint256 > vHave
A mutable version of CTransaction.
Application-specific storage settings.
fs::path path
Location in the filesystem where leveldb data will be stored.
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
std::unique_ptr< ChainstateManager > chainman
Key for looking up the hash of the block with the given sequence number.
The location of a transaction: the sequence number of the block that contains it and the transaction'...
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
void StopIndex(BaseIndex &index, node::NodeContext &node)
Drain validation callbacks before stopping an index, matching Shutdown() in init.cpp.
BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
BOOST_AUTO_TEST_CASE(txindex_position_encoding)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.