LCOV - code coverage report
Current view: top level - src/test - banman_tests.cpp (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 21 22 95.5 %
Date: 2022-04-21 14:51:19 Functions: 1 1 100.0 %
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: 0 0 -

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 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 <banman.h>
#       6                 :            : #include <chainparams.h>
#       7                 :            : #include <netbase.h>
#       8                 :            : #include <streams.h>
#       9                 :            : #include <test/util/logging.h>
#      10                 :            : #include <test/util/setup_common.h>
#      11                 :            : #include <util/readwritefile.h>
#      12                 :            : 
#      13                 :            : 
#      14                 :            : #include <boost/test/unit_test.hpp>
#      15                 :            : 
#      16                 :            : BOOST_FIXTURE_TEST_SUITE(banman_tests, BasicTestingSetup)
#      17                 :            : 
#      18                 :            : BOOST_AUTO_TEST_CASE(file)
#      19                 :          2 : {
#      20                 :          2 :     SetMockTime(777s);
#      21                 :          2 :     const fs::path banlist_path{m_args.GetDataDirBase() / "banlist_test"};
#      22                 :          2 :     {
#      23                 :          2 :         const std::string entries_write{
#      24                 :          2 :             "{ \"banned_nets\": ["
#      25                 :          2 :             "  { \"version\": 1, \"ban_created\": 0, \"banned_until\": 778, \"address\": \"aaaaaaaaa\" },"
#      26                 :          2 :             "  { \"version\": 2, \"ban_created\": 0, \"banned_until\": 778, \"address\": \"bbbbbbbbb\" },"
#      27                 :          2 :             "  { \"version\": 1, \"ban_created\": 0, \"banned_until\": 778, \"address\": \"1.0.0.0/8\" }"
#      28                 :          2 :             "] }",
#      29                 :          2 :         };
#      30                 :          2 :         assert(WriteBinaryFile(banlist_path + ".json", entries_write));
#      31                 :          0 :         {
#      32                 :            :             // The invalid entries will be dropped, but the valid one remains
#      33                 :          2 :             ASSERT_DEBUG_LOG("Dropping entry with unparseable address or subnet (aaaaaaaaa) from ban list");
#      34                 :          2 :             ASSERT_DEBUG_LOG("Dropping entry with unknown version (2) from ban list");
#      35                 :          2 :             BanMan banman{banlist_path, /*client_interface=*/nullptr, /*default_ban_time=*/0};
#      36                 :          2 :             banmap_t entries_read;
#      37                 :          2 :             banman.GetBanned(entries_read);
#      38                 :          2 :             assert(entries_read.size() == 1);
#      39                 :          2 :         }
#      40                 :          2 :     }
#      41                 :          2 : }
#      42                 :            : 
#      43                 :            : BOOST_AUTO_TEST_SUITE_END()

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