diff options
author | fanquake <fanquake@gmail.com> | 2024-03-01 10:07:35 -0500 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2024-03-01 10:07:48 -0500 |
commit | ae4165f7bc395ffdfc0ff46371d539d29c54dfce (patch) | |
tree | df809d02b25ff762b3f2f990f04b36c40921cfee /src | |
parent | d72cf823d4f0a79dd8720f9b81996ef4a703be40 (diff) | |
parent | 25eab523897e790f4f4d7b49cdbf19d13e3b0fcc (diff) |
Merge bitcoin/bitcoin#29495: fuzz: add target for local address stuff
25eab523897e790f4f4d7b49cdbf19d13e3b0fcc fuzz: add target for local addresses (brunoerg)
Pull request description:
This PR adds fuzz target for local address functions - (`AddLocal`, `RemoveLocal`, `SeenLocal`, `IsLocal`)
ACKs for top commit:
dergoegge:
ACK 25eab523897e790f4f4d7b49cdbf19d13e3b0fcc
vasild:
ACK 25eab523897e790f4f4d7b49cdbf19d13e3b0fcc
Tree-SHA512: 24faaab86dcd8835ba0e2d81fb6322a39a9266c7edf66415dbc4421754054f47efb6e0de4efdc7ea026b0686792658e86a526f7cf27cbc6cf9ed0c4aed376f97
Diffstat (limited to 'src')
-rw-r--r-- | src/test/fuzz/net.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/test/fuzz/net.cpp b/src/test/fuzz/net.cpp index c882bd766a..e8b1480c5b 100644 --- a/src/test/fuzz/net.cpp +++ b/src/test/fuzz/net.cpp @@ -77,3 +77,40 @@ FUZZ_TARGET(net, .init = initialize_net) (void)node.HasPermission(net_permission_flags); (void)node.ConnectedThroughNetwork(); } + +FUZZ_TARGET(local_address, .init = initialize_net) +{ + FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); + CService service{ConsumeService(fuzzed_data_provider)}; + CNode node{ConsumeNode(fuzzed_data_provider)}; + { + LOCK(g_maplocalhost_mutex); + mapLocalHost.clear(); + } + LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) { + CallOneOf( + fuzzed_data_provider, + [&] { + service = ConsumeService(fuzzed_data_provider); + }, + [&] { + const bool added{AddLocal(service, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, LOCAL_MAX - 1))}; + if (!added) return; + assert(service.IsRoutable()); + assert(IsLocal(service)); + assert(SeenLocal(service)); + }, + [&] { + (void)RemoveLocal(service); + }, + [&] { + (void)SeenLocal(service); + }, + [&] { + (void)IsLocal(service); + }, + [&] { + (void)GetLocalAddress(node); + }); + } +} |