LCOV - code coverage report
Current view: top level - src/test/util - txmempool.h (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 0 8 0.0 %
Date: 2023-11-10 23:46:46 Functions: 0 2 0.0 %
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                 :          0 : struct TestMemPoolEntryHelper {
      20                 :            :     // Default values
      21                 :          0 :     CAmount nFee{0};
      22                 :          0 :     NodeSeconds time{};
      23                 :          0 :     unsigned int nHeight{1};
      24                 :          0 :     uint64_t m_sequence{0};
      25                 :          0 :     bool spendsCoinbase{false};
      26                 :          0 :     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                 :          0 :     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                 :            : #endif // BITCOIN_TEST_UTIL_TXMEMPOOL_H

Generated by: LCOV version 1.14