mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-24 12:41:41 -05:00

-BEGIN VERIFY SCRIPT- sed -i 's/SingleV3Checks/SingleTRUCChecks/g' $(git grep -l 'SingleV3Checks') sed -i 's/PackageV3Checks/PackageTRUCChecks/g' $(git grep -l 'PackageV3Checks') sed -i 's/PV3C/PTRUCC/g' src/policy/truc_policy.h sed -i 's/V3_MAX_VSIZE/TRUC_MAX_VSIZE/g' $(git grep -l 'V3_MAX_VSIZE') sed -i 's/V3_CHILD_MAX_VSIZE/TRUC_CHILD_MAX_VSIZE/g' $(git grep -l 'V3_CHILD_MAX_VSIZE') sed -i 's/V3_DESCENDANT_LIMIT/TRUC_DESCENDANT_LIMIT/g' $(git grep -l 'V3_DESCENDANT_LIMIT') sed -i 's/V3_ANCESTOR_LIMIT/TRUC_ANCESTOR_LIMIT/g' $(git grep -l 'V3_ANCESTOR_LIMIT') sed -i 's/CheckMempoolV3Invariants/CheckMempoolTRUCInvariants/g' $(git grep -l 'CheckMempoolV3Invariants') -END VERIFY SCRIPT-
59 lines
2.5 KiB
C++
59 lines
2.5 KiB
C++
// Copyright (c) 2022 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_TEST_UTIL_TXMEMPOOL_H
|
|
#define BITCOIN_TEST_UTIL_TXMEMPOOL_H
|
|
|
|
#include <policy/packages.h>
|
|
#include <txmempool.h>
|
|
#include <util/time.h>
|
|
|
|
namespace node {
|
|
struct NodeContext;
|
|
}
|
|
struct PackageMempoolAcceptResult;
|
|
|
|
CTxMemPool::Options MemPoolOptionsForTest(const node::NodeContext& node);
|
|
|
|
struct TestMemPoolEntryHelper {
|
|
// Default values
|
|
CAmount nFee{0};
|
|
NodeSeconds time{};
|
|
unsigned int nHeight{1};
|
|
uint64_t m_sequence{0};
|
|
bool spendsCoinbase{false};
|
|
unsigned int sigOpCost{4};
|
|
LockPoints lp;
|
|
|
|
CTxMemPoolEntry FromTx(const CMutableTransaction& tx) const;
|
|
CTxMemPoolEntry FromTx(const CTransactionRef& tx) const;
|
|
|
|
// Change the default value
|
|
TestMemPoolEntryHelper& Fee(CAmount _fee) { nFee = _fee; return *this; }
|
|
TestMemPoolEntryHelper& Time(NodeSeconds tp) { time = tp; return *this; }
|
|
TestMemPoolEntryHelper& Height(unsigned int _height) { nHeight = _height; return *this; }
|
|
TestMemPoolEntryHelper& Sequence(uint64_t _seq) { m_sequence = _seq; return *this; }
|
|
TestMemPoolEntryHelper& SpendsCoinbase(bool _flag) { spendsCoinbase = _flag; return *this; }
|
|
TestMemPoolEntryHelper& SigOpsCost(unsigned int _sigopsCost) { sigOpCost = _sigopsCost; return *this; }
|
|
};
|
|
|
|
/** Check expected properties for every PackageMempoolAcceptResult, regardless of value. Returns
|
|
* a string if an error occurs with error populated, nullopt otherwise. If mempool is provided,
|
|
* checks that the expected transactions are in mempool (this should be set to nullptr for a test_accept).
|
|
*/
|
|
std::optional<std::string> CheckPackageMempoolAcceptResult(const Package& txns,
|
|
const PackageMempoolAcceptResult& result,
|
|
bool expect_valid,
|
|
const CTxMemPool* mempool);
|
|
|
|
/** For every transaction in tx_pool, check TRUC invariants:
|
|
* - a TRUC tx's ancestor count must be within TRUC_ANCESTOR_LIMIT
|
|
* - a TRUC tx's descendant count must be within TRUC_DESCENDANT_LIMIT
|
|
* - if a TRUC tx has ancestors, its sigop-adjusted vsize must be within TRUC_CHILD_MAX_VSIZE
|
|
* - any non-TRUC tx must only have non-TRUC parents
|
|
* - any TRUC tx must only have TRUC parents
|
|
* */
|
|
void CheckMempoolTRUCInvariants(const CTxMemPool& tx_pool);
|
|
|
|
#endif // BITCOIN_TEST_UTIL_TXMEMPOOL_H
|