LCOV - code coverage report
Current view: top level - src/test/util - validation.cpp (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 27.3 % 44 12
Test Date: 2025-12-19 04:44:33 Functions: 33.3 % 9 3
Branches: 37.5 % 8 3

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2020-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                 :             : #include <test/util/validation.h>
       6                 :             : 
       7                 :             : #include <node/blockstorage.h>
       8                 :             : #include <util/check.h>
       9                 :             : #include <util/time.h>
      10                 :             : #include <validation.h>
      11                 :             : #include <validationinterface.h>
      12                 :             : 
      13                 :             : using kernel::ChainstateRole;
      14                 :             : 
      15                 :           0 : void TestBlockManager::CleanupForFuzzing()
      16                 :             : {
      17                 :           0 :     m_dirty_blockindex.clear();
      18                 :           0 :     m_dirty_fileinfo.clear();
      19                 :           0 :     m_blockfile_info.resize(1);
      20                 :           0 : }
      21                 :             : 
      22                 :           0 : void TestChainstateManager::DisableNextWrite()
      23                 :             : {
      24                 :           0 :     struct TestChainstate : public Chainstate {
      25                 :           0 :         void ResetNextWrite() { m_next_write = NodeClock::time_point::max() - 1s; }
      26                 :             :     };
      27                 :           0 :     LOCK(::cs_main);
      28         [ #  # ]:           0 :     for (const auto& cs : m_chainstates) {
      29                 :           0 :         static_cast<TestChainstate&>(*cs).ResetNextWrite();
      30                 :             :     }
      31                 :           0 : }
      32                 :             : 
      33                 :           2 : void TestChainstateManager::ResetIbd()
      34                 :             : {
      35                 :           2 :     m_cached_finished_ibd = false;
      36         [ -  + ]:           2 :     assert(IsInitialBlockDownload());
      37                 :           2 : }
      38                 :             : 
      39                 :           1 : void TestChainstateManager::JumpOutOfIbd()
      40                 :             : {
      41         [ -  + ]:           1 :     Assert(IsInitialBlockDownload());
      42                 :           1 :     m_cached_finished_ibd = true;
      43         [ -  + ]:           1 :     Assert(!IsInitialBlockDownload());
      44                 :           1 : }
      45                 :             : 
      46                 :           1 : void ValidationInterfaceTest::BlockConnected(
      47                 :             :     const ChainstateRole& role,
      48                 :             :     CValidationInterface& obj,
      49                 :             :     const std::shared_ptr<const CBlock>& block,
      50                 :             :     const CBlockIndex* pindex)
      51                 :             : {
      52                 :           1 :     obj.BlockConnected(role, block, pindex);
      53                 :           1 : }
      54                 :           0 : void TestChainstateManager::InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state)
      55                 :             : {
      56                 :           0 :     struct TestChainstate : public Chainstate {
      57                 :           0 :         void CallInvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
      58                 :             :         {
      59                 :           0 :             InvalidBlockFound(pindex, state);
      60                 :             :         }
      61                 :             :     };
      62                 :             : 
      63                 :           0 :     static_cast<TestChainstate*>(&ActiveChainstate())->CallInvalidBlockFound(pindex, state);
      64                 :           0 : }
      65                 :             : 
      66                 :           0 : void TestChainstateManager::InvalidChainFound(CBlockIndex* pindexNew)
      67                 :             : {
      68                 :           0 :     struct TestChainstate : public Chainstate {
      69                 :           0 :         void CallInvalidChainFound(CBlockIndex* pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
      70                 :             :         {
      71                 :           0 :             InvalidChainFound(pindexNew);
      72                 :             :         }
      73                 :             :     };
      74                 :             : 
      75                 :           0 :     static_cast<TestChainstate*>(&ActiveChainstate())->CallInvalidChainFound(pindexNew);
      76                 :           0 : }
      77                 :             : 
      78                 :           0 : CBlockIndex* TestChainstateManager::FindMostWorkChain()
      79                 :             : {
      80                 :           0 :     struct TestChainstate : public Chainstate {
      81                 :           0 :         CBlockIndex* CallFindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
      82                 :             :         {
      83                 :           0 :             return FindMostWorkChain();
      84                 :             :         }
      85                 :             :     };
      86                 :             : 
      87                 :           0 :     return static_cast<TestChainstate*>(&ActiveChainstate())->CallFindMostWorkChain();
      88                 :             : }
      89                 :             : 
      90                 :           0 : void TestChainstateManager::ResetBestInvalid()
      91                 :             : {
      92                 :           0 :     m_best_invalid = nullptr;
      93                 :           0 : }
        

Generated by: LCOV version 2.0-1