LCOV - code coverage report
Current view: top level - src/test/util - txmempool.h (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 8 8
Test Date: 2024-09-01 05:20:30 Functions: 100.0 % 2 2
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2022 The Bitcoin Core developers
       2                 :             : // Distributed under the MIT software license, see the accompanying
       3                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4                 :             : 
       5                 :             : #ifndef BITCOIN_TEST_UTIL_TXMEMPOOL_H
       6                 :             : #define BITCOIN_TEST_UTIL_TXMEMPOOL_H
       7                 :             : 
       8                 :             : #include <policy/packages.h>
       9                 :             : #include <txmempool.h>
      10                 :             : #include <util/time.h>
      11                 :             : 
      12                 :             : namespace node {
      13                 :             : struct NodeContext;
      14                 :             : }
      15                 :             : struct PackageMempoolAcceptResult;
      16                 :             : 
      17                 :             : CTxMemPool::Options MemPoolOptionsForTest(const node::NodeContext& node);
      18                 :             : 
      19                 :      213367 : struct TestMemPoolEntryHelper {
      20                 :             :     // Default values
      21                 :      213367 :     CAmount nFee{0};
      22                 :      213367 :     NodeSeconds time{};
      23                 :      213367 :     unsigned int nHeight{1};
      24                 :      213367 :     uint64_t m_sequence{0};
      25                 :      213367 :     bool spendsCoinbase{false};
      26                 :      213367 :     unsigned int sigOpCost{4};
      27                 :             :     LockPoints lp;
      28                 :             : 
      29                 :             :     CTxMemPoolEntry FromTx(const CMutableTransaction& tx) const;
      30                 :             :     CTxMemPoolEntry FromTx(const CTransactionRef& tx) const;
      31                 :             : 
      32                 :             :     // Change the default value
      33                 :      213367 :     TestMemPoolEntryHelper& Fee(CAmount _fee) { nFee = _fee; return *this; }
      34                 :             :     TestMemPoolEntryHelper& Time(NodeSeconds tp) { time = tp; return *this; }
      35                 :             :     TestMemPoolEntryHelper& Height(unsigned int _height) { nHeight = _height; return *this; }
      36                 :             :     TestMemPoolEntryHelper& Sequence(uint64_t _seq) { m_sequence = _seq; return *this; }
      37                 :             :     TestMemPoolEntryHelper& SpendsCoinbase(bool _flag) { spendsCoinbase = _flag; return *this; }
      38                 :             :     TestMemPoolEntryHelper& SigOpsCost(unsigned int _sigopsCost) { sigOpCost = _sigopsCost; return *this; }
      39                 :             : };
      40                 :             : 
      41                 :             : /** Check expected properties for every PackageMempoolAcceptResult, regardless of value. Returns
      42                 :             :  * a string if an error occurs with error populated, nullopt otherwise. If mempool is provided,
      43                 :             :  * checks that the expected transactions are in mempool (this should be set to nullptr for a test_accept).
      44                 :             : */
      45                 :             : std::optional<std::string>  CheckPackageMempoolAcceptResult(const Package& txns,
      46                 :             :                                                             const PackageMempoolAcceptResult& result,
      47                 :             :                                                             bool expect_valid,
      48                 :             :                                                             const CTxMemPool* mempool);
      49                 :             : 
      50                 :             : /** For every transaction in tx_pool, check TRUC invariants:
      51                 :             :  * - a TRUC tx's ancestor count must be within TRUC_ANCESTOR_LIMIT
      52                 :             :  * - a TRUC tx's descendant count must be within TRUC_DESCENDANT_LIMIT
      53                 :             :  * - if a TRUC tx has ancestors, its sigop-adjusted vsize must be within TRUC_CHILD_MAX_VSIZE
      54                 :             :  * - any non-TRUC tx must only have non-TRUC parents
      55                 :             :  * - any TRUC tx must only have TRUC parents
      56                 :             :  *   */
      57                 :             : void CheckMempoolTRUCInvariants(const CTxMemPool& tx_pool);
      58                 :             : 
      59                 :             : #endif // BITCOIN_TEST_UTIL_TXMEMPOOL_H
        

Generated by: LCOV version 2.0-1