LCOV - code coverage report
Current view: top level - src/test/util - net.cpp (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 20 44 45.5 %
Date: 2022-04-21 14:51:19 Functions: 1 3 33.3 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 2 6 33.3 %

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2020-2021 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/net.h>
#       6                 :            : 
#       7                 :            : #include <chainparams.h>
#       8                 :            : #include <net.h>
#       9                 :            : #include <span.h>
#      10                 :            : 
#      11                 :            : #include <vector>
#      12                 :            : 
#      13                 :            : void ConnmanTestMsg::NodeReceiveMsgBytes(CNode& node, Span<const uint8_t> msg_bytes, bool& complete) const
#      14                 :          0 : {
#      15                 :          0 :     assert(node.ReceiveMsgBytes(msg_bytes, complete));
#      16         [ #  # ]:          0 :     if (complete) {
#      17                 :          0 :         size_t nSizeAdded = 0;
#      18                 :          0 :         auto it(node.vRecvMsg.begin());
#      19         [ #  # ]:          0 :         for (; it != node.vRecvMsg.end(); ++it) {
#      20                 :            :             // vRecvMsg contains only completed CNetMessage
#      21                 :            :             // the single possible partially deserialized message are held by TransportDeserializer
#      22                 :          0 :             nSizeAdded += it->m_raw_message_size;
#      23                 :          0 :         }
#      24                 :          0 :         {
#      25                 :          0 :             LOCK(node.cs_vProcessMsg);
#      26                 :          0 :             node.vProcessMsg.splice(node.vProcessMsg.end(), node.vRecvMsg, node.vRecvMsg.begin(), it);
#      27                 :          0 :             node.nProcessQueueSize += nSizeAdded;
#      28                 :          0 :             node.fPauseRecv = node.nProcessQueueSize > nReceiveFloodSize;
#      29                 :          0 :         }
#      30                 :          0 :     }
#      31                 :          0 : }
#      32                 :            : 
#      33                 :            : bool ConnmanTestMsg::ReceiveMsgFrom(CNode& node, CSerializedNetMsg& ser_msg) const
#      34                 :          0 : {
#      35                 :          0 :     std::vector<uint8_t> ser_msg_header;
#      36                 :          0 :     node.m_serializer->prepareForTransport(ser_msg, ser_msg_header);
#      37                 :            : 
#      38                 :          0 :     bool complete;
#      39                 :          0 :     NodeReceiveMsgBytes(node, ser_msg_header, complete);
#      40                 :          0 :     NodeReceiveMsgBytes(node, ser_msg.data, complete);
#      41                 :          0 :     return complete;
#      42                 :          0 : }
#      43                 :            : 
#      44                 :            : std::vector<NodeEvictionCandidate> GetRandomNodeEvictionCandidates(int n_candidates, FastRandomContext& random_context)
#      45                 :       3248 : {
#      46                 :       3248 :     std::vector<NodeEvictionCandidate> candidates;
#      47         [ +  + ]:     322084 :     for (int id = 0; id < n_candidates; ++id) {
#      48                 :     318836 :         candidates.push_back({
#      49                 :     318836 :             /*id=*/id,
#      50                 :     318836 :             /*m_connected=*/std::chrono::seconds{random_context.randrange(100)},
#      51                 :     318836 :             /*m_min_ping_time=*/std::chrono::microseconds{random_context.randrange(100)},
#      52                 :     318836 :             /*m_last_block_time=*/std::chrono::seconds{random_context.randrange(100)},
#      53                 :     318836 :             /*m_last_tx_time=*/std::chrono::seconds{random_context.randrange(100)},
#      54                 :     318836 :             /*fRelevantServices=*/random_context.randbool(),
#      55                 :     318836 :             /*m_relay_txs=*/random_context.randbool(),
#      56                 :     318836 :             /*fBloomFilter=*/random_context.randbool(),
#      57                 :     318836 :             /*nKeyedNetGroup=*/random_context.randrange(100),
#      58                 :     318836 :             /*prefer_evict=*/random_context.randbool(),
#      59                 :     318836 :             /*m_is_local=*/random_context.randbool(),
#      60                 :     318836 :             /*m_network=*/ALL_NETWORKS[random_context.randrange(ALL_NETWORKS.size())],
#      61                 :     318836 :         });
#      62                 :     318836 :     }
#      63                 :       3248 :     return candidates;
#      64                 :       3248 : }

Generated by: LCOV version 0-eol-96201-ge66f56f4af6a