12#include <boost/test/unit_test.hpp>
26 tx.
vin.resize(inputs.size());
28 for (
size_t i = 0; i < inputs.size(); ++i) {
29 tx.
vin[i].prevout = inputs[i];
40static inline bool sanity_check(
const std::vector<CTransactionRef>& transactions,
41 const std::map<COutPoint, CAmount>&
bumpfees)
45 if (
fee < 0)
return false;
46 if (
fee == 0)
continue;
48 const bool found = std::any_of(transactions.cbegin(), transactions.cend(), [&](
const auto& tx) {
49 return outpoint_.hash == tx->GetHash() && outpoint_.n < tx->vout.size();
51 if (!found)
return false;
53 for (
const auto& tx : transactions) {
55 if (tx->vout.size() > 1) {
57 for (
size_t i{0}; i < tx->vout.size(); ++i) {
67template <
typename Key,
typename Value>
68Value
Find(
const std::map<Key, Value>&
map,
const Key& key)
70 auto it =
map.find(key);
180 std::map<Txid, TxDimensions>
tx_dims;
184 CFeeRate(entry.GetModifiedFee(), entry.GetTxSize())});
568 descendant_caches.emplace(
tx4->GetHash(), std::set<Txid>{tx4->GetHash(), tx5->GetHash(), tx6->GetHash(), tx7->GetHash()});
569 descendant_caches.emplace(
tx5->GetHash(), std::set<Txid>{tx5->GetHash(), tx6->GetHash(), tx7->GetHash()});
604 auto&
lasttx = m_coinbase_txns[0];
606 for (
int cluster_count=0; cluster_count < 10; ++cluster_count) {
608 lasttx = m_coinbase_txns[cluster_count];
609 for (
auto i{0}; i < 50; ++i) {
636 for (
auto p{0};
p < 32; ++
p) {
641 for (
auto c{0};
c < 31; ++
c) {
649 for (
const auto index :
indices) {
int64_t CAmount
Amount in satoshis (Can be negative)
static constexpr CAmount COIN
The amount of satoshis in one BTC.
TryAddToMempool(pool, CTxMemPoolEntry(tx, fee, 0, 1, 0, false, 4, lp))
#define Assert(val)
Identity function.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
An outpoint - a combination of a transaction hash and an index n into its vout.
Serialized script, used inside transaction inputs and outputs.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
void PrioritiseTransaction(const Txid &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
std::vector< txiter > GetIterVec(const std::vector< Txid > &txids) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Translate a list of hashes into a list of mempool iterators to avoid repeated lookups.
std::set< txiter, CompareIteratorByHash > setEntries
std::vector< txiter > GatherClusters(const std::vector< Txid > &txids) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Collect the entire cluster of connected transactions for each transaction in txids.
const CTransaction * GetConflictTx(const COutPoint &prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Get the transaction in the pool that spends the same prevout.
std::tuple< size_t, size_t, CAmount > CalculateAncestorData(const CTxMemPoolEntry &entry) const EXCLUSIVE_LOCKS_REQUIRED(cs)
bool isSpent(const COutPoint &outpoint) const
const CTxMemPoolEntry * GetEntry(const Txid &txid) const LIFETIMEBOUND EXCLUSIVE_LOCKS_REQUIRED(cs)
A minimal version of BlockAssembler, using the same ancestor set scoring algorithm.
static transaction_identifier FromUint256(const uint256 &id)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
BOOST_FIXTURE_TEST_CASE(miniminer_negative, TestChain100Setup)
static bool sanity_check(const std::vector< CTransactionRef > &transactions, const std::map< COutPoint, CAmount > &bumpfees)
static CTransactionRef make_tx(const std::vector< COutPoint > &inputs, size_t num_outputs)
Value Find(const std::map< Key, Value > &map, const Key &key)
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
uint256 GetRandHash() noexcept
Generate a random uint256.
static constexpr CAmount CENT
A mutable version of CTransaction.
std::vector< CTxOut > vout
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
TestMemPoolEntryHelper & Fee(CAmount _fee)
Testing setup that configures a complete environment.
std::unique_ptr< CTxMemPool > mempool
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.