LCOV - code coverage report
Current view: top level - src/test/fuzz - net_permissions.cpp (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 22 22
Test Date: 2024-12-04 04:00:22 Functions: 100.0 % 2 2
Branches: 55.9 % 34 19

             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 <net_permissions.h>
       6                 :             : #include <netbase.h>
       7                 :             : #include <test/fuzz/FuzzedDataProvider.h>
       8                 :             : #include <test/fuzz/fuzz.h>
       9                 :             : #include <test/fuzz/util.h>
      10                 :             : #include <test/fuzz/util/net.h>
      11                 :             : #include <util/translation.h>
      12                 :             : 
      13                 :             : #include <cassert>
      14                 :             : #include <cstdint>
      15                 :             : #include <string>
      16                 :             : #include <vector>
      17                 :             : 
      18         [ +  - ]:         755 : FUZZ_TARGET(net_permissions)
      19                 :             : {
      20                 :         343 :     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      21                 :         343 :     const std::string s = fuzzed_data_provider.ConsumeRandomLengthString(1000);
      22                 :         343 :     const NetPermissionFlags net_permission_flags = ConsumeWeakEnum(fuzzed_data_provider, ALL_NET_PERMISSION_FLAGS);
      23                 :             : 
      24         [ +  - ]:         343 :     NetWhitebindPermissions net_whitebind_permissions;
      25         [ +  - ]:         343 :     bilingual_str error_net_whitebind_permissions;
      26   [ +  -  +  + ]:         343 :     if (NetWhitebindPermissions::TryParse(s, net_whitebind_permissions, error_net_whitebind_permissions)) {
      27         [ +  - ]:          11 :         (void)NetPermissions::ToStrings(net_whitebind_permissions.m_flags);
      28         [ +  - ]:          11 :         (void)NetPermissions::AddFlag(net_whitebind_permissions.m_flags, net_permission_flags);
      29                 :          11 :         assert(NetPermissions::HasFlag(net_whitebind_permissions.m_flags, net_permission_flags));
      30         [ +  - ]:          11 :         (void)NetPermissions::ClearFlag(net_whitebind_permissions.m_flags, NetPermissionFlags::Implicit);
      31         [ +  - ]:          11 :         (void)NetPermissions::ToStrings(net_whitebind_permissions.m_flags);
      32                 :             :     }
      33                 :             : 
      34         [ +  - ]:         343 :     NetWhitelistPermissions net_whitelist_permissions;
      35                 :         343 :     ConnectionDirection connection_direction;
      36         [ +  - ]:         343 :     bilingual_str error_net_whitelist_permissions;
      37   [ +  -  +  + ]:         343 :     if (NetWhitelistPermissions::TryParse(s, net_whitelist_permissions, connection_direction, error_net_whitelist_permissions)) {
      38         [ +  - ]:          67 :         (void)NetPermissions::ToStrings(net_whitelist_permissions.m_flags);
      39         [ +  - ]:          67 :         (void)NetPermissions::AddFlag(net_whitelist_permissions.m_flags, net_permission_flags);
      40                 :          67 :         assert(NetPermissions::HasFlag(net_whitelist_permissions.m_flags, net_permission_flags));
      41         [ +  - ]:          67 :         (void)NetPermissions::ClearFlag(net_whitelist_permissions.m_flags, NetPermissionFlags::Implicit);
      42         [ +  - ]:          67 :         (void)NetPermissions::ToStrings(net_whitelist_permissions.m_flags);
      43                 :             :     }
      44                 :         686 : }
        

Generated by: LCOV version 2.0-1